00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00021 #ifndef __vtkPVXMLElement_h
00022 #define __vtkPVXMLElement_h
00023
00024 #include "vtkObject.h"
00025
00026 class vtkPVXMLParser;
00027
00028 class VTK_EXPORT vtkPVXMLElement : public vtkObject
00029 {
00030 public:
00031 vtkTypeRevisionMacro(vtkPVXMLElement,vtkObject);
00032 void PrintSelf(ostream& os, vtkIndent indent);
00033 static vtkPVXMLElement* New();
00034
00036
00037 vtkGetStringMacro(Name);
00039
00041
00042 vtkGetStringMacro(Id);
00044
00047 const char* GetAttribute(const char* name);
00048
00050
00052 int GetScalarAttribute(const char* name, int* value);
00053 int GetScalarAttribute(const char* name, float* value);
00054 int GetScalarAttribute(const char* name, double* value);
00056
00058
00060 int GetVectorAttribute(const char* name, int length, int* value);
00061 int GetVectorAttribute(const char* name, int length, float* value);
00062 int GetVectorAttribute(const char* name, int length, double* value);
00064
00066 vtkPVXMLElement* GetParent();
00067
00069 unsigned int GetNumberOfNestedElements();
00070
00072 vtkPVXMLElement* GetNestedElement(unsigned int index);
00073
00075 vtkPVXMLElement* FindNestedElement(const char* id);
00076
00078 vtkPVXMLElement* LookupElement(const char* id);
00079
00080 protected:
00081 vtkPVXMLElement();
00082 ~vtkPVXMLElement();
00083
00084 char* Name;
00085 char* Id;
00086
00087
00088 char** AttributeNames;
00089 char** AttributeValues;
00090 unsigned int NumberOfAttributes;
00091 unsigned int AttributesSize;
00092
00093
00094 unsigned int NumberOfNestedElements;
00095 unsigned int NestedElementsSize;
00096 vtkPVXMLElement** NestedElements;
00097
00098
00099 vtkPVXMLElement* Parent;
00100
00101
00102 vtkSetStringMacro(Name);
00103 vtkSetStringMacro(Id);
00104 void ReadXMLAttributes(const char** atts);
00105 void AddNestedElement(vtkPVXMLElement* element);
00106 void AddCharacterData(const char* data, int length);
00107
00108 void PrintXML(ostream& os, vtkIndent indent);
00109
00110
00111 vtkPVXMLElement* LookupElementInScope(const char* id);
00112 vtkPVXMLElement* LookupElementUpScope(const char* id);
00113 void SetParent(vtkPVXMLElement* parent);
00114
00115
00116 friend class vtkPVXMLParser;
00117
00118
00119 private:
00120 vtkPVXMLElement(const vtkPVXMLElement&);
00121 void operator=(const vtkPVXMLElement&);
00122 };
00123
00124 #endif