52 std :: string x = this->
readToken(pos, line,
'"');
53 if ( line [ pos ] ==
'"' ) {
56 OOFEM_WARNING(
"Missing closing separator (\") inserted at end of line");
65 std :: string x = this->
readToken(pos, line,
'}');
66 if ( line [ pos ] ==
'}' ) {
69 OOFEM_WARNING(
"Missing closing separator (}) inserted at end of line");
78 std :: string x = this->
readToken(pos, line,
'$');
79 if ( line [ pos ] ==
'$' ) {
82 OOFEM_WARNING(
"Missing closing separator (\"$\") inserted at end of line");
91 std :: size_t startpos = pos;
92 while ( pos < line.size() && !isspace(line [ pos ]) ) {
95 return line.substr(startpos, pos - startpos);
102 std :: size_t startpos = pos;
103 while ( pos < line.size() && line [ pos ] != sep ) {
106 return line.substr(startpos, pos - startpos);
112 std :: list< std :: string >sList;
113 std :: size_t bpos = 0;
117 while ( bpos < currentLine.size() ) {
118 c = currentLine [ bpos ];
123 }
else if ( c ==
'"' ) {
125 }
else if ( c ==
'{' ) {
127 }
else if ( c ==
'$' ) {
136 this->
tokens.reserve(nTokens);
137 std :: copy( sList.begin(), sList.end(), std :: back_inserter(
tokens) );
143 return (
int )
tokens.size();
150 if ( i <= (
int )
tokens.size() ) {
151 return tokens [ i - 1 ].c_str();
std::string readSimpleExpressionToken(std::size_t &pos, const std::string &line)
Reads next simple expression token (section identified by starting with '$' and finishing with '$')...
Tokenizer()
Constructor. Creates tokenizer with given character as separator.
std::string readSimpleToken(std::size_t &pos, const std::string &line)
Reads next simple token (stops when whitespace character is reached)
std::string readToken(std::size_t &pos, const std::string &line, char sep)
Reads next token (stops when separator is reached)
const char * giveToken(int i)
Returns pointer to i-th token.
void tokenizeLine(const std::string &line)
Tokenizes given record (string).
std::vector< std::string > tokens
Array of tokens.
std::string readStructToken(std::size_t &pos, const std::string &line)
Reads next structured token (bounded by '{' '}' pairs, possibly nested).
the oofem namespace is to define a context or scope in which all oofem names are defined.
#define OOFEM_WARNING(...)
int giveNumberOfTokens()
returns the number of tokens.
std::string readStringToken(std::size_t &pos, const std::string &line)
Reads next string token (quoted).