token Class Reference

A token holds an item read from Istream. More...

Collaboration diagram for token:

Classes

class  Compound
 A templated class for holding compound tokens. The underlying container is normally a List of values, it must have a value_type typedef as well as size(), resize(), cdata_bytes(), data_bytes(), size_bytes() methods. More...
 
class  compound
 Abstract base class for complex tokens. More...
 

Public Types

enum  tokenType : char {
  UNDEFINED = '\0', ERROR = '\x80', FLAG, PUNCTUATION,
  BOOL, LABEL, FLOAT, DOUBLE,
  WORD, STRING, COMPOUND, DIRECTIVE,
  EXPRESSION, VARIABLE, VERBATIM, CHAR_DATA,
  FLOAT_SCALAR = FLOAT, DOUBLE_SCALAR = DOUBLE, VERBATIMSTRING = VERBATIM
}
 Enumeration defining the types of token. More...
 
enum  flagType { NO_FLAG = 0, ASCII = 1, BINARY = 2 }
 Stream or output control flags (1-byte width) More...
 
enum  punctuationToken : char {
  NULL_TOKEN = '\0', TAB = '\t', NL = '\n', SPACE = ' ',
  COLON = ':', SEMICOLON = ';', COMMA = ',', HASH = '#',
  DOLLAR = '$', QUESTION = '?', ATSYM = '@', SQUOTE = '\'',
  DQUOTE = '"', ASSIGN = '=', PLUS = '+', MINUS = '-',
  MULTIPLY = '*', DIVIDE = '/', LPAREN = '(', RPAREN = ')',
  LSQUARE = '[', RSQUARE = ']', LBRACE = '{', RBRACE = '}',
  ADD = PLUS, SUBTRACT = MINUS, END_STATEMENT = SEMICOLON, BEGIN_LIST = LPAREN,
  END_LIST = RPAREN, BEGIN_SQR = LSQUARE, END_SQR = RSQUARE, BEGIN_BLOCK = LBRACE,
  END_BLOCK = RBRACE, BEGIN_STRING = DQUOTE, END_STRING = DQUOTE
}
 Standard punctuation tokens (a character) More...
 

Public Member Functions

constexpr token () noexcept
 Default construct, initialized to an UNDEFINED token. More...
 
 token (const token &t)
 Copy construct. More...
 
 token (token &&t) noexcept
 Move construct. The original token is left as UNDEFINED. More...
 
 token (punctuationToken p, label lineNum=0) noexcept
 Construct punctuation character token. More...
 
 token (const label val, label lineNum=0) noexcept
 Construct label token. More...
 
 token (const float val, label lineNum=0) noexcept
 Construct float token. More...
 
 token (const double val, label lineNum=0) noexcept
 Construct double token. More...
 
 token (const word &w, label lineNum=0)
 Copy construct word token. More...
 
 token (const string &str, label lineNum=0)
 Copy construct string token. More...
 
 token (word &&w, label lineNum=0)
 Move construct word token. More...
 
 token (string &&str, label lineNum=0)
 Move construct string token. More...
 
 token (tokenType typ, const std::string &, label line=0)
 Copy construct word/string token with the specified variant. More...
 
 token (tokenType typ, std::string &&, label line=0)
 Copy construct word/string token with the specified variant. More...
 
 token (token::compound *ptr, label lineNum=0)
 Construct from a compound pointer, taking ownership. More...
 
 token (autoPtr< token::compound > &&ptr, label lineNum=0)
 Move construct from a compound pointer, taking ownership. More...
 
 token (Istream &is)
 Construct from Istream. More...
 
 ~token ()
 Destructor. More...
 
word name () const
 Return the name of the current token type. More...
 
tokenType type () const noexcept
 Return the token type. More...
 
bool setType (const tokenType tokType) noexcept
 Change the token type, for similar types. More...
 
label lineNumber () const noexcept
 The line number for the token. More...
 
label lineNumber (const label lineNum) noexcept
 Change token line number, return old value. More...
 
bool good () const noexcept
 True if token is not UNDEFINED or ERROR. More...
 
bool undefined () const noexcept
 Token is UNDEFINED. More...
 
bool error () const noexcept
 Token is ERROR. More...
 
bool isBool () const noexcept
 Token is BOOL. More...
 
bool isFlag () const noexcept
 Token is FLAG. More...
 
bool isPunctuation () const noexcept
 Token is PUNCTUATION. More...
 
bool isPunctuation (const punctuationToken p) const noexcept
 True if token is PUNCTUATION and equal to parameter. More...
 
bool isSeparator () const noexcept
 Token is PUNCTUATION and isseparator. More...
 
