source: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsParserXerces.h @ 575

Revision 575, 4.7 KB checked in by mattausch, 18 years ago (diff)

changed view cell parser. warning, not working yet!!

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#include "Mesh.h"
9
10XERCES_CPP_NAMESPACE_USE
11XERCES_CPP_NAMESPACE_BEGIN
12class AttributeList;
13XERCES_CPP_NAMESPACE_END
14
15class VspBspTree;
16class BspTree;
17class ViewCellsManager;
18
19class ViewCellsParseHandlers: public HandlerBase
20{
21public:
22  // -----------------------------------------------------------------------
23  //  Constructors and Destructor
24  // -----------------------------------------------------------------------
25  ViewCellsParseHandlers(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  void CreateViewCellsManager(const char *name);
64
65
66  VspBspTree *mVspBspTree;
67  BspTree *mBspTree;
68 
69  BspNode *mCurrentNode;
70  ViewCellContainer mViewCells;
71  ViewCellsManager *mViewCellsManager;
72  ObjectContainer *mObjects;
73
74  // Handlers for X3D
75  void StartBspLeaf(AttributeList& attributes);
76  void StartBspInterior(AttributeList& attributes);
77  void EndBspInterior();
78 
79  void StartViewCell(AttributeList&  attributes);
80  void EndViewCells();
81
82  void StartHierarchy(AttributeList& attributes);
83
84  void startBspElement(string element, AttributeList& attributes);
85  // -----------------------------------------------------------------------
86  //  Handlers for the SAX ErrorHandler interface
87  // -----------------------------------------------------------------------
88  void warning(const SAXParseException& exc);
89  void error(const SAXParseException& exc);
90  void fatalError(const SAXParseException& exc);
91 
92 
93private:
94  // -----------------------------------------------------------------------
95  //  Private data members
96  //
97  //  fAttrCount
98  //  fCharacterCount
99  //  fElementCount
100  //  fSpaceCount
101  //      These are just counters that are run upwards based on the input
102  //      from the document handlers.
103  // -----------------------------------------------------------------------
104  unsigned int    mAttrCount;
105  unsigned int    mCharacterCount;
106  unsigned int    mElementCount;
107  unsigned int    mSpaceCount;
108};
109
110// ---------------------------------------------------------------------------
111//  This is a simple class that lets us do easy (though not terribly efficient)
112//  trancoding of XMLCh data to local code page for display.
113// ---------------------------------------------------------------------------
114class StrX
115{
116public :
117  // -----------------------------------------------------------------------
118  //  Constructors and Destructor
119  // -----------------------------------------------------------------------
120  StrX(const XMLCh* const toTranscode)
121  {
122          // Call the private transcoding method
123          mLocalForm = XMLString::transcode(toTranscode);
124  }
125 
126  ~StrX()
127  {
128          XMLString::release(&mLocalForm);
129  }
130 
131  // -----------------------------------------------------------------------
132  //  Getter methods
133  // -----------------------------------------------------------------------
134  const char* LocalForm() const
135  {
136    return mLocalForm;
137  }
138 
139private :
140  // -----------------------------------------------------------------------
141  //  Private data members
142  //
143  //  fLocalForm
144  //      This is the local code page form of the string.
145  // -----------------------------------------------------------------------
146  char*   mLocalForm;
147};
148
149inline XERCES_STD_QUALIFIER ostream&
150operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
151{
152  target << toDump.LocalForm();
153  return target;
154}
155
156#endif
Note: See TracBrowser for help on using the repository browser.