/usr/include/vtk-5.10/vtkXMLDataElement.h is in libvtk5-dev 5.10.1+dfsg-2.1build1.
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 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkXMLDataElement.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm 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 vtkXMLDataElement - Represents an XML element and those nested inside.
// .SECTION Description
// vtkXMLDataElement is used by vtkXMLDataParser to represent an XML
// element. It provides methods to access the element's attributes
// and nested elements in a convenient manner. This allows easy
// traversal of an input XML file by vtkXMLReader and its subclasses.
// .SECTION See Also
// vtkXMLDataParser
#ifndef __vtkXMLDataElement_h
#define __vtkXMLDataElement_h
#include "vtkObject.h"
class vtkXMLDataParser;
class VTK_COMMON_EXPORT vtkXMLDataElement : public vtkObject
{
public:
vtkTypeMacro(vtkXMLDataElement,vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
static vtkXMLDataElement* New();
// Description:
// Set/Get the name of the element. This is its XML tag.
vtkGetStringMacro(Name);
virtual void SetName (const char* _arg);
// Description:
// Set/Get the value of the id attribute of the element, if any.
vtkGetStringMacro(Id);
vtkSetStringMacro(Id);
// Description:
// Get the attribute with the given name. If it doesn't exist,
// returns 0.
const char* GetAttribute(const char* name);
// Description:
// Set the attribute with the given name and value. If it doesn't exist,
// adds it.
void SetAttribute(const char* name, const char* value);
// Description:
// Set/Get the character data between XML start/end tags.
void SetCharacterData(const char* c, int length);
void AddCharacterData(const char* c, size_t length);
vtkGetStringMacro(CharacterData);
// Description:
// Get the attribute with the given name and 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);
int GetScalarAttribute(const char* name, unsigned long& value);
// Description:
// Set the attribute with the given name.
// We can not use the same GetScalarAttribute() construct since
// the compiler will not be able to resolve between
// SetAttribute(..., int) and SetAttribute(..., unsigned long).
void SetIntAttribute(const char* name, int value);
void SetFloatAttribute(const char* name, float value);
void SetDoubleAttribute(const char* name, double value);
void SetUnsignedLongAttribute(const char* name, unsigned long value);
// Description:
// Get the attribute with the given name and 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);
int GetVectorAttribute(const char* name, int length, unsigned long* value);
// Description:
// Set the attribute with the given name.
void SetVectorAttribute(const char* name, int length, const int* value);
void SetVectorAttribute(const char* name, int length, const float* value);
void SetVectorAttribute(const char* name, int length, const double* value);
void SetVectorAttribute(const char* name, int length, const unsigned long* value);
#ifdef VTK_USE_64BIT_IDS
//BTX
int GetScalarAttribute(const char* name, vtkIdType& value);
void SetIdTypeAttribute(const char* name, vtkIdType value);
int GetVectorAttribute(const char* name, int length, vtkIdType* value);
void SetVectorAttribute(const char* name, int length, const vtkIdType* value);
//ETX
#endif
// Description:
// Get the attribute with the given name and converted to a word type
// such as VTK_FLOAT or VTK_UNSIGNED_LONG.
int GetWordTypeAttribute(const char* name, int& value);
// Description:
// Get the number of attributes.
vtkGetMacro(NumberOfAttributes, int);
// Description:
// Get the n-th attribute name.
// Returns 0 if there is no such attribute.
const char* GetAttributeName(int idx);
// Description:
// Get the n-th attribute value.
// Returns 0 if there is no such attribute.
const char* GetAttributeValue(int idx);
// Description:
// Remove one or all attributes.
virtual void RemoveAttribute(const char *name);
virtual void RemoveAllAttributes();
// Description:
// Set/Get the parent of this element.
vtkXMLDataElement* GetParent();
void SetParent(vtkXMLDataElement* parent);
// Description:
// Get root of the XML tree this element is part of.
virtual vtkXMLDataElement* GetRoot();
// Description:
// Get the number of elements nested in this one.
int GetNumberOfNestedElements();
// Description:
// Get the element nested in this one at the given index.
vtkXMLDataElement* GetNestedElement(int index);
// Description:
// Add nested element
void AddNestedElement(vtkXMLDataElement* element);
// Description:
// Remove nested element.
virtual void RemoveNestedElement(vtkXMLDataElement *);
// Description:
// Remove all nested elements.
virtual void RemoveAllNestedElements();
// Description:
// Find the first nested element with the given id, given name, or given
// name and id.
// WARNING: the search is only performed on the children, not
// the grand-children.
vtkXMLDataElement* FindNestedElement(const char* id);
vtkXMLDataElement* FindNestedElementWithName(const char* name);
vtkXMLDataElement* FindNestedElementWithNameAndId(
const char* name, const char* id);
vtkXMLDataElement* FindNestedElementWithNameAndAttribute(
const char* name, const char* att_name, const char* att_value);
// Description:
// Find the first nested element with given name.
// WARNING: the search is performed on the whole XML tree.
vtkXMLDataElement* LookupElementWithName(const char* name);
// Description:
// Lookup the element with the given id, starting at this scope.
vtkXMLDataElement* LookupElement(const char* id);
// Description:
// Set/Get the offset from the beginning of the XML document to this element.
vtkGetMacro(XMLByteIndex, unsigned long);
vtkSetMacro(XMLByteIndex, unsigned long);
// Description:
// Check if the instance has the same name, attributes, character data
// and nested elements contents than the given element (this method is
// applied recursively on the nested elements, and they must be stored in
// the same order).
// Warning: Id, Parent, XMLByteIndex are ignored.
virtual int IsEqualTo(vtkXMLDataElement *elem);
// Description:
// Copy this element from another of the same type (elem), recursively.
// Old attributes and nested elements are removed, new ones are created
// given the contents of 'elem'.
// Warning: Parent is ignored.
virtual void DeepCopy(vtkXMLDataElement *elem);
// Description:
// Get/Set the internal character encoding of the attributes.
// Default type is VTK_ENCODING_UTF_8.
// Note that a vtkXMLDataParser has its own AttributesEncoding ivar. If
// this ivar is set to something other than VTK_ENCODING_NONE, it will be
// used to set the attribute encoding of each vtkXMLDataElement
// created by this vtkXMLDataParser.
vtkSetClampMacro(AttributeEncoding,int,VTK_ENCODING_NONE,VTK_ENCODING_UNKNOWN);
vtkGetMacro(AttributeEncoding, int);
// Description:
// Prints element tree as XML.
void PrintXML(ostream& os, vtkIndent indent);
void PrintXML(const char* fname);
// Description:
// Get/Set the width (in number of fields) that character
// data (that between open and closing tags ie. <X> ... </X>)
// is printed. If the width is less than one the tag's character
// data is printed all on one line. If it is greater than one
// the character data is streamed insterting line feeds every
// width number of fields. See PrintXML.
vtkGetMacro(CharacterDataWidth,int);
vtkSetMacro(CharacterDataWidth,int);
protected:
vtkXMLDataElement();
~vtkXMLDataElement();
// The name of the element from the XML file.
char* Name;
// The value of the "id" attribute, if any was given.
char* Id;
int CharacterDataWidth;
// Data inside of the tag's open and close. ie <X> character data </X>
char* CharacterData; // Null terminated buffer.
size_t CharacterDataBlockSize; // Allocation size if buffer needs expand
size_t CharacterDataBufferSize; // Allocated size.
size_t EndOfCharacterData; // Number of bytes used.
// Tags that have specialized character data handlers
// can set this flag to improve performance. The default is unset.
int IgnoreCharacterData;
// Get/Set the stream position of the elements inline data.
vtkGetMacro(InlineDataPosition,unsigned long);
vtkSetMacro(InlineDataPosition,unsigned long);
// The offset into the XML stream where the inline data begins.
unsigned long InlineDataPosition;
// The offset into the XML stream where the element begins.
unsigned long XMLByteIndex;
// The raw property name/value pairs read from the XML attributes.
char** AttributeNames;
char** AttributeValues;
int NumberOfAttributes;
int AttributesSize;
int AttributeEncoding;
// The set of nested elements.
int NumberOfNestedElements;
int NestedElementsSize;
vtkXMLDataElement** NestedElements;
// The parent of this element.
vtkXMLDataElement* Parent;
// Internal utility methods.
vtkXMLDataElement* LookupElementInScope(const char* id);
vtkXMLDataElement* LookupElementUpScope(const char* id);
static int IsSpace(char c);
void PrintCharacterData(ostream &os,vtkIndent indent);
static void PrintWithEscapedData(ostream& os, const char* data);
//BTX
friend class vtkXMLDataParser;
friend class vtkXMLMaterialParser;
//ETX
private:
vtkXMLDataElement(const vtkXMLDataElement&); // Not implemented.
void operator=(const vtkXMLDataElement&); // Not implemented.
};
//----------------------------------------------------------------------------
inline
void vtkXMLDataElement::AddCharacterData(const char* data, size_t length)
{
if (this->IgnoreCharacterData){ return; }
// This is the index where we start to put the new data at.
size_t eod=this->EndOfCharacterData-1;
// Check if the new data will write off the end. If it does
// resize the character data buffer.
this->EndOfCharacterData+=length;
if (this->EndOfCharacterData>=this->CharacterDataBufferSize)
{
while(this->EndOfCharacterData>=this->CharacterDataBufferSize)
{
this->CharacterDataBufferSize+=this->CharacterDataBlockSize;
}
this->CharacterData
= static_cast<char *>(realloc(this->CharacterData,this->CharacterDataBufferSize));
}
// put the new data at the end of the buffer, and null terminate.
char *pCD=this->CharacterData+eod;
memmove(pCD,data,length);
pCD[length]='\0';
return;
}
#endif
|