bool isLabel () const noexcept
 Token is LABEL. More...
 
bool isLabel (const label val) const noexcept
 True if token is LABEL and equal to parameter. More...
 
bool isFloat () const noexcept
 Token is FLOAT. More...
 
bool isDouble () const noexcept
 Token is DOUBLE. More...
 
bool isScalar () const noexcept
 Token is FLOAT or DOUBLE. More...
 
bool isNumber () const noexcept
 Token is LABEL, FLOAT or DOUBLE. More...
 
bool isWord () const noexcept
 Token is word-variant (WORD, DIRECTIVE) More...
 
bool isWord (const std::string &s) const
 Token is word-variant and equal to parameter. More...
 
bool isDirective () const noexcept
 Token is DIRECTIVE (word variant) More...
 
bool isQuotedString () const noexcept
 Token is (quoted) STRING (string variant) More...
 
bool isString () const noexcept
 Token is string-variant (STRING, EXPRESSION, VARIABLE, VERBATIM, CHAR_DATA) More...
 
bool isExpression () const noexcept
 Token is EXPRESSION (string variant) More...
 
bool isVariable () const noexcept
 Token is VARIABLE (string variant) More...
 
bool isVerbatim () const noexcept
 Token is VERBATIM string (string variant) More...
 
bool isCharData () const noexcept
 Token is CHAR_DATA (string variant) More...
 
bool isStringType () const noexcept
 Token is word-variant or string-variant (WORD, DIRECTIVE, STRING, EXPRESSION, VARIABLE, VERBATIM, CHAR_DATA) More...
 
bool isCompound () const noexcept
 Token is COMPOUND. More...
 
bool isCompound (const word &compoundType) const
 True if token is COMPOUND and its type() is equal to parameter. More...
 
template<class Type >
const Type * isCompound () const
 If token is COMPOUND and can be dynamic_cast to the Type return a const pointer to the content. More...
 
 operator bool () const noexcept
 True if token is not UNDEFINED or ERROR. Same as good(). More...
 
bool boolToken () const
 Return boolean token value. More...
 
int flagToken () const
 Return flag bitmask value. More...
 
punctuationToken pToken () const
 Return punctuation character. More...
 
label labelToken () const
 Return label value. More...
 
float floatToken () const
 Return float value. More...
 
double doubleToken () const
 Return double value. More...
 
scalar scalarToken () const
 Return float or double value. More...
 
scalar number () const
 Return label, float or double value. More...
 
const wordwordToken () const
 Return const reference to the word contents. More...
 
const stringstringToken () const
 Return const reference to the string contents. More...
 
const compoundcompoundToken () const
 Const reference to compound token. Fatal if the wrong type. More...
 
compoundrefCompoundToken ()
 Return reference to compound token. Fatal if the wrong type. More...
 
bool readCompoundToken (const word &compoundType, Istream &is, const bool readContent=true)
 Default construct the specified compound type and read from stream. More...
 
compoundtransferCompoundToken (const Istream *is=nullptr)
 Return reference to compound and mark internally as released. More...
 
compoundtransferCompoundToken (const Istream &is)
 Return reference to compound and mark internally as released. More...
 
template<class Type >
Type & transferCompoundToken (const Istream &is)
 Mark the compound as released and return a reference to the underlying encapsulated container - eg, List<label> More...
 
void reset ()
 Reset token to UNDEFINED and clear any allocated storage. More...
 
void setBad ()
 Clear token and set to be ERROR. More...
 
void swap (token &tok) noexcept
 Swap token contents: type, data, line-number. More...
 
InfoProxy< tokeninfo () const noexcept
 Return info proxy, for printing token information to a stream. More...
 
void operator= (const token &tok)
 Copy assign. More...
 
void operator= (token &&tok)
 Move assign. More...
 
void operator= (const punctuationToken p)
 Copy assign from punctuation. More...
 
void operator= (const label val)
 Copy assign from label. More...
 
void operator= (const float val)
 Copy assign from float. More...
 
void operator= (const double val)
 Copy assign from double. More...
 
void operator= (const word &w)
 Copy assign from word content. More...
 
void operator= (const string &str)
 Copy assign from string content. More...
 
void operator= (word &&w)
 Move assign from word content. More...
 
void operator= (string &&str)
 Move assign from string content. More...
 
void operator= (token::compound *ptr)
 Assign compound with reference counting to token. More...
 
void operator= (autoPtr< token::compound > &&ptr)
 Move assign from compound pointer. More...
 
bool operator== (const token &tok) const
 
bool operator== (const punctuationToken p) const noexcept
 
bool operator== (const label val) const noexcept
 
bool operator== (const float val) const noexcept
 
