IO/vtkXMLDataElement.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00042 #ifndef __vtkXMLDataElement_h
00043 #define __vtkXMLDataElement_h
00044
00045 #include "vtkObject.h"
00046
00047 class vtkXMLDataParser;
00048
00049 class VTK_IO_EXPORT vtkXMLDataElement : public vtkObject
00050 {
00051 public:
00052 vtkTypeRevisionMacro(vtkXMLDataElement,vtkObject);
00053 void PrintSelf(ostream& os, vtkIndent indent);
00054 static vtkXMLDataElement* New();
00055
00057
00058 vtkGetStringMacro(Name);
00059 vtkSetStringMacro(Name);
00061
00063
00064 vtkGetStringMacro(Id);
00065 vtkSetStringMacro(Id);
00067
00070 const char* GetAttribute(const char* name);
00071
00074 void SetAttribute(const char* name, const char* value);
00075
00077
00079 int GetScalarAttribute(const char* name, int& value);
00080 int GetScalarAttribute(const char* name, float& value);
00081 int GetScalarAttribute(const char* name, double& value);
00082 int GetScalarAttribute(const char* name, unsigned long& value);
00084
00086
00090 void SetIntAttribute(const char* name, int value);
00091 void SetFloatAttribute(const char* name, float value);
00092 void SetDoubleAttribute(const char* name, double value);
00093 void SetUnsignedLongAttribute(const char* name, unsigned long value);
00095
00097
00099 int GetVectorAttribute(const char* name, int length, int* value);
00100 int GetVectorAttribute(const char* name, int length, float* value);
00101 int GetVectorAttribute(const char* name, int length, double* value);
00102 int GetVectorAttribute(const char* name, int length, unsigned long* value);
00104
00106
00107 void SetVectorAttribute(const char* name, int length, const int* value);
00108 void SetVectorAttribute(const char* name, int length, const float* value);
00109 void SetVectorAttribute(const char* name, int length, const double* value);
00110 void SetVectorAttribute(const char* name, int length, const unsigned long* value);
00112
00113 #ifdef VTK_ID_TYPE_IS_NOT_BASIC_TYPE
00114
00115 int GetScalarAttribute(const char* name, vtkIdType& value);
00116 void SetIdTypeAttribute(const char* name, vtkIdType value);
00117 int GetVectorAttribute(const char* name, int length, vtkIdType* value);
00118 void SetVectorAttribute(const char* name, int length, const vtkIdType* value);
00119
00120 #endif
00121
00124 int GetWordTypeAttribute(const char* name, int& value);
00125
00127
00128 vtkGetMacro(NumberOfAttributes, int);
00130
00132 const char* GetAttributeName(int idx);
00133
00135
00136 vtkXMLDataElement* GetParent();
00137 void SetParent(vtkXMLDataElement* parent);
00139
00141 int GetNumberOfNestedElements();
00142
00144 vtkXMLDataElement* GetNestedElement(int index);
00145
00147 void AddNestedElement(vtkXMLDataElement* element);
00148
00150
00152 vtkXMLDataElement* FindNestedElement(const char* id);
00153 vtkXMLDataElement* FindNestedElementWithName(const char* name);
00154 vtkXMLDataElement* FindNestedElementWithNameAndId(
00155 const char* name, const char* id);
00156 vtkXMLDataElement* FindNestedElementWithNameAndAttribute(
00157 const char* name, const char* att_name, const char* att_value);
00159
00161 vtkXMLDataElement* LookupElement(const char* id);
00162
00164
00166 vtkGetMacro(XMLByteIndex, unsigned long);
00167 vtkSetMacro(XMLByteIndex, unsigned long);
00169
00170 protected:
00171 vtkXMLDataElement();
00172 ~vtkXMLDataElement();
00173
00174
00175 char* Name;
00176
00177
00178 char* Id;
00179
00180
00181 unsigned long XMLByteIndex;
00182
00183
00184 unsigned long InlineDataPosition;
00185
00186
00187 char** AttributeNames;
00188 char** AttributeValues;
00189 int NumberOfAttributes;
00190 int AttributesSize;
00191
00192
00193 int NumberOfNestedElements;
00194 int NestedElementsSize;
00195 vtkXMLDataElement** NestedElements;
00196
00197
00198 vtkXMLDataElement* Parent;
00199
00200
00201 void ReadXMLAttributes(const char** atts);
00202 void SeekInlineDataPosition(vtkXMLDataParser* parser);
00203
00204 void PrintXML(ostream& os, vtkIndent indent);
00205
00206
00207 vtkXMLDataElement* LookupElementInScope(const char* id);
00208 vtkXMLDataElement* LookupElementUpScope(const char* id);
00209 static int IsSpace(char c);
00210
00211
00212 friend class vtkXMLDataParser;
00213
00214
00215 private:
00216 vtkXMLDataElement(const vtkXMLDataElement&);
00217 void operator=(const vtkXMLDataElement&);
00218 };
00219
00220 #endif