IO/vtkXMLDataElement.h Source File

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# IO/vtkXMLDataElement.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkXMLDataElement.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00041 #ifndef __vtkXMLDataElement_h
    00042 #define __vtkXMLDataElement_h
    00043
    00044 #include "vtkObject.h"
    00045
    00046 class vtkXMLDataParser;
    00047
    00048 class VTK_IO_EXPORT vtkXMLDataElement : public vtkObject
    00049 {
    00050 public:
    00051   vtkTypeRevisionMacro(vtkXMLDataElement,vtkObject);
    00052   void PrintSelf(ostream& os, vtkIndent indent);
    00053   static vtkXMLDataElement* New();
    00054
    00056
    00057   vtkGetStringMacro(Name);
    00059
    00061
    00062   vtkGetStringMacro(Id);
    00064
    00067   const char* GetAttribute(const char* name);
    00068
    00070
    00072   int GetScalarAttribute(const char* name, int& value);
    00073   int GetScalarAttribute(const char* name, float& value);
    00074   int GetScalarAttribute(const char* name, unsigned long& value);
    00075 #ifdef VTK_ID_TYPE_IS_NOT_BASIC_TYPE
    00076   int GetScalarAttribute(const char* name, vtkIdType& value);
    00078 #endif
    00079
    00081
    00083   int GetVectorAttribute(const char* name, int length, int* value);
    00084   int GetVectorAttribute(const char* name, int length, float* value);
    00085   int GetVectorAttribute(const char* name, int length, unsigned long* value);
    00086 #ifdef VTK_ID_TYPE_IS_NOT_BASIC_TYPE
    00087   int GetVectorAttribute(const char* name, int length, vtkIdType* value);
    00089 #endif
    00090
    00093   int GetWordTypeAttribute(const char* name, int& value);
    00094
    00096   vtkXMLDataElement* GetParent();
    00097
    00099   int GetNumberOfNestedElements();
    00100
    00102   vtkXMLDataElement* GetNestedElement(int index);
    00103
    00105   vtkXMLDataElement* FindNestedElement(const char* id);
    00106
    00108   vtkXMLDataElement* LookupElement(const char* id);
    00109
    00111
    00113   vtkGetMacro(XMLByteIndex, unsigned long);
    00115
    00116 protected:
    00117   vtkXMLDataElement();
    00118   ~vtkXMLDataElement();
    00119
    00120   // The name of the element from the XML file.
    00121   char* Name;
    00122
    00123   // The value of the "id" attribute, if any was given.
    00124   char* Id;
    00125
    00126   // The offset into the XML stream where the element begins.
    00127   unsigned long XMLByteIndex;
    00128
    00129   // The offset into the XML stream where the inline data begins.
    00130   unsigned long InlineDataPosition;
    00131
    00132   // The raw property name/value pairs read from the XML attributes.
    00133   char** AttributeNames;
    00134   char** AttributeValues;
    00135   int NumberOfAttributes;
    00136   int AttributesSize;
    00137
    00138   // The set of nested elements.
    00139   int NumberOfNestedElements;
    00140   int NestedElementsSize;
    00141   vtkXMLDataElement** NestedElements;
    00142
    00143   // The parent of this element.
    00144   vtkXMLDataElement* Parent;
    00145
    00146   // Method used by vtkXMLFileParser to setup the element.
    00147   vtkSetStringMacro(Name);
    00148   vtkSetStringMacro(Id);
    00149   vtkSetMacro(XMLByteIndex, unsigned long);
    00150   void ReadXMLAttributes(const char** atts);
    00151   void AddNestedElement(vtkXMLDataElement* element);
    00152   void SeekInlineDataPosition(vtkXMLDataParser* parser);
    00153
    00154   void PrintXML(ostream& os, vtkIndent indent);
    00155
    00156   // Internal utility methods.
    00157   vtkXMLDataElement* LookupElementInScope(const char* id);
    00158   vtkXMLDataElement* LookupElementUpScope(const char* id);
    00159   void SetParent(vtkXMLDataElement* parent);
    00160   static int IsSpace(char c);
    00161
    00162   //BTX
    00163   friend class vtkXMLDataParser;
    00164   //ETX
    00165
    00166 private:
    00167   vtkXMLDataElement(const vtkXMLDataElement&);  // Not implemented.
    00168   void operator=(const vtkXMLDataElement&);  // Not implemented.
    00169 };
    00170
    00171 #endif