bool operator== (const double val) const noexcept
 
bool operator== (const std::string &s) const
 
bool operator!= (const token &tok) const
 
bool operator!= (const punctuationToken p) const noexcept
 
bool operator!= (const label val) const noexcept
 
bool operator!= (const float val) const noexcept
 
bool operator!= (const double val) const noexcept
 
bool operator!= (const std::string &s) const
 
label & lineNumber () noexcept
 Write access for the token line number. More...
 
bool isFloatScalar () const
 Token is FLOAT. More...
 
bool isDoubleScalar () const
 Token is DOUBLE. More...
 
float floatScalarToken () const
 Return float value. More...
 
double doubleScalarToken () const
 Return double value. More...
 
void operator= (word *)=delete
 Deprecated(2017-11) transfer word pointer to the token. More...
 
void operator= (string *)=delete
 Deprecated(2017-11) transfer string pointer to the token. More...
 

Static Public Member Functions

static token boolean (bool on) noexcept
 Create a bool token. More...
 
static token flag (int bitmask) noexcept
 Create a token with stream flags, no sanity check. More...
 
static bool isseparator (int c) noexcept
 True if the character is a punctuation separator (eg, in ISstream). More...
 
static word name (const token::tokenType tokType)
 Return the name for the token type. More...
 

Static Public Attributes

static const token undefinedToken
 An undefined token. More...
 
static constexpr const char *const typeName = "token"
 The type name is "token". More...
 

Friends

Ostreamoperator<< (Ostream &os, const token &tok)
 
Ostreamoperator<< (Ostream &os, const punctuationToken &pt)
 
ostream & operator<< (ostream &os, const punctuationToken &pt)
 
ostream & operator<< (ostream &os, const InfoProxy< token > &ip)
 

Detailed Description

A token holds an item read from Istream.

Source files

Definition at line 65 of file token.H.

Member Enumeration Documentation

◆ tokenType

enum tokenType : char

Enumeration defining the types of token.

Since the enumeration is used to tag content in Pstream, it is of type char and shall have values that do not overlap with regular punctuation characters.

Enumerator
UNDEFINED 

An undefined token-type.

ERROR 

Token error encountered.

FLAG 

stream flag (1-byte bitmask)

PUNCTUATION 

single character punctuation

BOOL 

boolean type

LABEL 

label (integer) type

FLOAT 

float (single-precision) type

DOUBLE 

double (double-precision) type

WORD 

Foam::word.

STRING 

Foam::string (usually double-quoted)

COMPOUND 

Compound type such as List<label> etc.

DIRECTIVE 

Word-variant: dictionary #directive stored with sigil

EXPRESSION 

String-variant: math expression for evaluation stored with delimiters

VARIABLE 

String-variant: dictionary $variable stored with sigil

VERBATIM 

String-variant: verbatim string content stored without delimiters

CHAR_DATA 

String-variant: plain character content.

FLOAT_SCALAR 
DOUBLE_SCALAR 
VERBATIMSTRING 

Definition at line 76 of file token.H.

◆ flagType

enum flagType

Stream or output control flags (1-byte width)

Enumerator
NO_FLAG 

No flags.

ASCII 

ASCII-mode stream.

BINARY 

BINARY-mode stream.

Definition at line 115 of file token.H.

◆ punctuationToken

enum punctuationToken : char

Standard punctuation tokens (a character)

Enumerator
NULL_TOKEN 

Nul character.

TAB 

Tab [isspace].

NL 

Newline [isspace].

SPACE 

Space [isspace].

COLON 

Colon [isseparator].

SEMICOLON 

Semicolon [isseparator].

COMMA 

Comma [isseparator].

HASH 

Hash - directive or start verbatim string.

DOLLAR 

Dollar - start variable or expression.

QUESTION 

Question mark (eg, ternary)

ATSYM 

The 'at' symbol.

SQUOTE 

Single quote.

DQUOTE 

Double quote.

ASSIGN 

Assignment/equals [isseparator].

PLUS 

Addition [isseparator].

MINUS 

Subtract or start of negative number.

MULTIPLY 

Multiply [isseparator].

DIVIDE 

Divide [isseparator].

LPAREN 

Left parenthesis [isseparator].

RPAREN 

Right parenthesis [isseparator].

LSQUARE 

Left square bracket [isseparator].

RSQUARE 

Right square bracket [isseparator].

LBRACE 

Left brace [isseparator].

RBRACE 

Right brace [isseparator].

ADD 

Addition [isseparator].

SUBTRACT 

Subtract or start of negative number.

END_STATEMENT 

End entry [isseparator].

BEGIN_LIST 

Begin list [isseparator].

