15 #ifndef OPENHRP_UTIL_EASYSCANNER_H_INCLUDED 16 #define OPENHRP_UTIL_EASYSCANNER_H_INCLUDED 23 #include <boost/shared_ptr.hpp> 40 std::string getFullMessage();
44 T_NONE = 0, T_SPACE, T_ALPHABET, T_INTEGER, T_DOUBLE,
T_WORD,
62 symbols->insert(SymbolPair(symbol,
id));
66 SymbolMap::iterator p = symbols->find(symbol);
67 return (p != symbols->end()) ? p->second : 0;
71 void setCommentChar(
char cc);
73 void setLineOriented(
bool on);
74 void setQuoteChar(
char qc);
75 void setWhiteSpaceChar(
char ws);
77 void loadFile(
const std::string&
filename);
79 void setText(
const char* text,
int len);
81 void setLineNumberOffset(
int offset);
84 defaultErrorMessage = message;
96 bool readChar(
int chara);
114 return readString0(delimiterChar);
117 bool readString(
const char* str);
120 return readString(str.c_str());
123 bool readQuotedString(
bool allowNoQuotedWord =
false);
125 bool readUnquotedTextBlock();
128 bool readSymbol(
int id);
132 return (*text ==
'\0');
143 return readLF0() ?
true : (*text ==
'\0');
150 bool skipBlankLines();
154 void throwException(
const char*
message);
155 void throwException(
const std::string& message);
162 if(!readInt()) throwException(message);
170 if(!readDouble()) throwException(message);
179 throwException(message);
186 if(!readChar(chara)) throwException(message);
193 if(!readWord()) throwException(message);
202 if(!readString()) throwException(message);
207 if(!readQuotedString()) throwException(message);
215 if(!readSymbol()) throwException(message);
222 if(!readLF()) throwException(message);
226 if(!readLFEOF()) throwException(message);
244 int extractQuotedString();
246 inline void skipToLineEnd();
249 bool readString0(
const int delimiterChar);
bool readString(const int delimiterChar= ',')
void readCharEx(int chara, const char *message=0)
HRP_UTIL_EXPORT EasyScanner & operator>>(EasyScanner &scanner, double &value)
bool readLF()
reading a line feed
double readDoubleEx(const char *message=0)
int readSymbolEx(const char *message=0)
std::string readWordEx(const char *message=0)
int readCharEx(const char *message=0)
void setDefaultErrorMessage(const std::string &message)
std::string readStringEx(const char *message=0)
std::pair< std::string, int > SymbolPair
std::vector< int > whiteSpaceChars
void registerSymbol(int id, const std::string &symbol)
std::map< std::string, int > SymbolMap
bool readString(const std::string &str)
void toLower(std::string &str)
int readIntEx(const char *message=0)
int getSymbolID(const std::string &symbol)
void readLFex(const char *message=0)
void readLFEOFex(const char *message=0)
std::string readQuotedStringEx(const char *message=0)
boost::shared_ptr< EasyScanner > EasyScannerPtr
boost::shared_ptr< SymbolMap > SymbolMapPtr
std::string defaultErrorMessage