class Token\r
{\r
public:\r
- ///\r
- enum Type\r
- {\r
- Type_string, ///\r
- Type_number, ///\r
- Type_regexp, ///\r
- Type_openParen, ///\r
- Type_closeParen, ///\r
- Type_comma, ///\r
- };\r
- \r
+ ///\r
+ enum Type {\r
+ Type_string, ///\r
+ Type_number, ///\r
+ Type_regexp, ///\r
+ Type_openParen, ///\r
+ Type_closeParen, ///\r
+ Type_comma, ///\r
+ };\r
+\r
private:\r
- u_char m_type; ///\r
- bool m_isValueQuoted; ///\r
- int m_numericValue; ///\r
- tstringi m_stringValue; ///\r
- long m_data; ///\r
- \r
+ u_char m_type; ///\r
+ bool m_isValueQuoted; ///\r
+ int m_numericValue; ///\r
+ tstringi m_stringValue; ///\r
+ long m_data; ///\r
+\r
public:\r
- ///\r
- Token(const Token &i_token);\r
- ///\r
- Token(int i_value, const tstringi &i_display);\r
- ///\r
- Token(const tstringi &i_value, bool i_isValueQuoted,\r
- bool i_isRegexp = false);\r
- ///\r
- Token(Type i_type);\r
- \r
- /// is the value quoted ?\r
- bool isQuoted() const { return m_isValueQuoted; }\r
-\r
- /// value type\r
- Type getType() const { return static_cast<Type>(m_type); }\r
- ///\r
- bool isString() const { return m_type == Type_string; }\r
- ///\r
- bool isNumber() const { return m_type == Type_number; }\r
- ///\r
- bool isRegexp() const { return m_type == Type_regexp; }\r
- ///\r
- bool isOpenParen() const { return m_type == Type_openParen; }\r
- ///\r
- bool isCloseParen() const { return m_type == Type_closeParen; }\r
- ///\r
- bool isComma() const { return m_type == Type_comma; }\r
- \r
- /// get numeric value\r
- int getNumber() const;\r
- \r
- /// get string value\r
- tstringi getString() const;\r
- \r
- /// get regexp value\r
- tstringi getRegexp() const;\r
-\r
- /// get data\r
- long getData() const { return m_data; }\r
- ///\r
- void setData(long i_data) { m_data = i_data; }\r
- \r
- /// case insensitive equal\r
- bool operator==(const tstringi &i_str) const\r
- { return *this == i_str.c_str(); }\r
- ///\r
- bool operator==(const _TCHAR *i_str) const;\r
- ///\r
- bool operator!=(const tstringi &i_str) const\r
- { return *this != i_str.c_str(); }\r
- ///\r
- bool operator!=(const _TCHAR *i_str) const { return !(*this == i_str); }\r
- \r
- /** paren equal\r
- @param i_c '<code>(</code>' or '<code>)</code>' */\r
- bool operator==(const _TCHAR i_c) const;\r
- /** paren equal\r
- @param i_c '<code>(</code>' or '<code>)</code>' */\r
- bool operator!=(const _TCHAR i_c) const { return !(*this == i_c); }\r
-\r
- /// add string\r
- void add(const tstringi &i_str);\r
-\r
- /// stream output\r
- friend tostream &operator<<(tostream &i_ost, const Token &i_token);\r
+ ///\r
+ Token(const Token &i_token);\r
+ ///\r
+ Token(int i_value, const tstringi &i_display);\r
+ ///\r
+ Token(const tstringi &i_value, bool i_isValueQuoted,\r
+ bool i_isRegexp = false);\r
+ ///\r
+ Token(Type i_type);\r
+\r
+ /// is the value quoted ?\r
+ bool isQuoted() const {\r
+ return m_isValueQuoted;\r
+ }\r
+\r
+ /// value type\r
+ Type getType() const {\r
+ return static_cast<Type>(m_type);\r
+ }\r
+ ///\r
+ bool isString() const {\r
+ return m_type == Type_string;\r
+ }\r
+ ///\r
+ bool isNumber() const {\r
+ return m_type == Type_number;\r
+ }\r
+ ///\r
+ bool isRegexp() const {\r
+ return m_type == Type_regexp;\r
+ }\r
+ ///\r
+ bool isOpenParen() const {\r
+ return m_type == Type_openParen;\r
+ }\r
+ ///\r
+ bool isCloseParen() const {\r
+ return m_type == Type_closeParen;\r
+ }\r
+ ///\r
+ bool isComma() const {\r
+ return m_type == Type_comma;\r
+ }\r
+\r
+ /// get numeric value\r
+ int getNumber() const;\r
+\r
+ /// get string value\r
+ tstringi getString() const;\r
+\r
+ /// get regexp value\r
+ tstringi getRegexp() const;\r
+\r
+ /// get data\r
+ long getData() const {\r
+ return m_data;\r
+ }\r
+ ///\r
+ void setData(long i_data) {\r
+ m_data = i_data;\r
+ }\r
+\r
+ /// case insensitive equal\r
+ bool operator==(const tstringi &i_str) const {\r
+ return *this == i_str.c_str();\r
+ }\r
+ ///\r
+ bool operator==(const _TCHAR *i_str) const;\r
+ ///\r
+ bool operator!=(const tstringi &i_str) const {\r
+ return *this != i_str.c_str();\r
+ }\r
+ ///\r
+ bool operator!=(const _TCHAR *i_str) const {\r
+ return !(*this == i_str);\r
+ }\r
+\r
+ /** paren equal\r
+ @param i_c '<code>(</code>' or '<code>)</code>' */\r
+ bool operator==(const _TCHAR i_c) const;\r
+ /** paren equal\r
+ @param i_c '<code>(</code>' or '<code>)</code>' */\r
+ bool operator!=(const _TCHAR i_c) const {\r
+ return !(*this == i_c);\r
+ }\r
+\r
+ /// add string\r
+ void add(const tstringi &i_str);\r
+\r
+ /// stream output\r
+ friend tostream &operator<<(tostream &i_ost, const Token &i_token);\r
};\r
\r
\r
class Parser\r
{\r
public:\r
- ///\r
- typedef std::vector<Token> Tokens;\r
- \r
+ ///\r
+ typedef std::vector<Token> Tokens;\r
+\r
private:\r
- ///\r
- typedef std::vector<tstringi> Prefixes;\r
- \r
+ ///\r
+ typedef std::vector<tstringi> Prefixes;\r
+\r
private:\r
- size_t m_lineNumber; /// current line number\r
- const Prefixes *m_prefixes; /** string that may be prefix\r
+ size_t m_lineNumber; /// current line number\r
+ const Prefixes *m_prefixes; /** string that may be prefix\r
of a token */\r
- \r
- size_t m_internalLineNumber; /// next line number\r
- const _TCHAR *m_ptr; /// read pointer\r
- const _TCHAR *m_end; /// end pointer\r
+\r
+ size_t m_internalLineNumber; /// next line number\r
+ const _TCHAR *m_ptr; /// read pointer\r
+ const _TCHAR *m_end; /// end pointer\r
\r
private:\r
- /// get a line\r
- bool getLine(tstringi *o_line);\r
- \r
+ /// get a line\r
+ bool getLine(tstringi *o_line);\r
+\r
public:\r
- ///\r
- Parser(const _TCHAR *i_str, size_t i_length);\r
-\r
- /** get a parsed line. if no more lines exist, returns false */\r
- bool getLine(Tokens *o_tokens);\r
- \r
- /// get current line number\r
- size_t getLineNumber() const { return m_lineNumber; }\r
- \r
- /** set string that may be prefix of a token. prefix_ is not\r
- copied, so it must be preserved after setPrefix() */\r
- void setPrefixes(const Prefixes *m_prefixes);\r
+ ///\r
+ Parser(const _TCHAR *i_str, size_t i_length);\r
+\r
+ /** get a parsed line. if no more lines exist, returns false */\r
+ bool getLine(Tokens *o_tokens);\r
+\r
+ /// get current line number\r
+ size_t getLineNumber() const {\r
+ return m_lineNumber;\r
+ }\r
+\r
+ /** set string that may be prefix of a token. prefix_ is not\r
+ copied, so it must be preserved after setPrefix() */\r
+ void setPrefixes(const Prefixes *m_prefixes);\r
};\r
\r
\r