00001
00022
00023
00024
00025
00026 #ifndef __SYNFIG_LOADCANVAS_H
00027 #define __SYNFIG_LOADCANVAS_H
00028
00029
00030
00031 #include "string.h"
00032 #include "canvas.h"
00033 #include "valuenode.h"
00034 #include "vector.h"
00035 #include "value.h"
00036 #include "valuenode_subtract.h"
00037 #include "valuenode_animated.h"
00038 #include "valuenode_composite.h"
00039 #include "valuenode_dynamiclist.h"
00040 #include "keyframe.h"
00041 #include "guid.h"
00042
00043
00044
00045
00046
00047
00048
00049 namespace xmlpp { class Node; class Element; };
00050
00051 namespace synfig {
00052
00056 class CanvasParser
00057 {
00058
00059
00060
00061
00062 private:
00063
00064 int max_warnings_;
00065
00066 int total_warnings_;
00067
00068 int total_errors_;
00069
00070 bool allow_errors_;
00071
00072 String filename;
00073
00074 String path;
00075
00076 GUID guid_;
00077
00078
00079
00080
00081
00082 public:
00083
00084 CanvasParser():
00085 max_warnings_ (1000),
00086 total_warnings_ (0),
00087 total_errors_ (0),
00088 allow_errors_ (false)
00089 { }
00090
00091
00092
00093
00094
00095 public:
00096
00098 CanvasParser &set_allow_errors(bool x) { allow_errors_=x; return *this; }
00099
00101 CanvasParser &set_max_warnings(int i) { max_warnings_=i; return *this; }
00102
00104 int get_max_warnings() { return max_warnings_; }
00105
00107 int error_count()const { return total_errors_; }
00108
00110 int warning_count()const { return total_warnings_; }
00111
00112 void set_path(const synfig::String& x) { path=x; }
00113
00114 const synfig::String& get_path()const { return path; }
00115
00117 Canvas::Handle parse_from_file(const String &filename);
00118
00119 Canvas::Handle parse_from_file_as(const String &filename,const String &as);
00120
00122 Canvas::Handle parse_from_string(const String &data);
00123
00124 private:
00125
00126
00127
00128 void error(xmlpp::Node *node,const String &text);
00129 void fatal_error(xmlpp::Node *node,const String &text);
00130 void warning(xmlpp::Node *node,const String &text);
00131 void error_unexpected_element(xmlpp::Node *node,const String &got, const String &expected);
00132 void error_unexpected_element(xmlpp::Node *node,const String &got);
00133
00134
00135
00136 Canvas::Handle parse_canvas(xmlpp::Element *node,Canvas::Handle parent=0,bool inline_=false, String path=".");
00137 void parse_canvas_defs(xmlpp::Element *node,Canvas::Handle canvas);
00138 etl::handle<Layer> parse_layer(xmlpp::Element *node,Canvas::Handle canvas);
00139 ValueBase parse_value(xmlpp::Element *node,Canvas::Handle canvas);
00140 etl::handle<ValueNode> parse_value_node(xmlpp::Element *node,Canvas::Handle canvas);
00141
00142
00143
00144 Real parse_real(xmlpp::Element *node);
00145 Time parse_time(xmlpp::Element *node,Canvas::Handle canvas);
00146 int parse_integer(xmlpp::Element *node);
00147 Vector parse_vector(xmlpp::Element *node);
00148 Color parse_color(xmlpp::Element *node);
00149 Angle parse_angle(xmlpp::Element *node);
00150 String parse_string(xmlpp::Element *node);
00151 bool parse_bool(xmlpp::Element *node);
00152 Segment parse_segment(xmlpp::Element *node);
00153 ValueBase parse_list(xmlpp::Element *node,Canvas::Handle canvas);
00154 Gradient parse_gradient(xmlpp::Element *node);
00155 BLinePoint parse_bline_point(xmlpp::Element *node);
00156
00157 Keyframe parse_keyframe(xmlpp::Element *node,Canvas::Handle canvas);
00158
00159
00160
00161 etl::handle<ValueNode_Animated> parse_animated(xmlpp::Element *node,Canvas::Handle canvas);
00162 etl::handle<ValueNode_Subtract> parse_subtract(xmlpp::Element *node,Canvas::Handle canvas);
00163 etl::handle<LinkableValueNode> parse_linkable_value_node(xmlpp::Element *node,Canvas::Handle canvas);
00164 etl::handle<ValueNode_Composite> parse_composite(xmlpp::Element *node,Canvas::Handle canvas);
00165 etl::handle<ValueNode_DynamicList> parse_dynamic_list(xmlpp::Element *node,Canvas::Handle canvas);
00166
00167 };
00168
00169
00170
00172
00173 extern Canvas::Handle open_canvas(const String &filename);
00174 extern Canvas::Handle open_canvas_as(const String &filename,const String &as);
00175
00177 extern Canvas::Handle string_to_canvas(const String &data);
00178
00179 std::map<synfig::String, etl::loose_handle<Canvas> >& get_open_canvas_map();
00180
00181 };
00182
00183
00184
00185 #endif