END_LIST 

End list [isseparator].

BEGIN_SQR 

Begin dimensions [isseparator].

END_SQR 

End dimensions [isseparator].

BEGIN_BLOCK 

Begin block [isseparator].

END_BLOCK 

End block [isseparator].

BEGIN_STRING 

Begin string with double quote.

END_STRING 

End string with double quote.

Definition at line 126 of file token.H.

Constructor & Destructor Documentation

◆ token() [1/16]

constexpr token ( )
inlinenoexcept

Default construct, initialized to an UNDEFINED token.

Definition at line 113 of file tokenI.H.

◆ token() [2/16]

token ( const token t)
inline

Copy construct.

Definition at line 121 of file tokenI.H.

◆ token() [3/16]

token ( token &&  t)
inlinenoexcept

Move construct. The original token is left as UNDEFINED.

Definition at line 165 of file tokenI.H.

◆ token() [4/16]

token ( punctuationToken  p,
label  lineNum = 0 
)
inlineexplicitnoexcept

Construct punctuation character token.

Definition at line 176 of file tokenI.H.

References p.

◆ token() [5/16]

token ( const label  val,
label  lineNum = 0 
)
inlineexplicitnoexcept

Construct label token.

Definition at line 186 of file tokenI.H.

◆ token() [6/16]

token ( const float  val,
label  lineNum = 0 
)
inlineexplicitnoexcept

Construct float token.

Definition at line 196 of file tokenI.H.

◆ token() [7/16]

token ( const double  val,
label  lineNum = 0 
)
inlineexplicitnoexcept

Construct double token.

Definition at line 206 of file tokenI.H.

◆ token() [8/16]

token ( const word w,
label  lineNum = 0 
)
inlineexplicit

Copy construct word token.

Definition at line 216 of file tokenI.H.

◆ token() [9/16]

token ( const string str,
label  lineNum = 0 
)
inlineexplicit

Copy construct string token.

Definition at line 226 of file tokenI.H.

◆ token() [10/16]

token ( word &&  w,
label  lineNum = 0 
)
inlineexplicit

Move construct word token.

Definition at line 236 of file tokenI.H.

◆ token() [11/16]

token ( string &&  str,
label  lineNum = 0 
)
inlineexplicit

Move construct string token.

Definition at line 246 of file tokenI.H.

◆ token() [12/16]

token ( tokenType  typ,
const std::string &  str,
label  line = 0 
)
inlineexplicit

Copy construct word/string token with the specified variant.

A invalid word/string variant type is silently treated as STRING. No character stripping

Definition at line 257 of file tokenI.H.

◆ token() [13/16]

token ( tokenType  typ,
std::string &&  str,
label  line = 0 
)
inlineexplicit

Copy construct word/string token with the specified variant.

A invalid word/string variant type is silently treated as STRING. No character stripping

Definition at line 281 of file tokenI.H.

◆ token() [14/16]

token ( token::compound ptr,
label  lineNum = 0 
)
inlineexplicit

Construct from a compound pointer, taking ownership.

Definition at line 304 of file tokenI.H.

◆ token() [15/16]

token ( autoPtr< token::compound > &&  ptr,
label  lineNum = 0 
)
inlineexplicit

Move construct from a compound pointer, taking ownership.

Definition at line 319 of file tokenI.H.

◆ token() [16/16]

token ( Istream is)
explicit

Construct from Istream.

Definition at line 124 of file tokenIO.C.

References Istream::read().

Here is the call graph for this function:

◆ ~token()

~token ( )
inline

Destructor.

Definition at line 327 of file tokenI.H.

Member Function Documentation

◆ boolean()

Foam::token boolean ( bool  on)
inlinestaticnoexcept

Create a bool token.

Definition at line 26 of file tokenI.H.

Referenced by Foam::fillTokens< bool >().

Here is the caller graph for this function:

◆ flag()

Foam::token flag ( int  bitmask)
inlinestaticnoexcept

Create a token with stream flags, no sanity check.

Parameters
bitmaskthe flags to set

Definition at line 36 of file tokenI.H.

◆ isseparator()

bool isseparator ( int  c)
inlinestaticnoexcept

True if the character is a punctuation separator (eg, in ISstream).

Since it could also start a number, SUBTRACT is not included as a separator.

Parameters
cthe character to test, passed as int for consistency with isdigit, isspace etc.

Definition at line 69 of file tokenI.H.

References Foam::constant::universal::c.

◆ name() [1/2]

Foam::word name ( const token::tokenType  tokType)
static

Return the name for the token type.

Definition at line 134 of file tokenIO.C.

◆ name() [2/2]

Foam::word name ( ) const
inline

