Code

Connector tool: make connectors avoid the convex hull of shapes.
[inkscape.git] / src / dom / svgreader.h
1 #ifndef __SVGREADER_H__
2 #define __SVGREADER_H__
4 /**
5  * Phoebe DOM Implementation.
6  *
7  * This is a C++ approximation of the W3C DOM model, which follows
8  * fairly closely the specifications in the various .idl files, copies of
9  * which are provided for reference.  Most important is this one:
10  *
11  * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
12  *
13  * Authors:
14  *   Bob Jamison
15  *
16  * Copyright (C) 2005-2008 Bob Jamison
17  *
18  *  This library is free software; you can redistribute it and/or
19  *  modify it under the terms of the GNU Lesser General Public
20  *  License as published by the Free Software Foundation; either
21  *  version 2.1 of the License, or (at your option) any later version.
22  *
23  *  This library is distributed in the hope that it will be useful,
24  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26  *  Lesser General Public License for more details.
27  *
28  *  You should have received a copy of the GNU Lesser General Public
29  *  License along with this library; if not, write to the Free Software
30  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
31  *  
32  * =======================================================================
33  * NOTES
34  * 
35  * This parser takes an XML document, as a file, string, or DOM Document,
36  * and attempts to parse it as an SVG-DOM  SVGDocument.
37  * 
38  * Look in svg.h and svgtypes.h for the classes which are the target of this
39  * parser.
40  * 
41  * They loosely follow the specification:
42  * http://www.w3.org/TR/SVG11/svgdom.html
43  *              
44  */
47 #include "svgimpl.h"
49 namespace org
50 {
51 namespace w3c
52 {
53 namespace dom
54 {
55 namespace svg
56 {
59 class SVGReader
60 {
61 public:
63     /**
64      *
65      */
66     SVGReader()
67         {
68         }
70     /**
71      *
72      */
73     SVGReader(const SVGReader &/*other*/)
74         {
75         }
77     /**
78      *
79      */
80     virtual ~SVGReader()
81         {
82         }
84     /**
85      *
86      */
87     SVGDocumentPtr parse(const DocumentPtr /*sourceDoc*/);
89     /**
90      *
91      */
92     SVGDocumentPtr parse(const DOMString &/*buffer*/);
94     /**
95      *
96      */
97     SVGDocumentPtr parseFile(const DOMString &/*fileName*/);
102 private:
104     /**
105      *  Get the next character in the parse buf,  0 if out
106      *  of range
107      */
108     XMLCh get(int p);
110     /**
111      *  Test if the given substring exists at the given position
112      *  in parsebuf.  Use get() in case of out-of-bounds
113      */
114     bool match(int pos, char const *str);
116     /**
117      *
118      */
119     int skipwhite(int p);
121     /**
122      * get a word from the buffer
123      */
124     int getWord(int p, DOMString &result);
126     /**
127      * get a word from the buffer
128      */
129     int getNumber(int p0, double &result);
132     /**
133      *
134      */
135     bool parseTransform(const DOMString &str);
138     /**
139      *
140      */
141     bool parseElement(SVGElementImplPtr destElem,
142                       ElementImplPtr sourceElem);
145     /**
146      *
147      */
148     void error(char const *format, ...)
149     #ifdef G_GNUC_PRINTF
150     G_GNUC_PRINTF(2, 3)
151     #endif
152     ;
154     /**
155      *
156      */
157     void trace(char const *format, ...)
158     #ifdef G_GNUC_PRINTF
159     G_GNUC_PRINTF(2, 3)
160     #endif
161     ;
165     DOMString parsebuf;
166     int parselen;
167     int lastPosition;
169     SVGDocumentImplPtr doc;
171 };
177 }  //namespace svg
178 }  //namespace dom
179 }  //namespace w3c
180 }  //namespace org
182 #endif /* __SVGREADER_H__ */
183 /*#########################################################################
184 ## E N D    O F    F I L E
185 #########################################################################*/