loadcanvas.h

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

Generated on Wed Aug 15 05:00:23 2007 for synfig by  doxygen 1.5.3