ParaView
vtkPVXMLParser.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkPVXMLParser.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
22 #ifndef vtkPVXMLParser_h
23 #define vtkPVXMLParser_h
24 
25 #include "vtkPVCommonModule.h" // needed for export macro
26 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
27 #include "vtkXMLParser.h"
28 
29 class vtkPVXMLElement;
30 
31 class VTKPVCOMMON_EXPORT vtkPVXMLParser : public vtkXMLParser
32 {
33 public:
34  vtkTypeMacro(vtkPVXMLParser, vtkXMLParser);
35  void PrintSelf(ostream& os, vtkIndent indent);
36  static vtkPVXMLParser* New();
37 
41  void PrintXML(ostream& os);
42 
46  vtkPVXMLElement* GetRootElement();
47 
49 
52  vtkSetStringMacro(FileName);
53  vtkGetStringMacro(FileName);
55 
57 
63  vtkGetMacro(SuppressErrorMessages, int);
64  vtkSetMacro(SuppressErrorMessages, int);
65  vtkBooleanMacro(SuppressErrorMessages, int);
67 
72  static vtkSmartPointer<vtkPVXMLElement> ParseXML(
73  const char* xmlcontents, bool suppress_errors = false);
74 
75 protected:
77  ~vtkPVXMLParser();
78 
80 
81  void StartElement(const char* name, const char** atts);
82  void EndElement(const char* name);
83  void CharacterDataHandler(const char* data, int length);
84 
85  void AddElement(vtkPVXMLElement* element);
86  void PushOpenElement(vtkPVXMLElement* element);
87  vtkPVXMLElement* PopOpenElement();
88 
89  // The root XML element.
91 
92  // The stack of elements currently being parsed.
94  unsigned int NumberOfOpenElements;
95  unsigned int OpenElementsSize;
96 
97  // Counter to assign unique element ids to those that don't have any.
98  unsigned int ElementIdIndex;
99 
100  // Called by Parse() to read the stream and call ParseBuffer. Can
101  // be replaced by subclasses to change how input is read.
102  virtual int ParseXML();
103 
104  // Overridden to implement the SuppressErrorMessages feature.
105  virtual void ReportXmlParseError();
106 
107 private:
108  vtkPVXMLParser(const vtkPVXMLParser&) VTK_DELETE_FUNCTION;
109  void operator=(const vtkPVXMLParser&) VTK_DELETE_FUNCTION;
110 };
111 
112 #endif
unsigned int NumberOfOpenElements
unsigned int ElementIdIndex
vtkPVXMLElement * RootElement
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
This is a subclass of vtkXMLParser that constructs a representation of parsed XML using vtkPVXMLEleme...
vtkPVXMLElement ** OpenElements
unsigned int OpenElementsSize