00001 //============================================================================= 00002 // This file is part of VTKEdge. See vtkedge.org for more information. 00003 // 00004 // Copyright (c) 2010 Kitware, Inc. 00005 // 00006 // VTKEdge may be used under the terms of the BSD License 00007 // Please see the file Copyright.txt in the root directory of 00008 // VTKEdge for further information. 00009 // 00010 // Alternatively, you may see: 00011 // 00012 // http://www.vtkedge.org/vtkedge/project/license.html 00013 // 00014 // 00015 // For custom extensions, consulting services, or training for 00016 // this or any other Kitware supported open source project, please 00017 // contact Kitware at sales@kitware.com. 00018 // 00019 // 00020 //============================================================================= 00027 #ifndef __vtkKWEXMLParser_h 00028 #define __vtkKWEXMLParser_h 00029 00030 #include "vtkXMLParser.h" 00031 #include "VTKEdgeConfigure.h" // include configuration header 00032 00033 class vtkKWEXMLElement; 00034 00035 class VTKEdge_IO_EXPORT vtkKWEXMLParser : public vtkXMLParser 00036 { 00037 public: 00038 vtkTypeRevisionMacro(vtkKWEXMLParser,vtkXMLParser); 00039 void PrintSelf(ostream& os, vtkIndent indent); 00040 static vtkKWEXMLParser* New(); 00041 00043 void PrintXML(ostream& os); 00044 00046 vtkKWEXMLElement* GetRootElement(); 00047 00049 00050 vtkSetStringMacro(FileName); 00051 vtkGetStringMacro(FileName); 00053 00054 protected: 00055 vtkKWEXMLParser(); 00056 ~vtkKWEXMLParser(); 00057 00058 void StartElement(const char* name, const char** atts); 00059 void EndElement(const char* name); 00060 void CharacterDataHandler(const char* data, int length); 00061 00062 void AddElement(vtkKWEXMLElement* element); 00063 void PushOpenElement(vtkKWEXMLElement* element); 00064 vtkKWEXMLElement* PopOpenElement(); 00065 00066 // The root XML element. 00067 vtkKWEXMLElement* RootElement; 00068 00069 // The stack of elements currently being parsed. 00070 vtkKWEXMLElement** OpenElements; 00071 unsigned int NumberOfOpenElements; 00072 unsigned int OpenElementsSize; 00073 00074 // Counter to assign unique element ids to those that don't have any. 00075 unsigned int ElementIdIndex; 00076 00077 // Called by Parse() to read the stream and call ParseBuffer. Can 00078 // be replaced by subclasses to change how input is read. 00079 virtual int ParseXML(); 00080 00081 private: 00082 vtkKWEXMLParser(const vtkKWEXMLParser&); // Not implemented. 00083 void operator=(const vtkKWEXMLParser&); // Not implemented. 00084 }; 00085 00086 #endif
1.7.1