7 #ifndef CNOID_UTIL_EASYSCANNER_H_INCLUDED 8 #define CNOID_UTIL_EASYSCANNER_H_INCLUDED 13 #include <boost/shared_ptr.hpp> 34 std::string getFullMessage()
const;
38 T_NONE = 0, T_SPACE, T_ALPHABET, T_INTEGER, T_DOUBLE,
T_WORD,
56 symbols->insert(SymbolPair(symbol,
id));
60 SymbolMap::iterator p = symbols->find(symbol);
61 return (p != symbols->end()) ? p->second : 0;
65 void setCommentChar(
char cc);
67 void setLineOriented(
bool on);
68 void setQuoteChar(
char qc);
69 void setWhiteSpaceChar(
char ws);
71 void loadFile(
const std::string& filename);
73 void setText(
const char* text,
int len);
75 void setLineNumberOffset(
int offset);
78 defaultErrorMessage = message;
91 bool readChar(
int chara);
109 return readString0(delimiterChar);
112 bool readString(
const char*
str);
115 return readString(str.c_str());
118 bool readQuotedString(
bool allowNoQuotedWord =
false);
120 bool readUnquotedTextBlock();
123 bool readSymbol(
int id);
127 return (*text ==
'\0');
138 return readLF0() ?
true : (*text ==
'\0');
145 bool skipBlankLines();
146 void skipToLineEnd();
150 void throwException(
const char* message);
151 void throwException(
const std::string& message);
158 if(!readInt()) throwException(message);
166 if(!readDouble()) throwException(message);
174 if(!readFloat()) throwException(message);
183 throwException(message);
190 if(!readChar(chara)) throwException(message);
196 inline const std::string&
readWordEx(
const char* message = 0) {
197 if(!readWord()) throwException(message);
202 if(!readString(str)) throwException(message);
210 if(!readString()) throwException(message);
215 if(!readQuotedString()) throwException(message);
223 if(!readSymbol()) throwException(message);
230 if(!readLF()) throwException(message);
234 if(!readLFEOF()) throwException(message);
253 bool extractQuotedString();
257 bool readString0(
const int delimiterChar);
262 int lineNumberOffset;
267 std::vector<int> whiteSpaceChars;
269 SymbolMapPtr symbols;
void registerSymbol(int id, const std::string &symbol)
Definition: EasyScanner.h:55
bool readWord()
Definition: EasyScanner.h:98
bool readLF()
reading a line feed
Definition: EasyScanner.h:131
const std::string & readQuotedStringEx(const char *message=0)
Definition: EasyScanner.h:214
Endl endl
Definition: EasyScanner.h:46
void setDefaultErrorMessage(const std::string &message)
Definition: EasyScanner.h:77
void readCharEx(int chara, const char *message=0)
Definition: EasyScanner.h:189
std::pair< std::string, int > SymbolPair
Definition: EasyScanner.h:43
CNOID_EXPORT EasyScanner & operator>>(EasyScanner &scanner, double &value)
Definition: EasyScanner.cpp:758
int intValue
Definition: EasyScanner.h:237
char charValue
Definition: EasyScanner.h:241
std::map< std::string, int > SymbolMap
Definition: EasyScanner.h:42
double doubleValue
Definition: EasyScanner.h:238
int readCharEx(const char *message=0)
Definition: EasyScanner.h:181
int symbolValue
Definition: EasyScanner.h:242
void readLFEOFex(const char *message=0)
Definition: EasyScanner.h:233
bool isEOF()
Definition: EasyScanner.h:125
boost::shared_ptr< SymbolMap > SymbolMapPtr
Definition: EasyScanner.h:44
std::string filename
Definition: EasyScanner.h:249
Definition: EasyScanner.h:38
const std::string & readStringEx(const char *message=0)
Definition: EasyScanner.h:209
std::string defaultErrorMessage
Definition: EasyScanner.h:244
int lineNumber
Definition: EasyScanner.h:245
std::string message
Definition: EasyScanner.h:31
std::string str(const Vector3 &v)
Definition: EigenUtil.cpp:90
float floatValue
Definition: EasyScanner.h:239
const std::string & readWordEx(const char *message=0)
Definition: EasyScanner.h:196
std::string stringValue
Definition: EasyScanner.h:240
int readSymbolEx(const char *message=0)
Definition: EasyScanner.h:222
Definition: EasyScanner.h:25
Definition: EasyScanner.h:29
double readDoubleEx(const char *message=0)
Definition: EasyScanner.h:165
Defines the minimum processing for performing pasing file for STL.
Definition: AbstractSceneLoader.h:9
int getSymbolID(const std::string &symbol)
Definition: EasyScanner.h:59
bool readString(const int delimiterChar= ',')
Definition: EasyScanner.h:107
float readFloatEx(const char *message=0)
Definition: EasyScanner.h:173
bool readString(const std::string &str)
Definition: EasyScanner.h:114
bool readLFEOF()
Definition: EasyScanner.h:136
Definition: EasyScanner.h:39
#define CNOID_EXPORT
Definition: Util/exportdecl.h:37
std::string filename
Definition: EasyScanner.h:32
TokenType
Definition: EasyScanner.h:37
int readIntEx(const char *message=0)
Definition: EasyScanner.h:157
char * text
Definition: EasyScanner.h:247
Definition: EasyScanner.h:21
void readLFex(const char *message=0)
Definition: EasyScanner.h:229
void checkStringEx(const char *str, const char *message=0)
Definition: EasyScanner.h:201
int lineNumber
Definition: EasyScanner.h:33