ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
vtkPVXMLElement.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <string> // for std::string
11 
12 #include "qPCL.h" // needed for export macro
13 #include "vtkObject.h"
14 
15 class vtkCollection;
16 class vtkPVXMLParser;
17 
18 struct vtkPVXMLElementInternals;
19 
20 class QPCL_ENGINE_LIB_API vtkPVXMLElement : public vtkObject {
21 public:
23  void PrintSelf(ostream& os, vtkIndent indent) override;
24  static vtkPVXMLElement* New();
25 
27 
34 
36 
42 
47  const char* GetAttribute(const char* name) {
48  return this->GetAttributeOrDefault(name, NULL);
49  }
50 
55  const char* GetAttributeOrEmpty(const char* name) {
56  return this->GetAttributeOrDefault(name, "");
57  }
58 
63  const char* GetAttributeOrDefault(const char* name, const char* notFound);
64 
68  const char* GetCharacterData();
69 
71 
75  int GetScalarAttribute(const char* name, int* value);
76  int GetScalarAttribute(const char* name, float* value);
77  int GetScalarAttribute(const char* name, double* value);
78 #if defined(VTK_USE_64BIT_IDS)
79  int GetScalarAttribute(const char* name, vtkIdType* value);
80 #endif
82 
84 
88  int GetVectorAttribute(const char* name, int length, int* value);
89  int GetVectorAttribute(const char* name, int length, float* value);
90  int GetVectorAttribute(const char* name, int length, double* value);
91 #if defined(VTK_USE_64BIT_IDS)
92  int GetVectorAttribute(const char* name, int length, vtkIdType* value);
93 #endif
95 
97 
101  int GetCharacterDataAsVector(int length, int* value);
102  int GetCharacterDataAsVector(int length, float* value);
103  int GetCharacterDataAsVector(int length, double* value);
104 #if defined(VTK_USE_64BIT_IDS)
105  int GetCharacterDataAsVector(int length, vtkIdType* value);
106 #endif
108 
112  vtkPVXMLElement* GetParent();
113 
117  unsigned int GetNumberOfNestedElements();
118 
122  vtkPVXMLElement* GetNestedElement(unsigned int index);
123 
129  vtkPVXMLElement* FindNestedElement(const char* id);
130 
134  vtkPVXMLElement* FindNestedElementByName(const char* name);
135 
139  void FindNestedElementByName(const char* name, vtkCollection* elements);
140 
144  void RemoveAllNestedElements();
145 
149  void RemoveNestedElement(vtkPVXMLElement*);
150 
154  void ReplaceNestedElement(vtkPVXMLElement* elementToReplace,
155  vtkPVXMLElement* element);
156 
160  vtkPVXMLElement* LookupElement(const char* id);
161 
163 
166  void AddAttribute(const char* attrName, const char* attrValue);
167  void AddAttribute(const char* attrName, unsigned int attrValue);
168  void AddAttribute(const char* attrName, double attrValue);
169  void AddAttribute(const char* attrName, double attrValue, int precision);
170  void AddAttribute(const char* attrName, int attrValue);
171 #if defined(VTK_USE_64BIT_IDS)
172  void AddAttribute(const char* attrName, vtkIdType attrValue);
173 #endif
175 
179  void RemoveAttribute(const char* attrName);
180 
188  void SetAttribute(const char* attrName, const char* attrValue);
189 
191 
196  void AddNestedElement(vtkPVXMLElement* element, int setPrent);
197  void AddNestedElement(vtkPVXMLElement* element);
199 
201 
204  void PrintXML(ostream& os, vtkIndent indent);
205  void PrintXML();
207 
216  void Merge(vtkPVXMLElement* element, const char* attributeName);
217 
219 
226  void GetElementsByName(const char* name, vtkCollection* elements);
227  void GetElementsByName(const char* name,
228  vtkCollection* elements,
229  bool recursively);
231 
235  static std::string Encode(const char* plaintext);
236 
242  bool Equals(vtkPVXMLElement* other);
243 
247  void CopyTo(vtkPVXMLElement* other);
248 
253  void CopyAttributesTo(vtkPVXMLElement* other);
254 
255 protected:
256  vtkPVXMLElement();
257  ~vtkPVXMLElement() override;
258 
259  vtkPVXMLElementInternals* Internal;
260 
261  char* Name;
262  char* Id;
263 
264  // The parent of this element.
266 
267  // Method used by vtkPVXMLParser to setup the element.
269  void ReadXMLAttributes(const char** atts);
270  void AddCharacterData(const char* data, int length);
271 
272  // Internal utility methods.
273  vtkPVXMLElement* LookupElementInScope(const char* id);
274  vtkPVXMLElement* LookupElementUpScope(const char* id);
275  void SetParent(vtkPVXMLElement* parent);
276 
277  friend class vtkPVXMLParser;
278 
279 private:
280  vtkPVXMLElement(const vtkPVXMLElement&) = delete;
281  void operator=(const vtkPVXMLElement&) = delete;
282 };
std::string name
#define NULL
vtkGetStringMacro(Name)
vtkTypeMacro(vtkPVXMLElement, vtkObject)
const char * GetAttributeOrEmpty(const char *name)
static vtkPVXMLElement * New()
vtkPVXMLElement * Parent
const char * GetAttribute(const char *name)
vtkSetStringMacro(Name)
GraphType data
Definition: graph_cut.cc:138
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15