Return the name of the current token type.

Definition at line 399 of file tokenI.H.

◆ type()

Foam::token::tokenType type ( ) const
inlinenoexcept

Return the token type.

Definition at line 405 of file tokenI.H.

Referenced by Foam::printTokenInfo(), OSstream::write(), and UOPstreamBase::write().

Here is the caller graph for this function:

◆ setType()

bool setType ( const tokenType  tokType)
inlinenoexcept

Change the token type, for similar types.

This can be used to change between string-like variants (eg, STRING, VARIABLE, etc) To change types entirely (eg, STRING to DOUBLE), use the corresponding assignment operator.

Returns
true if the change was successful or no change was required

Definition at line 411 of file tokenI.H.

Referenced by UIPstreamBase::read(), ISstream::read(), and exprString::writeEntry().

Here is the caller graph for this function:

◆ lineNumber() [1/3]

Foam::label lineNumber ( ) const
inlinenoexcept

The line number for the token.

Definition at line 493 of file tokenI.H.

Referenced by Foam::printTokenInfo(), UIPstreamBase::read(), ISstream::read(), and ITstream::read().

Here is the caller graph for this function:

◆ lineNumber() [2/3]

Foam::label lineNumber ( const label  lineNum)
inlinenoexcept

Change token line number, return old value.

Definition at line 499 of file tokenI.H.

◆ good()

◆ undefined()

bool undefined ( ) const
inlinenoexcept

Token is UNDEFINED.

Definition at line 513 of file tokenI.H.

◆ error()

bool error ( ) const
inlinenoexcept

Token is ERROR.

Definition at line 519 of file tokenI.H.

◆ isBool()

bool isBool ( ) const
inlinenoexcept

Token is BOOL.

Definition at line 525 of file tokenI.H.

Referenced by Switch::Switch().

Here is the caller graph for this function:

◆ isFlag()

bool isFlag ( ) const
inlinenoexcept

Token is FLAG.

Definition at line 543 of file tokenI.H.

Referenced by UIPstreamBase::read().

Here is the caller graph for this function:

◆ isPunctuation() [1/2]

◆ isPunctuation() [2/2]

bool isPunctuation ( const punctuationToken  p) const
inlinenoexcept

True if token is PUNCTUATION and equal to parameter.

Definition at line 567 of file tokenI.H.

References p.

◆ isSeparator()

bool isSeparator ( ) const
inlinenoexcept

Token is PUNCTUATION and isseparator.

Definition at line 577 of file tokenI.H.

◆ isLabel() [1/2]

◆ isLabel() [2/2]

bool isLabel ( const label  val) const
inlinenoexcept

True if token is LABEL and equal to parameter.

Definition at line 605 of file tokenI.H.

◆ isFloat()

bool isFloat ( ) const
inlinenoexcept

Token is FLOAT.

Definition at line 627 of file tokenI.H.

Referenced by token::isFloatScalar().

Here is the caller graph for this function:

◆ isDouble()

bool isDouble ( ) const
inlinenoexcept

Token is DOUBLE.

Definition at line 645 of file tokenI.H.

Referenced by token::isDoubleScalar().

Here is the caller graph for this function:

◆ isScalar()

bool isScalar ( ) const
inlinenoexcept

Token is FLOAT or DOUBLE.

Definition at line 663 of file tokenI.H.

Referenced by Foam::operator>>(), and exprValue::peekType().

Here is the caller graph for this function:

◆ isNumber()

bool isNumber ( ) const
inlinenoexcept

◆ isWord() [1/2]

◆ isWord() [2/2]

bool isWord ( const std::string &  s) const
inline

Token is word-variant and equal to parameter.

Definition at line 717 of file tokenI.H.

References s.

◆ isDirective()

bool isDirective ( ) const
inlinenoexcept

Token is DIRECTIVE (word variant)

Definition at line 723 of file tokenI.H.

Referenced by ifeqEntry::evaluate(), and ifeqEntry::execute().

Here is the caller graph for this function:

◆ isQuotedString()

bool isQuotedString ( ) const
inlinenoexcept

Token is (quoted) STRING (string variant)

Definition at line 741 of file tokenI.H.

Referenced by fileName::assign(), keyType::assign(), wordRe::assign(), and Foam::operator>>().

Here is the caller graph for this function:

◆ isString()

bool isString ( ) const
inlinenoexcept

Token is string-variant (STRING, EXPRESSION, VARIABLE, VERBATIM, CHAR_DATA)

Definition at line 747 of file tokenI.H.

Referenced by Foam::exprTools::getList(), seriesWriter::load(), and Foam::operator>>().

Here is the caller graph for this function:

