Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkXMLParser.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkXMLParser.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00028 #ifndef __vtkXMLParser_h
00029 #define __vtkXMLParser_h
00030 
00031 #include "vtkObject.h"
00032 
00033 extern "C"
00034 {
00035   void vtkXMLParserStartElement(void*, const char*, const char**);
00036   void vtkXMLParserEndElement(void*, const char*);
00037   void vtkXMLParserCharacterDataHandler(void*, const char*, int);
00038 }
00039 
00040 class VTK_IO_EXPORT vtkXMLParser : public vtkObject
00041 {
00042 public:
00043   vtkTypeRevisionMacro(vtkXMLParser,vtkObject);
00044   void PrintSelf(ostream& os, vtkIndent indent);
00045 
00046   static vtkXMLParser* New();
00047 
00048   //BTX
00050 
00051   vtkSetMacro(Stream, istream*);
00052   vtkGetMacro(Stream, istream*);
00053   //ETX
00055 
00057 
00060   long TellG();
00061   void SeekG(long position);
00063 
00065   virtual int Parse();
00066 
00068 
00070   virtual int Parse(const char* inputString);
00071   virtual int Parse(const char* inputString, unsigned int length);
00073 
00075 
00080   virtual int InitializeParser();
00081   virtual int ParseChunk(const char* inputString, unsigned int length);
00082   virtual int CleanupParser();
00084 
00086 
00087   vtkSetStringMacro(FileName);
00088   vtkGetStringMacro(FileName);
00090 
00091 protected:
00092   vtkXMLParser();
00093   ~vtkXMLParser();
00094 
00095   // Input stream.  Set by user.
00096   istream* Stream;
00097 
00098   // File name to parse
00099   char* FileName;
00100 
00101   // This variable is true if there was a parse error while parsing in
00102   // chunks.
00103   int ParseError;
00104 
00105   // Character message to parse
00106   const char* InputString;
00107   int InputStringLength;
00108 
00109   // Expat parser structure.  Exists only during call to Parse().
00110   void* Parser;
00111 
00112   // Called by Parse() to read the stream and call ParseBuffer.  Can
00113   // be replaced by subclasses to change how input is read.
00114   virtual int ParseXML();
00115 
00116   // Called before each block of input is read from the stream to
00117   // check if parsing is complete.  Can be replaced by subclasses to
00118   // change the terminating condition for parsing.  Parsing always
00119   // stops when the end of file is reached in the stream.
00120   virtual int ParsingComplete();
00121 
00122   // Called when a new element is opened in the XML source.  Should be
00123   // replaced by subclasses to handle each element.
00124   //  name = Name of new element.
00125   //  atts = Null-terminated array of attribute name/value pairs.
00126   //         Even indices are attribute names, and odd indices are values.
00127   virtual void StartElement(const char* name, const char** atts);
00128 
00129   // Called at the end of an element in the XML source opened when
00130   // StartElement was called.
00131   virtual void EndElement(const char* name);
00132 
00133   // Called when there is character data to handle.
00134   virtual void CharacterDataHandler(const char* data, int length);
00135 
00136   // Called by begin handlers to report any stray attribute values.
00137   virtual void ReportStrayAttribute(const char* element, const char* attr,
00138                                     const char* value);
00139 
00140   // Called by begin handlers to report any missing attribute values.
00141   virtual void ReportMissingAttribute(const char* element, const char* attr);
00142 
00143   // Called by begin handlers to report bad attribute values.
00144   virtual void ReportBadAttribute(const char* element, const char* attr,
00145                                   const char* value);
00146 
00147   // Called by StartElement to report unknown element type.
00148   virtual void ReportUnknownElement(const char* element);
00149 
00150   // Called by Parse to report an XML syntax error.
00151   virtual void ReportXmlParseError();
00152 
00153   // Get the current byte index from the beginning of the XML stream.
00154   unsigned long GetXMLByteIndex();
00155 
00156   // Send the given buffer to the XML parser.
00157   virtual int ParseBuffer(const char* buffer, unsigned int count);
00158 
00159   // Send the given c-style string to the XML parser.
00160   int ParseBuffer(const char* buffer);
00161 
00162   // Utility for convenience of subclasses.  Wraps isspace C library
00163   // routine.
00164   static int IsSpace(char c);
00165 
00166   //BTX
00167   friend void vtkXMLParserStartElement(void*, const char*, const char**);
00168   friend void vtkXMLParserEndElement(void*, const char*);
00169   friend void vtkXMLParserCharacterDataHandler(void*, const char*, int);
00170   //ETX
00171 
00172 private:
00173   vtkXMLParser(const vtkXMLParser&);  // Not implemented.
00174   void operator=(const vtkXMLParser&);  // Not implemented.
00175 };
00176 
00177 #endif

Generated on Mon Jan 21 23:07:32 2008 for VTK by  doxygen 1.4.3-20050530