00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00027 #ifndef __vtkKWEXMLElement_h
00028 #define __vtkKWEXMLElement_h
00029
00030 #include "vtkObject.h"
00031 #include "VTKEdgeConfigure.h"
00032 #include "vtkStdString.h"
00033
00034 class vtkCollection;
00035 class vtkKWEXMLParser;
00036
00037
00038 struct vtkKWEXMLElementInternals;
00039
00040
00041 class VTKEdge_IO_EXPORT vtkKWEXMLElement : public vtkObject
00042 {
00043 public:
00044 vtkTypeRevisionMacro(vtkKWEXMLElement,vtkObject);
00045 void PrintSelf(ostream& os, vtkIndent indent);
00046 static vtkKWEXMLElement* New();
00047
00049
00050 vtkSetStringMacro(Name);
00051 vtkGetStringMacro(Name);
00053
00055
00057 vtkGetStringMacro(Id);
00059
00062 const char* GetAttribute(const char* name);
00063
00065 const char* GetCharacterData();
00066
00068
00070 unsigned int GetScalarAttribute(const char* name, int* value);
00071 unsigned int GetScalarAttribute(const char* name, unsigned int* value);
00072 unsigned int GetScalarAttribute(const char* name, unsigned long* value);
00073 unsigned int GetScalarAttribute(const char* name, float* value);
00074 unsigned int GetScalarAttribute(const char* name, double* value);
00075 #if defined(VTK_USE_64BIT_IDS)
00076 unsigned int GetScalarAttribute(const char* name, vtkIdType* value);
00077 #endif
00078
00079
00081
00083 unsigned int GetVectorAttribute(const char* name, unsigned int length, int* value);
00084 unsigned int GetVectorAttribute(const char* name, unsigned int length, unsigned int* value);
00085 unsigned int GetVectorAttribute(const char* name, unsigned int length, unsigned long* value);
00086 unsigned int GetVectorAttribute(const char* name, unsigned int length, float* value);
00087 unsigned int GetVectorAttribute(const char* name, unsigned int length, double* value);
00088 #if defined(VTK_USE_64BIT_IDS)
00089 unsigned int GetVectorAttribute(const char* name, unsigned int length, vtkIdType* value);
00090 #endif
00091
00092
00094
00096 unsigned int GetCharacterDataAsVector(unsigned int length, int* value);
00097 unsigned int GetCharacterDataAsVector(unsigned int length, unsigned long* value);
00098 unsigned int GetCharacterDataAsVector(unsigned int length, float* value);
00099 unsigned int GetCharacterDataAsVector(unsigned int length, double* value);
00100 #if defined(VTK_USE_64BIT_IDS)
00101 unsigned int GetCharacterDataAsVector(unsigned int length, vtkIdType* value);
00102 #endif
00103
00104
00106 vtkKWEXMLElement* GetParent();
00107
00109 unsigned int GetNumberOfNestedElements();
00110
00112 vtkKWEXMLElement* GetNestedElement(unsigned int index);
00113
00116 vtkKWEXMLElement* FindNestedElement(const char* id);
00117
00119 vtkKWEXMLElement* FindNestedElementByName(const char* name);
00120
00122 void RemoveAllNestedElements();
00123
00125 void RemoveNestedElement(vtkKWEXMLElement*);
00126
00128 vtkKWEXMLElement* LookupElement(const char* id);
00129
00131
00132 void AddAttribute(const char* attrName, const char* attrValue);
00133 void AddAttribute(const char* attrName, unsigned int attrValue);
00134 void AddAttribute(const char* attrName, double attrValue);
00135 void AddAttribute(const char* attrName, int attrValue);
00136 void AddAttribute(const char* attrName, unsigned long attrValue);
00137 void AddAttribute(const char* attrName, double* vals, unsigned int length);
00138 void AddAttribute(const char* attrName, int* vals, unsigned int length);
00139 void AddAttribute(const char* attrName, unsigned long* vals, unsigned int length);
00140 #if defined(VTK_USE_64BIT_IDS)
00141 void AddAttribute(const char* attrName, vtkIdType attrValue);
00142 void AddAttribute(const char* attrName, vtkIdType* vals, unsigned int length);
00143 #endif
00144
00145
00150 void SetAttribute(const char* attrName, const char* attrValue);
00151
00153
00156 void AddNestedElement(vtkKWEXMLElement* element, int setPrent);
00157 void AddNestedElement(vtkKWEXMLElement* element);
00159
00161
00162 void PrintXML(ostream& os, vtkIndent indent);
00163 void PrintXML();
00165
00172 void Merge(vtkKWEXMLElement* element, const char* attributeName);
00173
00179 void GetElementsByName(const char* name, vtkCollection* elements);
00180
00182 static vtkStdString Encode(const char* plaintext);
00183
00184 protected:
00185 vtkKWEXMLElement();
00186 ~vtkKWEXMLElement();
00187
00188 vtkKWEXMLElementInternals* Internal;
00189
00190 char* Name;
00191 char* Id;
00192
00193
00194 vtkKWEXMLElement* Parent;
00195
00196
00197 vtkSetStringMacro(Id);
00198 void ReadXMLAttributes(const char** atts);
00199 void AddCharacterData(const char* data, int length);
00200
00201
00202
00203 vtkKWEXMLElement* LookupElementInScope(const char* id);
00204 vtkKWEXMLElement* LookupElementUpScope(const char* id);
00205 void SetParent(vtkKWEXMLElement* parent);
00206
00207
00208 friend class vtkKWEXMLParser;
00209
00210
00211 private:
00212 vtkKWEXMLElement(const vtkKWEXMLElement&);
00213 void operator=(const vtkKWEXMLElement&);
00214 };
00215
00216 #endif