1 | #ifndef _X3D_PARSER_XERCES__H
|
---|
2 | #define _X3D_PARSER_XERCES__H
|
---|
3 |
|
---|
4 | // ---------------------------------------------------------------------------
|
---|
5 | // Includes
|
---|
6 | // ---------------------------------------------------------------------------
|
---|
7 | #include <xercesc/sax/HandlerBase.hpp>
|
---|
8 | #include "Mesh.h"
|
---|
9 |
|
---|
10 | XERCES_CPP_NAMESPACE_USE
|
---|
11 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
12 | class AttributeList;
|
---|
13 | XERCES_CPP_NAMESPACE_END
|
---|
14 |
|
---|
15 | class VspBspTree;
|
---|
16 | class ViewCellsManager;
|
---|
17 |
|
---|
18 | class ViewCellsParseHandlers: public HandlerBase
|
---|
19 | {
|
---|
20 | public:
|
---|
21 | // -----------------------------------------------------------------------
|
---|
22 | // Constructors and Destructor
|
---|
23 | // -----------------------------------------------------------------------
|
---|
24 | ViewCellsParseHandlers(VspBspTree *tree,
|
---|
25 | ViewCellsManager *viewCellsManager,
|
---|
26 | ObjectContainer *objects);
|
---|
27 | ~ViewCellsParseHandlers();
|
---|
28 |
|
---|
29 |
|
---|
30 | // -----------------------------------------------------------------------
|
---|
31 | // Getter methods
|
---|
32 | // -----------------------------------------------------------------------
|
---|
33 | unsigned int GetElementCount()
|
---|
34 | {
|
---|
35 | return mElementCount;
|
---|
36 | }
|
---|
37 |
|
---|
38 | unsigned int GetAttrCount()
|
---|
39 | {
|
---|
40 | return mAttrCount;
|
---|
41 | }
|
---|
42 |
|
---|
43 | unsigned int GetCharacterCount()
|
---|
44 | {
|
---|
45 | return mCharacterCount;
|
---|
46 | }
|
---|
47 |
|
---|
48 | unsigned int GetSpaceCount()
|
---|
49 | {
|
---|
50 | return mSpaceCount;
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 | // -----------------------------------------------------------------------
|
---|
55 | // Handlers for the SAX DocumentHandler interface
|
---|
56 | // -----------------------------------------------------------------------
|
---|
57 | void endElement(const XMLCh* const name);
|
---|
58 | void startElement(const XMLCh* const name, AttributeList& attributes);
|
---|
59 | void characters(const XMLCh* const chars, const unsigned int length);
|
---|
60 | void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
|
---|
61 | void resetDocument();
|
---|
62 |
|
---|
63 | VspBspTree *mVspBspTree;
|
---|
64 | BspNode *mCurrentNode;
|
---|
65 | ViewCellContainer mViewCells;
|
---|
66 | ViewCellsManager *mViewCellsManager;
|
---|
67 | ObjectContainer *mObjects;
|
---|
68 |
|
---|
69 | // Handlers for X3D
|
---|
70 | void StartLeaf(AttributeList& attributes);
|
---|
71 | void StartInterior(AttributeList& attributes);
|
---|
72 | void EndInterior();
|
---|
73 |
|
---|
74 | void StartViewCell(AttributeList& attributes);
|
---|
75 | void EndViewCells();
|
---|
76 |
|
---|
77 | // -----------------------------------------------------------------------
|
---|
78 | // Handlers for the SAX ErrorHandler interface
|
---|
79 | // -----------------------------------------------------------------------
|
---|
80 | void warning(const SAXParseException& exc);
|
---|
81 | void error(const SAXParseException& exc);
|
---|
82 | void fatalError(const SAXParseException& exc);
|
---|
83 |
|
---|
84 |
|
---|
85 | private:
|
---|
86 | // -----------------------------------------------------------------------
|
---|
87 | // Private data members
|
---|
88 | //
|
---|
89 | // fAttrCount
|
---|
90 | // fCharacterCount
|
---|
91 | // fElementCount
|
---|
92 | // fSpaceCount
|
---|
93 | // These are just counters that are run upwards based on the input
|
---|
94 | // from the document handlers.
|
---|
95 | // -----------------------------------------------------------------------
|
---|
96 | unsigned int mAttrCount;
|
---|
97 | unsigned int mCharacterCount;
|
---|
98 | unsigned int mElementCount;
|
---|
99 | unsigned int mSpaceCount;
|
---|
100 | };
|
---|
101 |
|
---|
102 | // ---------------------------------------------------------------------------
|
---|
103 | // This is a simple class that lets us do easy (though not terribly efficient)
|
---|
104 | // trancoding of XMLCh data to local code page for display.
|
---|
105 | // ---------------------------------------------------------------------------
|
---|
106 | class StrX
|
---|
107 | {
|
---|
108 | public :
|
---|
109 | // -----------------------------------------------------------------------
|
---|
110 | // Constructors and Destructor
|
---|
111 | // -----------------------------------------------------------------------
|
---|
112 | StrX(const XMLCh* const toTranscode)
|
---|
113 | {
|
---|
114 | // Call the private transcoding method
|
---|
115 | mLocalForm = XMLString::transcode(toTranscode);
|
---|
116 | }
|
---|
117 |
|
---|
118 | ~StrX()
|
---|
119 | {
|
---|
120 | XMLString::release(&mLocalForm);
|
---|
121 | }
|
---|
122 |
|
---|
123 | // -----------------------------------------------------------------------
|
---|
124 | // Getter methods
|
---|
125 | // -----------------------------------------------------------------------
|
---|
126 | const char* LocalForm() const
|
---|
127 | {
|
---|
128 | return mLocalForm;
|
---|
129 | }
|
---|
130 |
|
---|
131 | private :
|
---|
132 | // -----------------------------------------------------------------------
|
---|
133 | // Private data members
|
---|
134 | //
|
---|
135 | // fLocalForm
|
---|
136 | // This is the local code page form of the string.
|
---|
137 | // -----------------------------------------------------------------------
|
---|
138 | char* mLocalForm;
|
---|
139 | };
|
---|
140 |
|
---|
141 | inline XERCES_STD_QUALIFIER ostream&
|
---|
142 | operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
|
---|
143 | {
|
---|
144 | target << toDump.LocalForm();
|
---|
145 | return target;
|
---|
146 | }
|
---|
147 |
|
---|
148 | #endif
|
---|