#ifndef _OBJECTS_PARSER_XERCES__H #define _OBJECTS_PARSER_XERCES__H // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- #include #include "Mesh.h" #include "BoundingBoxConverter.h" namespace GtpVisibilityPreprocessor { XERCES_CPP_NAMESPACE_USE XERCES_CPP_NAMESPACE_BEGIN class AttributeList; XERCES_CPP_NAMESPACE_END class BvhNode; class BvHierarchy; class ObjectsParseHandlers: public HandlerBase { public: friend class BvHierarchy; // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- ObjectsParseHandlers(ObjectContainer &pvsObjects, const ObjectContainer &preprocessorObjects); ~ObjectsParseHandlers(); // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- unsigned int GetElementCount() { return mElementCount; } unsigned int GetAttrCount() { return mAttrCount; } unsigned int GetCharacterCount() { return mCharacterCount; } unsigned int GetSpaceCount() { return mSpaceCount; } // ----------------------------------------------------------------------- // Handlers for the SAX DocumentHandler interface // ----------------------------------------------------------------------- void endElement(const XMLCh* const name); void startElement(const XMLCh* const name, AttributeList& attributes); void characters(const XMLCh* const chars, const unsigned int length); void ignorableWhitespace(const XMLCh* const chars, const unsigned int length); void resetDocument(); void StartObjectSpaceHierarchyElement(const std::string &element, AttributeList& attributes); ///////////////////////// int mUniqueObjectId; vector mBvhLeaves; const ObjectContainer &mPreprocessorObjects; ObjectContainer &mPvsObjects; /// current state of the parser bool mIsObjectSpaceHierarchy; enum {BVH}; //////////// //-- Handlers for X3D void StartBvhLeaf(AttributeList& attributes); void StartBvhElement(std::string element, AttributeList& attributes); void EndObjectSpaceHierarchy(); void StartBvhLeafObjects(ObjectContainer &objects, const char *ptr); // ----------------------------------------------------------------------- // Handlers for the SAX ErrorHandler interface // ----------------------------------------------------------------------- void warning(const SAXParseException& exc); void error(const SAXParseException& exc); void fatalError(const SAXParseException& exc); private: // ----------------------------------------------------------------------- // Private data members // // fAttrCount // fCharacterCount // fElementCount // fSpaceCount // These are just counters that are run upwards based on the input // from the document handlers. // ----------------------------------------------------------------------- unsigned int mAttrCount; unsigned int mCharacterCount; unsigned int mElementCount; unsigned int mSpaceCount; }; // --------------------------------------------------------------------------- // This is a simple class that lets us do easy (though not terribly efficient) // trancoding of XMLCh data to local code page for display. // --------------------------------------------------------------------------- class StrX { public : // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- StrX(const XMLCh* const toTranscode) { // Call the private transcoding method mLocalForm = XMLString::transcode(toTranscode); } ~StrX() { XMLString::release(&mLocalForm); } // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- const char* LocalForm() const { return mLocalForm; } private : // ----------------------------------------------------------------------- // Private data members // // fLocalForm // This is the local code page form of the string. // ----------------------------------------------------------------------- char* mLocalForm; }; inline XERCES_STD_QUALIFIER ostream& operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump) { target << toDump.LocalForm(); return target; } } #endif