Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkXMLDataElement.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkXMLDataElement.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00027 #ifndef __vtkXMLDataElement_h
00028 #define __vtkXMLDataElement_h
00029 
00030 #include "vtkObject.h"
00031 
00032 class vtkXMLDataParser;
00033 
00034 class VTK_IO_EXPORT vtkXMLDataElement : public vtkObject
00035 {
00036 public:
00037   vtkTypeRevisionMacro(vtkXMLDataElement,vtkObject);
00038   void PrintSelf(ostream& os, vtkIndent indent);
00039   static vtkXMLDataElement* New();
00040   
00042 
00043   vtkGetStringMacro(Name);
00044   vtkSetStringMacro(Name);
00046   
00048 
00049   vtkGetStringMacro(Id);
00050   vtkSetStringMacro(Id);
00052   
00055   const char* GetAttribute(const char* name);
00056 
00059   void SetAttribute(const char* name, const char* value);
00060  
00062 
00063   void SetCharacterData(const char* c, int length);
00064   void AddCharacterData(const char* c, int length);
00065   vtkGetStringMacro(CharacterData);
00067 
00069 
00071   int GetScalarAttribute(const char* name, int& value);
00072   int GetScalarAttribute(const char* name, float& value);
00073   int GetScalarAttribute(const char* name, double& value);
00074   int GetScalarAttribute(const char* name, unsigned long& value);
00076 
00078 
00082   void SetIntAttribute(const char* name, int value);
00083   void SetFloatAttribute(const char* name, float value);
00084   void SetDoubleAttribute(const char* name, double value);
00085   void SetUnsignedLongAttribute(const char* name, unsigned long value);
00087   
00089 
00091   int GetVectorAttribute(const char* name, int length, int* value);
00092   int GetVectorAttribute(const char* name, int length, float* value);
00093   int GetVectorAttribute(const char* name, int length, double* value);
00094   int GetVectorAttribute(const char* name, int length, unsigned long* value);
00096   
00098 
00099   void SetVectorAttribute(const char* name, int length, const int* value);
00100   void SetVectorAttribute(const char* name, int length, const float* value);
00101   void SetVectorAttribute(const char* name, int length, const double* value);
00102   void SetVectorAttribute(const char* name, int length, const unsigned long* value);
00104 
00105 #ifdef VTK_USE_64BIT_IDS
00106   //BTX
00107   int  GetScalarAttribute(const char* name, vtkIdType& value);
00108   void SetIdTypeAttribute(const char* name, vtkIdType value);
00109   int  GetVectorAttribute(const char* name, int length, vtkIdType* value);
00110   void SetVectorAttribute(const char* name, int length, const vtkIdType* value);
00111   //ETX
00112 #endif
00113   
00116   int GetWordTypeAttribute(const char* name, int& value);
00117   
00119 
00120   vtkGetMacro(NumberOfAttributes, int);
00122 
00124   const char* GetAttributeName(int idx);
00125 
00128   const char* GetAttributeValue(int idx);
00129 
00131   virtual void RemoveAllAttributes();
00132 
00134 
00135   vtkXMLDataElement* GetParent();
00136   void SetParent(vtkXMLDataElement* parent);
00138   
00140   virtual vtkXMLDataElement* GetRoot();
00141   
00143   int GetNumberOfNestedElements();
00144   
00146   vtkXMLDataElement* GetNestedElement(int index);
00147   
00149   void AddNestedElement(vtkXMLDataElement* element);
00150 
00152   virtual void RemoveNestedElement(vtkXMLDataElement *);
00153   
00155   virtual void RemoveAllNestedElements();
00156 
00158 
00160   vtkXMLDataElement* FindNestedElement(const char* id);
00161   vtkXMLDataElement* FindNestedElementWithName(const char* name);
00162   vtkXMLDataElement* FindNestedElementWithNameAndId(
00163     const char* name, const char* id);
00164   vtkXMLDataElement* FindNestedElementWithNameAndAttribute(
00165     const char* name, const char* att_name, const char* att_value);
00167   
00169   vtkXMLDataElement* LookupElement(const char* id);
00170   
00172 
00174   vtkGetMacro(XMLByteIndex, unsigned long);
00175   vtkSetMacro(XMLByteIndex, unsigned long);
00177   
00182   virtual int IsEqualTo(vtkXMLDataElement *elem);
00183 
00187   virtual void DeepCopy(vtkXMLDataElement *elem);
00188 
00190 
00195   vtkSetClampMacro(AttributeEncoding,int,VTK_ENCODING_NONE,VTK_ENCODING_UNKNOWN);
00196   vtkGetMacro(AttributeEncoding, int);
00198   
00199 protected:
00200   vtkXMLDataElement();
00201   ~vtkXMLDataElement();  
00202   
00203   // The name of the element from the XML file.
00204   char* Name;
00205   
00206   // The value of the "id" attribute, if any was given.
00207   char* Id;
00208   
00209   // The character data between the start and end tags of this element.
00210   char* CharacterData;
00211   
00212   // The offset into the XML stream where the element begins.
00213   unsigned long XMLByteIndex;
00214   
00215   // The offset into the XML stream where the inline data begins.
00216   unsigned long InlineDataPosition;
00217   
00218   // The raw property name/value pairs read from the XML attributes.
00219   char** AttributeNames;
00220   char** AttributeValues;
00221   int NumberOfAttributes;
00222   int AttributesSize;
00223   int AttributeEncoding;
00224 
00225   // The set of nested elements.
00226   int NumberOfNestedElements;
00227   int NestedElementsSize;
00228   vtkXMLDataElement** NestedElements;
00229   
00230   // The parent of this element.
00231   vtkXMLDataElement* Parent;
00232   
00233   // Method used by vtkXMLFileParser to setup the element.
00234   void ReadXMLAttributes(const char** atts, int encoding);  
00235   void SeekInlineDataPosition(vtkXMLDataParser* parser);
00236   
00237   void PrintXML(ostream& os, vtkIndent indent);
00238   
00239   // Internal utility methods.
00240   vtkXMLDataElement* LookupElementInScope(const char* id);
00241   vtkXMLDataElement* LookupElementUpScope(const char* id);
00242   static int IsSpace(char c);
00243   
00244   //BTX
00245   friend class vtkXMLDataParser;
00246   friend class vtkXMLMaterialParser;
00247   //ETX
00248 
00249 private:
00250   vtkXMLDataElement(const vtkXMLDataElement&);  // Not implemented.
00251   void operator=(const vtkXMLDataElement&);  // Not implemented.
00252 };
00253 
00254 #endif

Generated on Mon Jan 21 23:07:32 2008 for VTK by  doxygen 1.4.3-20050530