00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00042 #ifndef __vtkXMLDataParser_h
00043 #define __vtkXMLDataParser_h
00044
00045 #include "vtkXMLParser.h"
00046
00047 class vtkXMLDataElement;
00048 class vtkInputStream;
00049 class vtkDataCompressor;
00050
00051 class VTK_IO_EXPORT vtkXMLDataParser : public vtkXMLParser
00052 {
00053 public:
00054 vtkTypeRevisionMacro(vtkXMLDataParser,vtkXMLParser);
00055 void PrintSelf(ostream& os, vtkIndent indent);
00056 static vtkXMLDataParser* New();
00057
00058
00060
00061 enum { BigEndian, LittleEndian };
00062
00064
00066 vtkXMLDataElement* GetRootElement();
00067
00069
00071 unsigned long ReadInlineData(vtkXMLDataElement* element, int isAscii,
00072 void* buffer, int startWord, int numWords,
00073 int wordType);
00074 unsigned long ReadInlineData(vtkXMLDataElement* element, int isAscii,
00075 char* buffer, int startWord, int numWords)
00076 { return this->ReadInlineData(element, isAscii, buffer, startWord,
00077 numWords, VTK_CHAR); }
00079
00081
00083 unsigned long ReadAppendedData(unsigned long offset, void* buffer,
00084 int startWord, int numWords, int wordType);
00085 unsigned long ReadAppendedData(unsigned long offset, char* buffer,
00086 int startWord, int numWords)
00087 { return this->ReadAppendedData(offset, buffer, startWord, numWords,
00088 VTK_CHAR); }
00090
00092
00094 unsigned long ReadAsciiData(void* buffer, int startWord, int numWords,
00095 int wordType);
00097
00099
00101 unsigned long ReadBinaryData(void* buffer, int startWord, int maxWords,
00102 int wordType);
00104
00106
00108 virtual void SetCompressor(vtkDataCompressor*);
00109 vtkGetObjectMacro(Compressor, vtkDataCompressor);
00111
00113 unsigned long GetWordTypeSize(int wordType);
00114
00117 virtual int Parse();
00118
00119 protected:
00120 vtkXMLDataParser();
00121 ~vtkXMLDataParser();
00122
00123
00124 virtual int Parse(const char*);
00125 virtual int Parse(const char*, unsigned int);
00126
00127
00128 void StartElement(const char* name, const char** atts);
00129 void EndElement(const char*);
00130 int ParsingComplete();
00131 void ClearStreamEOF();
00132 int CheckPrimaryAttributes();
00133 void FindAppendedDataPosition();
00134 unsigned long FindInlineDataPosition(unsigned long start);
00135 int ParseBuffer(const char* buffer, unsigned int count);
00136
00137 void AddElement(vtkXMLDataElement* element);
00138 void PushOpenElement(vtkXMLDataElement* element);
00139 vtkXMLDataElement* PopOpenElement();
00140 void PerformByteSwap(void* data, int numWords, int wordSize);
00141
00142
00143 void ReadCompressionHeader();
00144 unsigned int FindBlockSize(unsigned int block);
00145 int ReadBlock(unsigned int block, unsigned char* buffer);
00146 unsigned char* ReadBlock(unsigned int block);
00147 unsigned long ReadUncompressedData(unsigned char* data, unsigned long offset,
00148 unsigned long length);
00149 unsigned long ReadCompressedData(unsigned char* data, unsigned long offset,
00150 unsigned long length);
00151
00152
00153 int ParseAsciiData(int wordType);
00154 void FreeAsciiBuffer();
00155
00156
00157 vtkXMLDataElement* RootElement;
00158
00159
00160 vtkXMLDataElement** OpenElements;
00161 unsigned int NumberOfOpenElements;
00162 unsigned int OpenElementsSize;
00163
00164
00165 unsigned long AppendedDataPosition;
00166
00167
00168 int AppendedDataMatched;
00169
00170
00171 int ByteOrder;
00172
00173
00174
00175 vtkInputStream* DataStream;
00176
00177
00178
00179 vtkInputStream* InlineDataStream;
00180
00181
00182 vtkInputStream* AppendedDataStream;
00183
00184
00185 vtkDataCompressor* Compressor;
00186 unsigned int NumberOfBlocks;
00187 unsigned int BlockUncompressedSize;
00188 unsigned int PartialLastBlockUncompressedSize;
00189 unsigned int* BlockCompressedSizes;
00190 unsigned long* BlockStartOffsets;
00191
00192
00193 unsigned char* AsciiDataBuffer;
00194 int AsciiDataBufferLength;
00195 int AsciiDataWordType;
00196 unsigned long AsciiDataPosition;
00197
00198 private:
00199 vtkXMLDataParser(const vtkXMLDataParser&);
00200 void operator=(const vtkXMLDataParser&);
00201 };
00202
00203 #endif