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 "vtkPVVTKExtensionsCoreModule.h" // needed for export macro
26 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
27 #include "vtkXMLParser.h"
28 
29 class vtkPVXMLElement;
30 
32 {
33 public:
34  vtkTypeMacro(vtkPVXMLParser, vtkXMLParser);
35  void PrintSelf(ostream& os, vtkIndent indent) override;
36  static vtkPVXMLParser* New();
37 
41  void PrintXML(ostream& os);
42 
46  vtkPVXMLElement* GetRootElement();
47 
49 
55  vtkGetMacro(SuppressErrorMessages, int);
56  vtkSetMacro(SuppressErrorMessages, int);
57  vtkBooleanMacro(SuppressErrorMessages, int);
59 
65  const char* xmlcontents, bool suppress_errors = false);
66 
67 protected:
69  ~vtkPVXMLParser() override;
70 
72 
73  void StartElement(const char* name, const char** atts) override;
74  void EndElement(const char* name) override;
75  void CharacterDataHandler(const char* data, int length) override;
76 
77  void AddElement(vtkPVXMLElement* element);
78  void PushOpenElement(vtkPVXMLElement* element);
79  vtkPVXMLElement* PopOpenElement();
80 
81  // The root XML element.
83 
84  // The stack of elements currently being parsed.
86  unsigned int NumberOfOpenElements;
87  unsigned int OpenElementsSize;
88 
89  // Counter to assign unique element ids to those that don't have any.
90  unsigned int ElementIdIndex;
91 
92  // Called by Parse() to read the stream and call ParseBuffer. Can
93  // be replaced by subclasses to change how input is read.
94  int ParseXML() override;
95 
96  // Overridden to implement the SuppressErrorMessages feature.
97  void ReportXmlParseError() override;
98 
99 private:
100  vtkPVXMLParser(const vtkPVXMLParser&) = delete;
101  void operator=(const vtkPVXMLParser&) = delete;
102 };
103 
104 #endif
unsigned int NumberOfOpenElements
unsigned int ElementIdIndex
#define VTKPVVTKEXTENSIONSCORE_EXPORT
virtual void StartElement(const char *name, const char **atts)
vtkPVXMLElement * RootElement
virtual int ParseXML()
virtual void CharacterDataHandler(const char *data, int length)
void PrintSelf(ostream &os, vtkIndent indent)
virtual void EndElement(const char *name)
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
static vtkXMLParser * New()
virtual void ReportXmlParseError()
void operator=(const vtkObjectBase &)
unsigned int OpenElementsSize