◆ isExpression()

bool isExpression ( ) const
inlinenoexcept

Token is EXPRESSION (string variant)

Definition at line 753 of file tokenI.H.

◆ isVariable()

bool isVariable ( ) const
inlinenoexcept

Token is VARIABLE (string variant)

Definition at line 759 of file tokenI.H.

Referenced by Foam::operator>>().

Here is the caller graph for this function:

◆ isVerbatim()

bool isVerbatim ( ) const
inlinenoexcept

Token is VERBATIM string (string variant)

Definition at line 765 of file tokenI.H.

◆ isCharData()

bool isCharData ( ) const
inlinenoexcept

Token is CHAR_DATA (string variant)

Definition at line 771 of file tokenI.H.

◆ isStringType()

bool isStringType ( ) const
inlinenoexcept

Token is word-variant or string-variant (WORD, DIRECTIVE, STRING, EXPRESSION, VARIABLE, VERBATIM, CHAR_DATA)

Definition at line 777 of file tokenI.H.

Referenced by functionEntry::readStringList(), and IOstreamOption::versionNumber::versionNumber().

Here is the caller graph for this function:

◆ isCompound() [1/3]

◆ isCompound() [2/3]

bool isCompound ( const word compoundType) const
inline

True if token is COMPOUND and its type() is equal to parameter.

Definition at line 809 of file tokenI.H.

◆ isCompound() [3/3]

const Type * isCompound ( ) const
inline

If token is COMPOUND and can be dynamic_cast to the Type return a const pointer to the content.

Return nullptr on any failure.

Definition at line 820 of file tokenI.H.

◆ operator bool()

operator bool ( ) const
inlineexplicitnoexcept

True if token is not UNDEFINED or ERROR. Same as good().

Definition at line 927 of file token.H.

References token::good().

Here is the call graph for this function:

◆ boolToken()

bool boolToken ( ) const
inline

Return boolean token value.

Report FatalIOError and return false if token is not BOOL or LABEL

Definition at line 531 of file tokenI.H.

Referenced by Foam::printTokenInfo(), and Switch::Switch().

Here is the caller graph for this function:

◆ flagToken()

int flagToken ( ) const
inline

Return flag bitmask value.

Report FatalIOError and return NO_FLAG if token is not FLAG

Definition at line 549 of file tokenI.H.

Referenced by Foam::printTokenInfo(), UIPstreamBase::read(), and UOPstreamBase::write().

Here is the caller graph for this function:

◆ pToken()

Foam::token::punctuationToken pToken ( ) const
inline

Return punctuation character.

Report FatalIOError and return \0 if token is not PUNCTUATION

Definition at line 587 of file tokenI.H.

Referenced by blockDescriptor::blockDescriptor(), seriesWriter::load(), Foam::operator>>(), Foam::printTokenInfo(), primitiveEntry::read(), Istream::readBeginList(), and Istream::readEndList().

Here is the caller graph for this function:

◆ labelToken()

◆ floatToken()

float floatToken ( ) const
inline

Return float value.

Report FatalIOError and return 0 if token is not FLOAT

Definition at line 633 of file tokenI.H.

Referenced by token::floatScalarToken(), and Foam::printTokenInfo().

Here is the caller graph for this function:

◆ doubleToken()

double doubleToken ( ) const
inline

Return double value.

Report FatalIOError and return 0 if token is not DOUBLE

Definition at line 651 of file tokenI.H.

Referenced by token::doubleScalarToken(), and Foam::printTokenInfo().

Here is the caller graph for this function:

◆ scalarToken()

Foam::scalar scalarToken ( ) const
inline

Return float or double value.

Report FatalIOError and return 0 if token is not a FLOAT or DOUBLE

Definition at line 673 of file tokenI.H.

Referenced by Foam::operator>>().

Here is the caller graph for this function:

◆ number()

Foam::scalar number ( ) const
inline

Return label, float or double value.

Report FatalIOError and return 0 if token is not a LABEL, FLOAT or DOUBLE

Definition at line 695 of file tokenI.H.

Referenced by arcEdge::arcEdge(), CrankNicolsonDdtScheme< Type >::CrankNicolsonDdtScheme(), seriesWriter::load(), Foam::operator>>(), dimensionSet::read(), Reaction< ReactionThermo >::specieCoeffs::specieCoeffs(), and IOstreamOption::versionNumber::versionNumber().

Here is the caller graph for this function:

◆ wordToken()

const Foam::word & wordToken ( ) const
inline

◆ stringToken()

const Foam::string & stringToken ( ) const
inline

Return const reference to the string contents.

