source: GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParserXerces.h @ 2176

Revision 2176, 4.7 KB checked in by mattausch, 17 years ago (diff)

removed using namespace std from .h

Line 
1#ifndef _OBJECTS_PARSER_XERCES__H
2#define _OBJECTS_PARSER_XERCES__H
3
4// ---------------------------------------------------------------------------
5//  Includes
6// ---------------------------------------------------------------------------
7#include <xercesc/sax/HandlerBase.hpp>
8#include "Mesh.h"
9#include "BoundingBoxConverter.h"
10
11
12namespace GtpVisibilityPreprocessor {
13
14XERCES_CPP_NAMESPACE_USE
15XERCES_CPP_NAMESPACE_BEGIN
16class AttributeList;
17XERCES_CPP_NAMESPACE_END
18
19
20class BvhNode;
21class BvHierarchy;
22
23
24class ObjectsParseHandlers: public HandlerBase
25{
26public:
27
28        friend class BvHierarchy;
29
30        // -----------------------------------------------------------------------
31        //  Constructors and Destructor
32        // -----------------------------------------------------------------------
33
34        ObjectsParseHandlers(ObjectContainer &pvsObjects,
35                                                 const ObjectContainer &preprocessorObjects);
36
37        ~ObjectsParseHandlers();
38
39
40        // -----------------------------------------------------------------------
41        //  Getter methods
42        // -----------------------------------------------------------------------
43
44        unsigned int GetElementCount()
45        {
46                return mElementCount;
47        }
48
49        unsigned int GetAttrCount()
50        {
51                return mAttrCount;
52        }
53
54        unsigned int GetCharacterCount()
55        {
56                return mCharacterCount;
57        }
58
59        unsigned int GetSpaceCount()
60        {
61                return mSpaceCount;
62        }
63
64
65        // -----------------------------------------------------------------------
66        //  Handlers for the SAX DocumentHandler interface
67        // -----------------------------------------------------------------------
68
69        void endElement(const XMLCh* const name);
70        void startElement(const XMLCh* const name, AttributeList& attributes);
71        void characters(const XMLCh* const chars, const unsigned int length);
72        void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
73        void resetDocument();
74
75        void StartObjectSpaceHierarchyElement(const std::string &element,
76                                                                                  AttributeList& attributes);
77
78        /////////////////////////
79
80        int mUniqueObjectId;
81
82        vector<BvhLeaf *> mBvhLeaves;
83
84        const ObjectContainer &mPreprocessorObjects;
85        ObjectContainer &mPvsObjects;
86
87        /// current state of the parser
88        bool mIsObjectSpaceHierarchy;
89
90        enum {BVH};
91
92        ////////////
93        //-- Handlers for X3D
94
95        void StartBvhLeaf(AttributeList& attributes);
96        void StartBvhElement(std::string element, AttributeList& attributes);
97
98        void EndObjectSpaceHierarchy();
99
100        void StartBvhLeafObjects(ObjectContainer &objects, const char *ptr);
101
102        // -----------------------------------------------------------------------
103        //  Handlers for the SAX ErrorHandler interface
104        // -----------------------------------------------------------------------
105
106        void warning(const SAXParseException& exc);
107        void error(const SAXParseException& exc);
108        void fatalError(const SAXParseException& exc);
109
110
111private:
112        // -----------------------------------------------------------------------
113        //  Private data members
114        //
115        //  fAttrCount
116        //  fCharacterCount
117        //  fElementCount
118        //  fSpaceCount
119        //      These are just counters that are run upwards based on the input
120        //      from the document handlers.
121        // -----------------------------------------------------------------------
122        unsigned int    mAttrCount;
123        unsigned int    mCharacterCount;
124        unsigned int    mElementCount;
125        unsigned int    mSpaceCount;
126};
127
128// ---------------------------------------------------------------------------
129//  This is a simple class that lets us do easy (though not terribly efficient)
130//  trancoding of XMLCh data to local code page for display.
131// ---------------------------------------------------------------------------
132class StrX
133{
134public :
135        // -----------------------------------------------------------------------
136        //  Constructors and Destructor
137        // -----------------------------------------------------------------------
138        StrX(const XMLCh* const toTranscode)
139        {
140                // Call the private transcoding method
141                mLocalForm = XMLString::transcode(toTranscode);
142        }
143
144        ~StrX()
145        {
146                XMLString::release(&mLocalForm);
147        }
148
149        // -----------------------------------------------------------------------
150        //  Getter methods
151        // -----------------------------------------------------------------------
152        const char* LocalForm() const
153        {
154                return mLocalForm;
155        }
156
157private :
158        // -----------------------------------------------------------------------
159        //  Private data members
160        //
161        //  fLocalForm
162        //      This is the local code page form of the string.
163        // -----------------------------------------------------------------------
164        char*   mLocalForm;
165};
166
167inline XERCES_STD_QUALIFIER ostream&
168operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
169{
170        target << toDump.LocalForm();
171        return target;
172}
173}
174
175#endif
Note: See TracBrowser for help on using the repository browser.