00001 #ifndef _CTBxmlLexer_HXX
00002 #define _CTBxmlLexer_HXX 1
00003
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "CTBstring.hxx"
00017
00018 class CTBxmlLexerToken;
00019
00020 class CTBxmlLexer {
00021 public:
00022 enum mode { tagordata,
00023 tagattr,
00024 attrval,
00025 valsquote,
00026 valdquote
00027 };
00028
00029 CTBxmlLexer();
00030
00031 void Get(istream& is, CTBxmlLexerToken& lt);
00032
00033 void Clear();
00034 int NLine() const;
00035 int NColumn() const;
00036
00037 void Mode(int i_mode);
00038 int Mode() const;
00039
00040 void Dump(int i_indent=0, ostream& os=cout,
00041 const char* p_text=0) const;
00042
00043 private:
00044 int GetChar(istream& is);
00045 void GetEntity(istream& is, CTBxmlLexerToken& lt);
00046 void GetWhite(istream& is, CTBxmlLexerToken& lt);
00047 void GetName(istream& is, CTBxmlLexerToken& lt);
00048
00049 private:
00050 int mi_mode;
00051 int mi_nline_t;
00052 int mi_ncolumn_t;
00053 int mi_nline_s;
00054 int mi_ncolumn_s;
00055 };
00056
00057
00058
00059 class CTBxmlLexerToken {
00060 public:
00061 enum type { invalid = -1,
00062 fail,
00063 eof,
00064 tagopen,
00065 etagopen,
00066 tagclose,
00067 etagclose,
00068 comment,
00069 defopen,
00070 piopen,
00071 piclose,
00072 charref,
00073 entref,
00074 equal,
00075 squote,
00076 dquote,
00077 name,
00078 white,
00079 data
00080 };
00081
00082 CTBxmlLexerToken();
00083
00084 int Type() const;
00085 void Type(int i_type);
00086
00087 const CTBstring& Text() const;
00088
00089 void Clear();
00090
00091 void ToStream(ostream& os) const;
00092
00093 void Dump(int i_indent=0, ostream& os=cout,
00094 const char* p_text=0) const;
00095
00096 bool operator!() const;
00097
00098 operator const char* () const;
00099 operator CTBstring() const;
00100
00101 CTBxmlLexerToken& operator=(const char* c_text);
00102 CTBxmlLexerToken& operator+=(char c);
00103 CTBxmlLexerToken& operator+=(const char* c_text);
00104
00105 private:
00106
00107 int mi_type;
00108 CTBstring m_text;
00109 };
00110
00111 ostream& operator<<(ostream& os, const CTBxmlLexerToken& obj);
00112
00113 #include "CTBxmlLexer.icc"
00114
00115 #endif