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:
22  vtkTypeMacro(vtkPVXMLElement, vtkObject);
23  void PrintSelf(ostream& os, vtkIndent indent) override;
24  static vtkPVXMLElement* New();
25 
27 
31  vtkSetStringMacro(Name);
32  vtkGetStringMacro(Name);
34 
36 
40  vtkGetStringMacro(Id);
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
81 
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
94 
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
107 
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
174 
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.
268  vtkSetStringMacro(Id);
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 };
vtkPVXMLParser
Definition: vtkPVXMLParser.h:16
vtkIsSpace
static bool vtkIsSpace(const std::string &str)
Definition: vtkPVXMLElement.cxx:43
vtkPVXMLElement::Id
char * Id
Definition: vtkPVXMLElement.h:262
QtCompat::endl
QTextStream & endl(QTextStream &stream)
Definition: QtCompat.h:718
vtkPVXMLElement::RemoveNestedElement
void RemoveNestedElement(vtkPVXMLElement *)
Definition: vtkPVXMLElement.cxx:205
vtkPVXMLElement::AddAttribute
void AddAttribute(const char *attrName, const char *attrValue)
Definition: vtkPVXMLElement.cxx:140
vtkPVXMLElement::GetParent
vtkPVXMLElement * GetParent()
Definition: vtkPVXMLElement.cxx:337
vtkPVXMLElement::vtkPVXMLElement
vtkPVXMLElement()
Definition: vtkPVXMLElement.cxx:56
vtkPVXMLElement::ReadXMLAttributes
void ReadXMLAttributes(const char **atts)
Definition: vtkPVXMLElement.cxx:175
NULL
#define NULL
Definition: UVUnwrapping.cpp:40
vtkPVXMLElement::AddCharacterData
void AddCharacterData(const char *data, int length)
Definition: vtkPVXMLElement.cxx:250
vtkPVXMLElement::LookupElementInScope
vtkPVXMLElement * LookupElementInScope(const char *id)
Definition: vtkPVXMLElement.cxx:404
data
GraphType data
Definition: graph_cut.cc:138
vtkPVXMLElement::FindNestedElement
vtkPVXMLElement * FindNestedElement(const char *id)
Definition: vtkPVXMLElement.cxx:365
vtkPVXMLElement::AddNestedElement
void AddNestedElement(vtkPVXMLElement *element, int setPrent)
Definition: vtkPVXMLElement.cxx:240
vtkPVXMLElement.h
vtkPVXMLElement::SetAttribute
void SetAttribute(const char *attrName, const char *attrValue)
Definition: vtkPVXMLElement.cxx:152
vtkSmartPointer
Definition: WidgetMap.h:20
vtkPVXMLElement::GetScalarAttribute
int GetScalarAttribute(const char *name, int *value)
Definition: vtkPVXMLElement.cxx:457
qPCL.h
vtkPVXMLElement::CopyTo
void CopyTo(vtkPVXMLElement *other)
Definition: vtkPVXMLElement.cxx:721
vtkPVXMLElement::GetNestedElement
vtkPVXMLElement * GetNestedElement(unsigned int index)
Definition: vtkPVXMLElement.cxx:349
vtkPVXMLVectorAttributeParse
int vtkPVXMLVectorAttributeParse(const char *str, int length, T *data)
Definition: vtkPVXMLElement.cxx:484
vtkPVXMLElement::GetAttributeOrEmpty
const char * GetAttributeOrEmpty(const char *name)
Definition: vtkPVXMLElement.h:55
vtkPVXMLElement::FindNestedElementByName
vtkPVXMLElement * FindNestedElementByName(const char *name)
Definition: vtkPVXMLElement.cxx:381
SNPRINTF
#define SNPRINTF
Definition: vtkPVXMLElement.cxx:30
vtkPVXMLElement::CopyAttributesTo
void CopyAttributesTo(vtkPVXMLElement *other)
Definition: vtkPVXMLElement.cxx:742
vtkPVXMLElement::GetVectorAttribute
int GetVectorAttribute(const char *name, int length, int *value)
Definition: vtkPVXMLElement.cxx:505
vtkStandardNewMacro
vtkStandardNewMacro(vtkPVXMLElement)
next
math::float4 next
Definition: LineSetBuffers.cpp:45
vtkPVXMLElement::Name
char * Name
Definition: vtkPVXMLElement.h:261
vtkPVXMLElement::GetElementsByName
void GetElementsByName(const char *name, vtkCollection *elements)
Definition: vtkPVXMLElement.cxx:549
vtkPVXMLElement::LookupElement
vtkPVXMLElement * LookupElement(const char *id)
Definition: vtkPVXMLElement.cxx:359
vtkPVXMLElement::LookupElementUpScope
vtkPVXMLElement * LookupElementUpScope(const char *id)
Definition: vtkPVXMLElement.cxx:428
vtkPVXMLElement::GetNumberOfNestedElements
unsigned int GetNumberOfNestedElements()
Definition: vtkPVXMLElement.cxx:343
vtkPVXMLElement::GetCharacterDataAsVector
int GetCharacterDataAsVector(int length, int *value)
Definition: vtkPVXMLElement.cxx:531
vtkPVXMLElement::SetParent
void SetParent(vtkPVXMLElement *parent)
Definition: vtkPVXMLElement.cxx:331
vtkPVXMLElement::Equals
bool Equals(vtkPVXMLElement *other)
Definition: vtkPVXMLElement.cxx:753
vtkPVXMLElement
Definition: vtkPVXMLElement.h:20
count
int count
Definition: FileIOFactory.cpp:132
QPCL_ENGINE_LIB_API
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15
vtkPVXMLElement::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Definition: vtkPVXMLElement.cxx:75
vtkPVXMLElement::~vtkPVXMLElement
~vtkPVXMLElement() override
Definition: vtkPVXMLElement.cxx:66
vtkPVXMLElement::ReplaceNestedElement
void ReplaceNestedElement(vtkPVXMLElement *elementToReplace, vtkPVXMLElement *element)
Definition: vtkPVXMLElement.cxx:220
vtkPVXMLElement::Encode
static std::string Encode(const char *plaintext)
Definition: vtkPVXMLElement.cxx:593
vtkPVXMLElement::PrintXML
void PrintXML(ostream &os, vtkIndent indent)
Definition: vtkPVXMLElement.cxx:282
vtkPVXMLElement::Parent
vtkPVXMLElement * Parent
Definition: vtkPVXMLElement.h:265
vtkPVXMLElement::GetCharacterData
const char * GetCharacterData()
Definition: vtkPVXMLElement.cxx:270
vtkPVXMLElement::GetAttributeOrDefault
const char * GetAttributeOrDefault(const char *name, const char *notFound)
Definition: vtkPVXMLElement.cxx:256
vtkPVXMLElement::GetAttribute
const char * GetAttribute(const char *name)
Definition: vtkPVXMLElement.h:47
vtkPVXMLElement::Merge
void Merge(vtkPVXMLElement *element, const char *attributeName)
Definition: vtkPVXMLElement.cxx:640
vtkPVXMLElement::RemoveAllNestedElements
void RemoveAllNestedElements()
Definition: vtkPVXMLElement.cxx:199
vtkPVXMLElement::RemoveAttribute
void RemoveAttribute(const char *attrName)
Definition: vtkPVXMLElement.cxx:771
name
std::string name
Definition: FileIOFactory.cpp:129
vtkPVXMLElement::PrintXML
void PrintXML()
Definition: vtkPVXMLElement.cxx:276