source: trunk/VUT/GtpVisibilityPreprocessor/src/X3dParserXerces.h @ 180

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