synfig-core  1.0.3
loadcanvas.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
23 /* ========================================================================= */
24 
25 /* === S T A R T =========================================================== */
26 
27 #ifndef __SYNFIG_LOADCANVAS_H
28 #define __SYNFIG_LOADCANVAS_H
29 
30 /* === H E A D E R S ======================================================= */
31 
32 #include "string.h"
33 #include "canvas.h"
34 #include "valuenode.h"
35 #include "vector.h"
36 #include "value.h"
42 #include "keyframe.h"
43 #include "guid.h"
44 #include "filesystemnative.h"
45 #include "weightedvalue.h"
46 #include "pair.h"
47 
48 /* === M A C R O S ========================================================= */
49 
50 /* === T Y P E D E F S ===================================================== */
51 
52 /* === C L A S S E S & S T R U C T S ======================================= */
53 
54 namespace xmlpp { class Node; class Element; };
55 
56 namespace synfig {
57 
63 {
64  /*
65  -- ** -- D A T A -------------------------------------------------------------
66  */
67 
68 private:
70  int max_warnings_;
72  int total_warnings_;
74  int total_errors_;
76  bool allow_errors_;
78  String filename;
80  String path;
82  String errors_text;
84  String warnings_text;
86  GUID guid_;
87 
88  /*
89  -- ** -- C O N S T R U C T O R S ---------------------------------------------
90  */
91 
92 public:
93 
95  max_warnings_ (1000),
96  total_warnings_ (0),
97  total_errors_ (0),
98  allow_errors_ (false)
99  { }
100 
101  /*
102  -- ** -- M E M B E R F U N C T I O N S -------------------------------------
103  */
104 
105 public:
106 
108  CanvasParser &set_allow_errors(bool x) { allow_errors_=x; return *this; }
109 
111  CanvasParser &set_max_warnings(int i) { max_warnings_=i; return *this; }
112 
114  int get_max_warnings() { return max_warnings_; }
115 
117  int error_count()const { return total_errors_; }
118 
120  int warning_count()const { return total_warnings_; }
121 
123  void set_path(const synfig::String& x) { path=x; }
124 
126  const synfig::String& get_path()const { return path; }
127 
129  const synfig::String& get_errors_text()const { return errors_text; }
131  const synfig::String& get_warnings_text()const { return warnings_text; }
132 
134 
137  static void register_canvas_in_map(Canvas::Handle canvas, String as);
138 
139 #ifdef _DEBUG
140  static void show_canvas_map(String file, int line, String text);
141 #endif // _DEBUG
142 
144  Canvas::Handle parse_from_file_as(const FileSystem::Identifier &identifier,const String &as,String &errors);
146  Canvas::Handle parse_as(xmlpp::Element* node,String &errors);
147 
149  static std::set<FileSystem::Identifier> loading_;
150 
151 private:
152 
154  void error(xmlpp::Node *node,const String &text);
156  void fatal_error(xmlpp::Node *node,const String &text);
158  void warning(xmlpp::Node *node,const String &text);
160  void error_unexpected_element(xmlpp::Node *node,const String &got, const String &expected);
162  void error_unexpected_element(xmlpp::Node *node,const String &got);
163 
165  Canvas::Handle parse_canvas(xmlpp::Element *node,Canvas::Handle parent=0,bool inline_=false,const FileSystem::Identifier &identifier = FileSystemNative::instance()->get_identifier(std::string()),String path=".");
167  void parse_canvas_defs(xmlpp::Element *node,Canvas::Handle canvas);
168 
169  std::list<ValueNode::Handle> parse_canvas_bones(xmlpp::Element *node,Canvas::Handle canvas);
170 
172  etl::handle<Layer> parse_layer(xmlpp::Element *node,Canvas::Handle canvas);
174  ValueBase parse_value(xmlpp::Element *node,Canvas::Handle canvas);
176  etl::handle<ValueNode> parse_value_node(xmlpp::Element *node,Canvas::Handle canvas);
177 
179  Real parse_real(xmlpp::Element *node);
181  Time parse_time(xmlpp::Element *node,Canvas::Handle canvas);
183  int parse_integer(xmlpp::Element *node);
185  Vector parse_vector(xmlpp::Element *node);
187  Color parse_color(xmlpp::Element *node);
189  Angle parse_angle(xmlpp::Element *node);
191  String parse_string(xmlpp::Element *node);
193  bool parse_bool(xmlpp::Element *node);
195  Segment parse_segment(xmlpp::Element *node);
197  ValueBase parse_list(xmlpp::Element *node,Canvas::Handle canvas);
199  ValueBase parse_weighted_value(xmlpp::Element *node, types_namespace::TypeWeightedValueBase &type, Canvas::Handle canvas);
201  ValueBase parse_pair(xmlpp::Element *node, types_namespace::TypePairBase &type, Canvas::Handle canvas);
203  Gradient parse_gradient(xmlpp::Element *node);
205  BLinePoint parse_bline_point(xmlpp::Element *node);
207  Transformation parse_transformation(xmlpp::Element *node);
208 
209  GUID parse_guid(xmlpp::Element *node);
210 
212  WidthPoint parse_width_point(xmlpp::Element *node);
214  DashItem parse_dash_item(xmlpp::Element *node);
215 
217  Keyframe parse_keyframe(xmlpp::Element *node,Canvas::Handle canvas);
218 
220  etl::handle<ValueNode_Animated> parse_animated(xmlpp::Element *node,Canvas::Handle canvas);
222  etl::handle<LinkableValueNode> parse_linkable_value_node(xmlpp::Element *node,Canvas::Handle canvas);
223 
225  etl::handle<ValueNode_StaticList> parse_static_list(xmlpp::Element *node,Canvas::Handle canvas);
226 
228  etl::handle<ValueNode_DynamicList> parse_dynamic_list(xmlpp::Element *node,Canvas::Handle canvas);
229 
231  Interpolation parse_interpolation(xmlpp::Element *node, String attribute);
233  bool parse_static(xmlpp::Element *node);
234 
235 }; // END of CanvasParser
236 
237 /* === E X T E R N S ======================================================= */
238 
240 
241 extern Canvas::Handle open_canvas(xmlpp::Element* node,String &errors,String &warnings);
243 
244 extern Canvas::Handle open_canvas_as(const FileSystem::Identifier &identifier,const String &as,String &errors,String &warnings);
245 
248 std::map<String, etl::loose_handle<Canvas> >& get_open_canvas_map();
249 
250 }; // END of namespace synfig
251 
252 /* === E N D =============================================================== */
253 
254 #endif