/usr/include/paraview/vtkPVXMLElement.h is in paraview-dev 5.0.1+dfsg1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | /*=========================================================================
Program: ParaView
Module: vtkPVXMLElement.h
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPVXMLElement represents an XML element and those nested inside.
// .SECTION Description
// This is used by vtkPVXMLParser to represent an XML document starting
// at the root element.
#ifndef vtkPVXMLElement_h
#define vtkPVXMLElement_h
#include "vtkObject.h"
#include "vtkStdString.h" // needed for vtkStdString.
#include "vtkPVCommonModule.h" // needed for export macro
class vtkCollection;
class vtkPVXMLParser;
//BTX
struct vtkPVXMLElementInternals;
//ETX
class VTKPVCOMMON_EXPORT vtkPVXMLElement : public vtkObject
{
public:
vtkTypeMacro(vtkPVXMLElement,vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
static vtkPVXMLElement* New();
// Description:
// Set/Get the name of the element. This is its XML tag.
// (<Name />).
vtkSetStringMacro(Name);
vtkGetStringMacro(Name);
// Description:
// Get the id of the element. This is assigned by the XML parser
// and can be used as an identifier to an element.
vtkGetStringMacro(Id);
// Description:
// Get the attribute with the given name. If it doesn't exist,
// returns NULL.
const char* GetAttribute(const char* name)
{ return this->GetAttributeOrDefault(name, NULL); }
// Description:
// Get the attribute with the given name. If it doesn't exist,
// returns "".
const char* GetAttributeOrEmpty(const char* name)
{ return this->GetAttributeOrDefault(name, ""); }
// Description:
// Get the attribute with the given name.
// If it doesn't exist, returns the provided notFound value.
const char* GetAttributeOrDefault(const char* name, const char* notFound);
// Description:
// Get the character data for the element.
const char* GetCharacterData();
// Description:
// Get the attribute with the given name converted to a scalar
// value. Returns whether value was extracted.
int GetScalarAttribute(const char* name, int* value);
int GetScalarAttribute(const char* name, float* value);
int GetScalarAttribute(const char* name, double* value);
#if defined(VTK_USE_64BIT_IDS)
int GetScalarAttribute(const char* name, vtkIdType* value);
#endif
// Description:
// Get the attribute with the given name converted to a scalar
// value. Returns length of vector read.
int GetVectorAttribute(const char* name, int length, int* value);
int GetVectorAttribute(const char* name, int length, float* value);
int GetVectorAttribute(const char* name, int length, double* value);
#if defined(VTK_USE_64BIT_IDS)
int GetVectorAttribute(const char* name, int length, vtkIdType* value);
#endif
// Description:
// Get the character data converted to a scalar
// value. Returns length of vector read.
int GetCharacterDataAsVector(int length, int* value);
int GetCharacterDataAsVector(int length, float* value);
int GetCharacterDataAsVector(int length, double* value);
#if defined(VTK_USE_64BIT_IDS)
int GetCharacterDataAsVector(int length, vtkIdType* value);
#endif
// Description:
// Get the parent of this element.
vtkPVXMLElement* GetParent();
// Description:
// Get the number of elements nested in this one.
unsigned int GetNumberOfNestedElements();
// Description:
// Get the element nested in this one at the given index.
vtkPVXMLElement* GetNestedElement(unsigned int index);
// Description:
// Find a nested element with the given id.
// Not that this searches only the immediate children of this
// vtkPVXMLElement.
vtkPVXMLElement* FindNestedElement(const char* id);
// Description:
// Locate a nested element with the given tag name.
vtkPVXMLElement* FindNestedElementByName(const char* name);
// Description:
// Locate a set of nested elements with the given tag name.
void FindNestedElementByName(const char* name, vtkCollection* elements);
// Description:
// Removes all nested elements.
void RemoveAllNestedElements();
// Description:
// Remove a particular element.
void RemoveNestedElement(vtkPVXMLElement*);
// Description:
// Lookup the element with the given id, starting at this scope.
vtkPVXMLElement* LookupElement(const char* id);
// Description:
// Given it's name and value, add an attribute.
void AddAttribute(const char* attrName, const char* attrValue);
void AddAttribute(const char* attrName, unsigned int attrValue);
void AddAttribute(const char* attrName, double attrValue);
void AddAttribute(const char* attrName, double attrValue, int precision);
void AddAttribute(const char* attrName, int attrValue);
#if defined(VTK_USE_64BIT_IDS)
void AddAttribute(const char* attrName, vtkIdType attrValue);
#endif
// Description:
// Remove the attribute from the current element
void RemoveAttribute(const char* attrName);
// Description:
// Given it's name and value, set an attribute.
// If an attribute with the given name already exists,
// it replaces the old attribute.
// chars that need to be XML escaped will be done so internally
// for example " will be converted to "
void SetAttribute(const char* attrName, const char* attrValue);
// Description:
// Add a sub-element. The parent element keeps a reference to
// sub-element. If setParent is true, the nested element's parent
// is set as this.
void AddNestedElement(vtkPVXMLElement* element, int setPrent);
void AddNestedElement(vtkPVXMLElement* element);
// Description:
// Serialize (as XML) in the given stream.
void PrintXML(ostream& os, vtkIndent indent);
void PrintXML();
// Description:
// Merges another element with this one, both having the same name.
// If any attribute, character data or nested element exists in both,
// the passed in one will override this one's. If they don't exist,
// they'll be added. If nested elements have the same names, the
// optional attributeName maybe passed in as another criteria to determine
// what to merge in case of same names.
void Merge(vtkPVXMLElement* element, const char* attributeName);
// Description:
// Similar to DOM sepecific getElementsByTagName().
// Returns a list of vtkPVXMLElements with the given name in the order
// in which they will be encountered in a preorder traversal
// of the sub-tree under this node. The elements are populated
// in the vtkCollection passed as an argument.
void GetElementsByName(const char* name, vtkCollection* elements);
void GetElementsByName(const char* name, vtkCollection* elements,
bool recursively);
// Description:
// Encode a string.
static vtkStdString Encode(const char* plaintext);
// Description:
// Return true if the current object has the same content as the other.
// The comparison implementation is pretty weak in the mean that
// we compare resulting XML string.
bool Equals(vtkPVXMLElement* other);
// Description:
// Copy the current XML element content into the provided one
void CopyTo(vtkPVXMLElement* other);
// Description:
// Copy the attributes from current XML element content into the provided one.
void CopyAttributesTo(vtkPVXMLElement* other);
protected:
vtkPVXMLElement();
~vtkPVXMLElement();
vtkPVXMLElementInternals* Internal;
char* Name;
char* Id;
// The parent of this element.
vtkPVXMLElement* Parent;
// Method used by vtkPVXMLParser to setup the element.
vtkSetStringMacro(Id);
void ReadXMLAttributes(const char** atts);
void AddCharacterData(const char* data, int length);
// Internal utility methods.
vtkPVXMLElement* LookupElementInScope(const char* id);
vtkPVXMLElement* LookupElementUpScope(const char* id);
void SetParent(vtkPVXMLElement* parent);
//BTX
friend class vtkPVXMLParser;
//ETX
private:
vtkPVXMLElement(const vtkPVXMLElement&); // Not implemented.
void operator=(const vtkPVXMLElement&); // Not implemented.
};
#endif
|