Report FatalIOError and return "" if token is not a STRING, EXPRESSION, VARIABLE, VERBATIM, CHAR_DATA or an upcast WORD or DIRECTIVE

Definition at line 783 of file tokenI.H.

References string::null.

Referenced by fileName::assign(), keyType::assign(), wordRe::assign(), Foam::exprTools::getList(), seriesWriter::load(), Foam::operator>>(), Foam::printTokenInfo(), IOstreamOption::versionNumber::versionNumber(), functionEntry::write(), OSstream::write(), and UOPstreamBase::write().

Here is the caller graph for this function:

◆ compoundToken()

const Foam::token::compound & compoundToken ( ) const
inline

Const reference to compound token. Fatal if the wrong type.

Definition at line 831 of file tokenI.H.

Referenced by Foam::printTokenInfo().

Here is the caller graph for this function:

◆ refCompoundToken()

Foam::token::compound & refCompoundToken ( )
inline

Return reference to compound token. Fatal if the wrong type.

Definition at line 841 of file tokenI.H.

◆ readCompoundToken()

bool readCompoundToken ( const word compoundType,
Istream is,
const bool  readContent = true 
)

Default construct the specified compound type and read from stream.

A no-op and returns false if compound type is unknown. Modify the token and return true on success.

Definition at line 126 of file token.C.

References token::compound::read().

Referenced by Foam::readCompoundToken().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transferCompoundToken() [1/3]

Foam::token::compound & transferCompoundToken ( const Istream is = nullptr)

Return reference to compound and mark internally as released.

Optional Istream parameter only as reference for errors messages.

Definition at line 157 of file token.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::FatalIOError, and FatalIOErrorInFunction.

Referenced by mappedPatchBase::constructIOField(), List< Field< scalar > >::readList(), DynamicList< Foam::vector >::readList(), FixedList< point, 2 >::readList(), and UList< Foam::vector >::readList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transferCompoundToken() [2/3]

Foam::token::compound & transferCompoundToken ( const Istream is)
inline

Return reference to compound and mark internally as released.

The Istream is used for reference error messages only.

Definition at line 852 of file tokenI.H.

◆ transferCompoundToken() [3/3]

Type & transferCompoundToken ( const Istream is)
inline

Mark the compound as released and return a reference to the underlying encapsulated container - eg, List<label>

The Istream is used for reference error messages only.

Definition at line 859 of file tokenI.H.

◆ reset()

void reset ( )
inline

Reset token to UNDEFINED and clear any allocated storage.

Definition at line 335 of file tokenI.H.

Referenced by Foam::operator>>(), UIPstreamBase::read(), ISstream::read(), and ITstream::read().

Here is the caller graph for this function:

◆ setBad()

void setBad ( )
inline

Clear token and set to be ERROR.

Definition at line 379 of file tokenI.H.

Referenced by UIPstreamBase::read(), and ISstream::read().

Here is the caller graph for this function:

◆ swap()

void swap ( token tok)
inlinenoexcept

Swap token contents: type, data, line-number.

Definition at line 386 of file tokenI.H.

◆ info()

◆ operator=() [1/14]

void operator= ( const token tok)
inline

Copy assign.

Definition at line 917 of file tokenI.H.

◆ operator=() [2/14]

void operator= ( token &&  tok)
inline

Move assign.

Definition at line 968 of file tokenI.H.

◆ operator=() [3/14]

void operator= ( const punctuationToken  p)
inline

Copy assign from punctuation.

Definition at line 981 of file tokenI.H.

References p.

◆ operator=() [4/14]

void operator= ( const label  val)
inline

Copy assign from label.

Definition at line 989 of file tokenI.H.

◆ operator=() [5/14]

void operator= ( const float  val)
inline

Copy assign from float.

Definition at line 997 of file tokenI.H.

◆ operator=() [6/14]

void operator= ( const double  val)
inline

Copy assign from double.

Definition at line 1005 of file tokenI.H.

◆ operator=() [7/14]

void operator= ( const word w)
inline

Copy assign from word content.

Definition at line 1013 of file tokenI.H.

◆ operator=() [8/14]

void operator= ( const string str)
inline

Copy assign from string content.

Definition at line 1021 of file tokenI.H.

◆ operator=() [9/14]

void operator= ( word &&  w)
inline

Move assign from word content.

Definition at line 1029 of file tokenI.H.

◆ operator=() [10/14]

void operator= ( string &&  str)
inline

Move assign from string content.

Definition at line 1037 of file tokenI.H.

References s.

◆ operator=() [11/14]

void operator= ( token::compound ptr)
inline

Assign compound with reference counting to token.

Definition at line 1045 of file tokenI.H.

◆ operator=() [12/14]

