00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _MONITOR_XMLREADER_H
00020 #define _MONITOR_XMLREADER_H
00021
00022 #include <string>
00023 #include "indri/XMLNode.hpp"
00024 namespace indri
00025 {
00026 namespace xml
00027 {
00028
00029 class XMLReader {
00030 private:
00031 enum {
00032 TAG_OPEN_TYPE,
00033 TAG_CLOSE_TYPE,
00034 TAG_OPEN_CLOSE_TYPE,
00035 TAG_CDATA_TYPE
00036 };
00037
00038 int _tryFindChar( char ch, const char* buffer, int start, int finish );
00039 int _findChar( char ch, const char* buffer, int start, int finish );
00040 int _tryFindBeginTag( const char* buffer, int start, int finish );
00041 int _findBeginTag( const char* buffer, int start, int finish );
00042 int _findEndTag( const char* buffer, int start, int finish );
00043 int _tryFindText( const char* buffer, int start, int finish );
00044 int _findText( const char* buffer, int start, int finish );
00045 int _findNotName( const char* buffer, int start, int finish );
00046 int _findSpace( const char* buffer, int start, int finish );
00047 int _readTag( const char* buffer, int bufferStart, int bufferEnd, std::string* tagName, std::map<std::string, std::string>* attributes, int* tagType );
00048 int _findClosingTag( const char* buffer, int start, int end, std::string& openingTagName, bool* tagsBetween );
00049 void _read( XMLNode** parent, const char* buffer, int start, int end );
00050
00051 public:
00052 XMLNode* read( const char* buffer, size_t length );
00053 XMLNode* read( const std::string& str );
00054 };
00055 }
00056 }
00057
00058 #endif // _MONITOR_XMLREADER_H