Go to the documentation of this file.
36 iOstream&
operator<<(iOstream& os,
const token& tok);
115 return token(punctuationToken::END_LIST);
120 return token(punctuationToken::BEGIN_LIST);
125 return token(punctuationToken::END_STATEMENT);
130 return token(punctuationToken::BEGIN_BLOCK);
135 return token(punctuationToken::END_BLOCK);
140 return token(punctuationToken::BEGIN_SQR);
145 return token(punctuationToken::END_SQR);
150 return token(punctuationToken::SPACE);
155 return token(punctuationToken::NL);
205 inline constexpr
token() noexcept;
258 inline static
token boolean(
bool on);
300 inline
bool good() const;
306 inline
bool error() const;
309 inline
bool isBool() const;
312 inline
bool isFlag() const;
339 inline
bool isReal() const;
345 inline
bool isWord() const;
426 inline
void operator=(const
token& tok);
429 inline
void operator=(
token&& tok);
435 inline
void operator=(const
int64 val);
438 inline
void operator=(const
int32 val);
441 inline
void operator=(const
float val);
444 inline
void operator=(const
double val);
447 inline
void operator=(const
word& w);
452 inline
void operator=(
word&& w);
457 inline
bool operator==(const
token& tok) const;
459 inline
bool operator==(const
int64 val) const;
460 inline
bool operator==(const
int32 val) const;
461 inline
bool operator==(const
float val) const;
462 inline
bool operator==(const
double val) const;
463 inline
bool operator==(const
word& w) const;
468 inline
bool operator!=(const
token& tok) const;
470 inline
bool operator!=(const
int64 val) const;
471 inline
bool operator!=(const
int32 val) const;
472 inline
bool operator!=(const
float val) const;
473 inline
bool operator!=(const
double val) const;
474 inline
bool operator!=(const
word& w) const;
478 std::ostream&
printInfo(std::ostream& os)const;
486 friend std::ostream& operator<<(std::ostream& os, const
token& tok);
487 friend std::ostream& operator<<(std::ostream& os, const
punctuationToken& pt);
489 void operator=(
word*) = delete;
500 std::ostream& operator<<(std::ostream& os, const
token& tok);
static token beginBlock()
void parseError(const char *expected) const
Parse error, expected 'expected', found ...
bool setType(const tokenType tokType)
Change the token type, for similar types.
@ PUNCTUATION
stream flag (1-byte bitmask)
bool isBool() const
Token is BOOL.
tokenType type() const
Return the token type.
Token class based on OpenFOAM stream, with some modifications/simplifications to be tailored to our n...
bool undefined() const
Token is UNDEFINED.
content data_
The data content (as a union).
punctuationToken pToken() const
Return punctuation character.
bool isFloat() const
Token is float.
token endStatementToken()
punctuationToken
Standard punctuation tokens (a character)
bool isEndBlock() const
Token is end endBlock.
bool isPunctuation() const
Token is PUNCTUATION.
const word & stringToken() const
Return const reference to the string contents.
@ END_BLOCK
Begin block [isseparator].
bool error() const
Token is ERROR.
bool good() const
True if token is not UNDEFINED or ERROR.
@ FLOAT
int64 (integer) type
bool isDouble() const
Token is double.
real number() const
Return int64, float or double value.
bool isVariable() const
Token is VARIABLE (string variant)
@ DOUBLE
float (single-precision) type
int64 int64Token() const
Return int64 value.
bool isSeparator() const
Token is PUNCTUATION and isseparator.
flagType
Stream or output control flags (1-byte width)
punctuationToken punctuationVal
bool boolToken() const
Return boolean token value.
bool isStringType() const
Token is WORD, DIRECTIVE, STRING, VARIABLE or VERBATIM.
@ BEGIN_BLOCK
End dimensions [isseparator].
@ ERROR
A dictionary $variable (string variant)
@ SQUOTE
Dollar - start variable.
void setUndefined()
Set as UNDEFINED and zero the union content without any checking.
@ BOOL
single character punctuation
static token beginSquare()
int flagToken() const
Return flag bitmask value.
void reset()
Reset token to UNDEFINED and clear any allocated storage.
constexpr token() noexcept
Default construct, initialized to an UNDEFINED token.
double doubleToken() const
Return double value.
Interface class for any input stream
real realToken() const
Return float or double value.
static bool isseparator(int c)
True if the character is a punctuation separator (eg, in ISstream).
int32 lineNumber_
Line number in the file the token was read from.
@ WORD
double (double-precision) type
@ UNDEFINED
An undefined token-type.
iOstream & printInfo(iOstream &os) const
static token flag(int bitmask)
Create a token with stream flags, no sanity check.
@ BEGIN_STRING
Divide [isseparator].
@ VARIABLE
A dictionary #directive (word variant)
@ END_LIST
Begin list [isseparator].
@ DOLLAR
Comma [isseparator].
float floatToken() const
Return float value.
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
bool isInt64() const
Token is int64.
@ COLON
End block [isseparator].
bool isInt32() const
Token is int32.
@ END_STATEMENT
Newline [isspace].
bool isFlag() const
Token is FLAG.
static const token undefinedToken()
An undefined token.
tokenType
Enumeration defining the types of token.
@ BEGIN_LIST
End entry [isseparator].
void swap(token &tok)
Swap token contents: type, data, line-number.
@ BEGIN_SQR
End list [isseparator].
@ DIVIDE
Subtract or start of negative number.
unsigned long long int uint64
@ COMMA
Colon [isseparator].
word name() const
Return the name of the token type.
@ END_STRING
Begin string with double quote.
static token endStatement()
tokenType type_
The token type.
bool isNumber() const
Token is int, float or duble.
bool isEndStatement() const
Token is end statement.
bool isDirective() const
Token is DIRECTIVE (word variant)
int32 int32Token() const
Return int32 value.
@ DIRECTIVE
A string whth double quuote.
Interface class for any output stream.
@ END_SQR
Begin dimensions [isseparator].
const word & wordToken() const
Return const reference to the word contents.
void setBad()
Clear token and set to be ERROR.
bool isString() const
Token is STRING, VARIABLE or VERBATIM string.
int32 lineNumber() const
The line number for the token.
@ BINARY
ASCII-mode stream.
bool isReal() const
Token is float or double.
bool isWord() const
Token is word or DIRECTIVE word.