1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\r
9 # include "stringtool.h"
\r
23 Type_closeParen, ///
\r
29 bool m_isValueQuoted; ///
\r
30 int m_numericValue; ///
\r
31 tstringi m_stringValue; ///
\r
36 Token(const Token &i_token);
\r
38 Token(int i_value, const tstringi &i_display);
\r
40 Token(const tstringi &i_value, bool i_isValueQuoted,
\r
41 bool i_isRegexp = false);
\r
45 /// is the value quoted ?
\r
46 bool isQuoted() const {
\r
47 return m_isValueQuoted;
\r
51 Type getType() const {
\r
52 return static_cast<Type>(m_type);
\r
55 bool isString() const {
\r
56 return m_type == Type_string;
\r
59 bool isNumber() const {
\r
60 return m_type == Type_number;
\r
63 bool isRegexp() const {
\r
64 return m_type == Type_regexp;
\r
67 bool isOpenParen() const {
\r
68 return m_type == Type_openParen;
\r
71 bool isCloseParen() const {
\r
72 return m_type == Type_closeParen;
\r
75 bool isComma() const {
\r
76 return m_type == Type_comma;
\r
79 /// get numeric value
\r
80 int getNumber() const;
\r
82 /// get string value
\r
83 tstringi getString() const;
\r
85 /// get regexp value
\r
86 tstringi getRegexp() const;
\r
89 long getData() const {
\r
93 void setData(long i_data) {
\r
97 /// case insensitive equal
\r
98 bool operator==(const tstringi &i_str) const {
\r
99 return *this == i_str.c_str();
\r
102 bool operator==(const _TCHAR *i_str) const;
\r
104 bool operator!=(const tstringi &i_str) const {
\r
105 return *this != i_str.c_str();
\r
108 bool operator!=(const _TCHAR *i_str) const {
\r
109 return !(*this == i_str);
\r
113 @param i_c '<code>(</code>' or '<code>)</code>' */
\r
114 bool operator==(const _TCHAR i_c) const;
\r
116 @param i_c '<code>(</code>' or '<code>)</code>' */
\r
117 bool operator!=(const _TCHAR i_c) const {
\r
118 return !(*this == i_c);
\r
122 void add(const tstringi &i_str);
\r
125 friend tostream &operator<<(tostream &i_ost, const Token &i_token);
\r
134 typedef std::vector<Token> Tokens;
\r
138 typedef std::vector<tstringi> Prefixes;
\r
141 size_t m_lineNumber; /// current line number
\r
142 const Prefixes *m_prefixes; /** string that may be prefix
\r
145 size_t m_internalLineNumber; /// next line number
\r
146 const _TCHAR *m_ptr; /// read pointer
\r
147 const _TCHAR *m_end; /// end pointer
\r
151 bool getLine(tstringi *o_line);
\r
155 Parser(const _TCHAR *i_str, size_t i_length);
\r
157 /** get a parsed line. if no more lines exist, returns false */
\r
158 bool getLine(Tokens *o_tokens);
\r
160 /// get current line number
\r
161 size_t getLineNumber() const {
\r
162 return m_lineNumber;
\r
165 /** set string that may be prefix of a token. prefix_ is not
\r
166 copied, so it must be preserved after setPrefix() */
\r
167 void setPrefixes(const Prefixes *m_prefixes);
\r
171 #endif // !_PARSER_H
\r