wxArt2D
xmlpars.h
Go to the documentation of this file.
1 /*! \file wx/canvas/xmlpars.h
2  \brief a2dIOHandlerCVGIn and a2dIOHandlerCVGOut - XML I/O classes for the CVG format.
3 
4  The main way of serialisation is done with XML and the format is called CVG ( canvas vector graphics ).
5 
6  \author Probably Klaas Holwerda
7 
8  Copyright: 2001-2004 (C) Probably Klaas Holwerda
9 
10  Licence: wxWidgets licence
11 
12  RCS-ID: $Id: xmlpars.h,v 1.16 2009/05/15 16:34:28 titato Exp $
13 */
14 
15 #ifndef _WX_CANVASXMLIO_H_
16 #define _WX_CANVASXMLIO_H_
17 
18 #include "a2dprivate.h"
19 
20 #if wxART2D_USE_XMLPARSE
21 
22 #include <wx/defs.h>
23 #include <wx/string.h>
24 
25 #if wxCHECK_VERSION(2, 5, 3)
26 #include <wx/sstream.h>
27 #endif
28 
29 #include <expat.h>
30 
31 #include "wx/xmlparse/genxmlpars.h"
32 #include "wx/xmlparse/xmlencode.h"
33 #include "wx/canvas/candefs.h"
34 #include "wx/canvas/canobj.h"
35 
36 #if wxART2D_USE_CVGIO
37 
38 
39 //! Input handler for the CVG format.
40 /*!
41  The CVG format is the native file format of wxArt2d.
42  It's a XML format and each a2dCanvasObject is able to load its data from CVG.
43  There's no specification of the CVG, please have a look into the DoLoad methods
44  of the a2dCanvasObject derived classes to see details.
45 
46  In general the following is done.
47  - each a2dObject has a2dObject::Save() and a2dObject::Load() as a start for serialisation.
48  - a2dObject::DoLoad and a2dObject::DoSave() methods are virtual and should be implemented
49  to save also the data of the derived classes.
50  - Saving is a two pass process, in order to first write all XML attributes of an object and next
51  its NON attribute data and nested objects.
52  - one always needs to call derivedFrom::DoLoad in the implementation of a Doload()
53  - one always needs to call derivedFrom::DoSave in the implementation of a DoSave()
54  - multiple referenced objects are written only by refid attribute. When loading the file,
55  those references are resolved.
56 
57  \ingroup fileio cvgfileio
58 */
59 class A2DCANVASDLLEXP a2dIOHandlerCVGIn : public a2dIOHandlerXmlSerIn
60 {
61 public:
62  //! Constructor.
64 
65  //! Destructor.
67 
68  //! test header of the file to see if its CVG format
69  virtual bool CanLoad( a2dDocumentInputStream& stream, const wxObject* obj = NULL, wxClassInfo* docClassInfo = NULL );
70 
71  //! load a layer definition from a CVG file.
72  bool LoadLayers( a2dDocumentInputStream& stream, a2dLayers* layers );
73 
74  //! reading a CVG document and add the contents as children to a given a2dCanvasObject parent.
75  /*!
76  This can be used to include a CVG document in an existing document.
77  Also clipboard action might use this.
78  */
79  bool Load( a2dDocumentStringInputStream& stream, a2dDrawing* doc, a2dCanvasObject* parent );
80 
81  //! reading a single CVG canvasobject from a stream.
82  /*!
83  used Drag and Drop.
84  \param stream the stream to read from
85  \param canvasobject on return contain the read CVG canvas object.
86  */
87  bool Load( a2dDocumentStringInputStream& stream, a2dCanvasObjectPtr& canvasobject );
88 
89 protected:
90 
91 
92 };
93 
94 //! output handler for the CVG format.
95 /*!
96  The CVG format is the native file format of wxArt2d.
97  It's a XML format and each a2dCanvasObject is able to save its data as CVG.
98  There's no specification of the CVG, please have a look into the DoSave methods
99  of the a2dCanvasObject derived classes to see details.
100 
101  \ingroup fileio cvgfileio
102 */
103 class A2DCANVASDLLEXP a2dIOHandlerCVGOut : public a2dIOHandlerXmlSerOut
104 {
105 public:
106  //! Constructor.
108 
109  //! Destructor.
111 
112  //! this handler can also save as CVG
113  bool CanSave( const wxObject* obj = NULL ) { return true; }
114 
115  //! saves as CVG starting at object start
116  bool SaveStartAt( a2dDocumentOutputStream& stream, const a2dDrawing* drawing, a2dCanvasObject* start );
117 
118  //! save a layer definition to a CVG file.
119  bool SaveLayers( a2dDocumentOutputStream& stream, a2dLayers* layers );
120 
121  void WriteCvgStartDocument( a2dDocumentOutputStream& stream );
122 
123  void WriteCvgEndDocument();
124 
125  void WriteObject( a2dCanvasObject* start );
126 
127 protected:
128 
129  //! the document to store/load the data found into
131 };
132 
133 #endif //wxART2D_USE_CVGIO
134 
135 #endif // wxART2D_USE_XMLPARSE
136 
137 #endif /* _WX_CANVASXMLIO_H_ */
138 
bool CanSave(const wxObject *obj=NULL)
this handler can also save as CVG
Definition: xmlpars.h:113
virtual bool Load(a2dDocumentInputStream &stream, wxObject *doc)
load a complete document
a2dDrawing * m_drawing
the document to store/load the data found into
Definition: xmlpars.h:130
wxOutputStream a2dDocumentOutputStream
output stream based wxStreams
Definition: gen.h:3458
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
The base class for all drawable objects in a a2dCanvasDocument.
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
output handler for the CVG format.
Definition: xmlpars.h:103
defenitions an no more
XML I/O classes which is Pull parser based for reading XML files.
wxStringInputStream a2dDocumentStringInputStream
string input stream based wxStreams
Definition: gen.h:3452
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
bool CanLoad(a2dDocumentInputStream &stream, const wxObject *obj, wxClassInfo *docClassInfo=NULL)
test header of the file to see if its CVG format
functions for encoding characters in xml
wxInputStream a2dDocumentInputStream
input stream based wxStreams
Definition: gen.h:3456
Input handler for the CVG format.
Definition: xmlpars.h:59
Contain one drawing as hierarchical tree of a2dCanvasObject&#39;s.
Definition: drawing.h:434
xmlpars.h Source File -- Sun Oct 12 2014 17:04:26 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation