44 case token::tokenType::UNDEFINED:
45 os <<
"undefined token";
48 case token::tokenType::BOOL:
49 os <<
"bool '" << (tok.
boolToken() ?
"true" :
"false") <<
'\'';
52 case token::tokenType::FLAG:
53 os <<
"flag '" << int(tok.
flagToken()) <<
'\'';
56 case token::tokenType::PUNCTUATION:
57 os <<
"punctuation '" << tok.
pToken() <<
'\'';
60 case token::tokenType::INTEGER_32:
64 case token::tokenType::INTEGER_64:
68 case token::tokenType::UNSIGNED_INTEGER_32:
72 case token::tokenType::UNSIGNED_INTEGER_64:
76 case token::tokenType::FLOAT:
80 case token::tokenType::DOUBLE:
84 case token::tokenType::WORD:
85 os <<
"word '" << tok.
wordToken() <<
'\'';
88 case token::tokenType::DIRECTIVE:
89 os <<
"directive '" << tok.
wordToken() <<
'\'';
92 case token::tokenType::STRING:
96 case token::tokenType::EXPRESSION:
100 case token::tokenType::VARIABLE:
104 case token::tokenType::VERBATIM:
108 case token::tokenType::CHAR_DATA:
112 case token::tokenType::COMPOUND:
122 os <<
"compound of type " 127 case token::tokenType::ERROR:
132 os <<
"unknown token type '" << int(tok.
type()) <<
'\'';
170 case token::tokenType::UNDEFINED:
return "undefined";
171 case token::tokenType::BOOL:
return "bool";
172 case token::tokenType::FLAG:
return "flag";
173 case token::tokenType::PUNCTUATION:
return "punctuation";
175 case token::tokenType::INTEGER_32:
return "int32";
176 case token::tokenType::INTEGER_64:
return "int64";
177 case token::tokenType::UNSIGNED_INTEGER_32:
return "uint32";
178 case token::tokenType::UNSIGNED_INTEGER_64:
return "uint64";
179 case token::tokenType::FLOAT:
return "float";
180 case token::tokenType::DOUBLE:
return "double";
181 case token::tokenType::WORD:
return "word";
182 case token::tokenType::DIRECTIVE:
return "directive";
183 case token::tokenType::STRING:
return "string";
184 case token::tokenType::EXPRESSION:
return "expression";
185 case token::tokenType::VARIABLE:
return "variable";
186 case token::tokenType::VERBATIM:
return "verbatim";
187 case token::tokenType::CHAR_DATA:
return "char_data";
188 case token::tokenType::COMPOUND:
return "compound";
189 case token::tokenType::ERROR:
return "error";
195 return "unknown(" + std::to_string(
int(tokType)) +
")";
212 case token::tokenType::UNDEFINED:
215 <<
"Undefined token" <<
endl;
218 case token::tokenType::FLAG:
222 case token::tokenType::PUNCTUATION:
223 os << tok.data_.punctuationVal;
226 case token::tokenType::BOOL:
227 os << tok.data_.flagVal;
230 case token::tokenType::INTEGER_32:
231 os << tok.data_.int32Val;
234 case token::tokenType::INTEGER_64:
235 os << tok.data_.int64Val;
238 case token::tokenType::UNSIGNED_INTEGER_32:
239 os << tok.data_.uint32Val;
242 case token::tokenType::UNSIGNED_INTEGER_64:
243 os << tok.data_.uint64Val;
246 case token::tokenType::FLOAT:
247 os << tok.data_.floatVal;
250 case token::tokenType::DOUBLE:
251 os << tok.data_.doubleVal;
256 case token::tokenType::DIRECTIVE:
257 case token::tokenType::EXPRESSION:
258 case token::tokenType::VARIABLE:
259 case token::tokenType::VERBATIM:
260 case token::tokenType::CHAR_DATA:
264 case token::tokenType::WORD:
265 os << *tok.data_.wordPtr;
268 case token::tokenType::STRING:
269 os << *tok.data_.stringPtr;
272 case token::tokenType::COMPOUND:
273 os << *tok.data_.compoundPtr;
276 case token::tokenType::ERROR:
279 <<
"Error token" <<
endl;
285 <<
"Unknown token" <<
endl;
295 return os << char(pt);
301 return os << char(pt);
321 ostream& Foam::operator<<
324 const InfoProxy<token>& iproxy
335 const InfoProxy<token>& iproxy
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
punctuationToken pToken() const
Return punctuation character.
constexpr token() noexcept
Default construct, initialized to an UNDEFINED token.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
const word & wordToken() const
Return const reference to the word contents.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
A token holds an item read from Istream.
tokenType
Enumeration defining the types of token.
bool moved() const noexcept
Get compound transferred status.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tokenType type() const noexcept
Return the token type.
static OS & printTokenInfo(OS &os, const token &tok)
int32_t int32Token() const
Return int32 value, convert from other integer type or Error.
float floatToken() const
Return float value.
bool boolToken() const
Return boolean token value.
word name() const
Return the name of the current token type.
#define SeriousErrorInFunction
Report an error message using Foam::SeriousError.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
int flagToken() const
Return flag bitmask value.
label lineNumber() const noexcept
The line number for the token.
virtual Istream & read(token &)=0
Return next token from stream.
double doubleToken() const
Return double value.
A class for handling words, derived from Foam::string.
Istream & operator>>(Istream &, directionInfo &)
punctuationToken
Standard punctuation tokens (a character)
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
const compound & compoundToken() const
Const reference to compound token. Fatal if the wrong type.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
uint32_t uint32Token() const
Return int32 value, convert from other integer type or Error.
const string & stringToken() const
Return const reference to the string contents.
int64_t int64Token() const
Return int64 value, convert from other integer type or Error.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
void reset()
Reset token to UNDEFINED and clear any allocated storage.
bool read(Istream &is)
Read a token from Istream, calls reset() first.
#define WarningInFunction
Report a warning using Foam::Warning.
uint64_t uint64Token() const
Return int64 value, convert from other integer type or Error.
bool good() const noexcept
True if next operation might succeed.
bool pending() const noexcept
Get compound pending-read status.