vtkPVXMLParser.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
10 #ifndef vtkPVXMLParser_h
11 #define vtkPVXMLParser_h
12 
13 #include "vtkPVVTKExtensionsCoreModule.h" // needed for export macro
14 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
15 #include "vtkXMLParser.h"
16 
17 class vtkPVXMLElement;
18 
20 {
21 public:
22  vtkTypeMacro(vtkPVXMLParser, vtkXMLParser);
23  void PrintSelf(ostream& os, vtkIndent indent) override;
24  static vtkPVXMLParser* New();
25 
29  void PrintXML(ostream& os);
30 
34  vtkPVXMLElement* GetRootElement();
35 
37 
43  vtkGetMacro(SuppressErrorMessages, int);
44  vtkSetMacro(SuppressErrorMessages, int);
45  vtkBooleanMacro(SuppressErrorMessages, int);
47 
53  const char* xmlcontents, bool suppress_errors = false);
54 
55 protected:
57  ~vtkPVXMLParser() override;
58 
60 
61  void StartElement(const char* name, const char** atts) override;
62  void EndElement(const char* name) override;
63  void CharacterDataHandler(const char* data, int length) override;
64 
65  void AddElement(vtkPVXMLElement* element);
66  void PushOpenElement(vtkPVXMLElement* element);
67  vtkPVXMLElement* PopOpenElement();
68 
69  // The root XML element.
71 
72  // The stack of elements currently being parsed.
74  unsigned int NumberOfOpenElements;
75  unsigned int OpenElementsSize;
76 
77  // Counter to assign unique element ids to those that don't have any.
78  unsigned int ElementIdIndex;
79 
80  // Called by Parse() to read the stream and call ParseBuffer. Can
81  // be replaced by subclasses to change how input is read.
82  int ParseXML() override;
83 
84  // Overridden to implement the SuppressErrorMessages feature.
85  void ReportXmlParseError() override;
86 
87 private:
88  vtkPVXMLParser(const vtkPVXMLParser&) = delete;
89  void operator=(const vtkPVXMLParser&) = delete;
90 };
91 
92 #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