void operator= ( autoPtr< token::compound > &&  ptr)
inline

Move assign from compound pointer.

Definition at line 1053 of file tokenI.H.

◆ operator==() [1/6]

bool operator== ( const token tok) const
inline

Definition at line 1061 of file tokenI.H.

References Foam::equal().

Here is the call graph for this function:

◆ operator==() [2/6]

bool operator== ( const punctuationToken  p) const
inlinenoexcept

Definition at line 1115 of file tokenI.H.

References p.

◆ operator==() [3/6]

bool operator== ( const label  val) const
inlinenoexcept

Definition at line 1132 of file tokenI.H.

◆ operator==() [4/6]

bool operator== ( const float  val) const
inlinenoexcept

Definition at line 1138 of file tokenI.H.

References Foam::equal().

Here is the call graph for this function:

◆ operator==() [5/6]

bool operator== ( const double  val) const
inlinenoexcept

Definition at line 1148 of file tokenI.H.

References Foam::equal().

Here is the call graph for this function:

◆ operator==() [6/6]

bool operator== ( const std::string &  s) const
inline

Definition at line 1121 of file tokenI.H.

References s.

◆ operator!=() [1/6]

bool operator!= ( const token tok) const
inline

Definition at line 1158 of file tokenI.H.

References Foam::operator==().

Here is the call graph for this function:

◆ operator!=() [2/6]

bool operator!= ( const punctuationToken  p) const
inlinenoexcept

Definition at line 1164 of file tokenI.H.

References p.

◆ operator!=() [3/6]

bool operator!= ( const label  val) const
inlinenoexcept

Definition at line 1170 of file tokenI.H.

References Foam::operator==().

Here is the call graph for this function:

◆ operator!=() [4/6]

bool operator!= ( const float  val) const
inlinenoexcept

Definition at line 1176 of file tokenI.H.

References Foam::operator==().

Here is the call graph for this function:

◆ operator!=() [5/6]

bool operator!= ( const double  val) const
inlinenoexcept

Definition at line 1182 of file tokenI.H.

References Foam::operator==().

Here is the call graph for this function:

◆ operator!=() [6/6]

bool operator!= ( const std::string &  s) const
inline

Definition at line 1188 of file tokenI.H.

References Foam::operator==(), and s.

Here is the call graph for this function:

◆ lineNumber() [3/3]

label& lineNumber ( )
inlinenoexcept

Write access for the token line number.

Deprecated:
(2021-03) - use lineNumber(label)

Definition at line 1183 of file token.H.

◆ isFloatScalar()

bool isFloatScalar ( ) const
inline

Token is FLOAT.

Deprecated:
(2020-01) - isFloat()

Definition at line 1190 of file token.H.

References token::isFloat().

Here is the call graph for this function:

◆ isDoubleScalar()

bool isDoubleScalar ( ) const
inline

Token is DOUBLE.

Deprecated:
(2020-01) - isDouble()

Definition at line 1197 of file token.H.

References token::isDouble().

Here is the call graph for this function:

◆ floatScalarToken()

float floatScalarToken ( ) const
inline

Return float value.

Deprecated:
(2020-01) - floatToken()

Definition at line 1204 of file token.H.

References token::floatToken().

Here is the call graph for this function:

◆ doubleScalarToken()

double doubleScalarToken ( ) const
inline

Return double value.

Deprecated:
(2020-01) - doubleToken()

Definition at line 1211 of file token.H.

References token::doubleToken().

Here is the call graph for this function:

◆ operator=() [13/14]

void operator= ( word )
delete

Deprecated(2017-11) transfer word pointer to the token.

Deprecated:
(2017-11) - use move assign from word

◆ operator=() [14/14]

void operator= ( string )
delete

Deprecated(2017-11) transfer string pointer to the token.

Deprecated:
(2017-11) - use move assign from string

Friends And Related Function Documentation

◆ operator<< [1/4]

Ostream& operator<< ( Ostream os,
const token tok 
)
friend

◆ operator<< [2/4]

Ostream& operator<< ( Ostream os,
const punctuationToken pt 
)
friend

◆ operator<< [3/4]

ostream& operator<< ( ostream &  os,
const punctuationToken pt 
)
friend

◆ operator<< [4/4]

ostream& operator<< ( ostream &  os,
const InfoProxy< token > &  ip 
)
friend

Member Data Documentation

◆ undefinedToken

const Foam::token undefinedToken
static

An undefined token.

Definition at line 542 of file token.H.

Referenced by Istream::peekBack().

◆ typeName

constexpr const char* const typeName = "token"
static

The type name is "token".

Definition at line 617 of file token.H.


The documentation for this class was generated from the following files: