#ifndef _X3D_PARSER_XERCES__H #define _X3D_PARSER_XERCES__H // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- #include #include "Mesh.h" XERCES_CPP_NAMESPACE_USE XERCES_CPP_NAMESPACE_BEGIN class AttributeList; XERCES_CPP_NAMESPACE_END class SceneGraphNode; class Mesh; class Material; class X3dParseHandlers : public HandlerBase { public: // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- X3dParseHandlers(SceneGraphNode *root); ~X3dParseHandlers(); // ----------------------------------------------------------------------- // 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(); SceneGraphNode *mCurrentNode; Mesh *mCurrentMesh; Material *mCurrentMaterial; // Handlers for X3D void StartIndexedFaceSet( AttributeList& attributes); void EndShape(); void StartCoordinate( AttributeList& attributes); void StartMaterial( AttributeList& attributes); // ----------------------------------------------------------------------- // 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; }; /** Parser handlers for view cell x3d files. */ class X3dViewCellsParseHandlers : public HandlerBase { public: // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- X3dViewCellsParseHandlers(ViewCellContainer *mViewCells); ~X3dViewCellsParseHandlers(); // ----------------------------------------------------------------------- // 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(); ViewCellContainer *mViewCells; VertexIndexContainer mCurrentVertexIndices; // Handlers for X3D void StartIndexedFaceSet( AttributeList& attributes); void EndShape(); void StartCoordinate( AttributeList& attributes); void StartMaterial( AttributeList& attributes); // ----------------------------------------------------------------------- // 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