Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
token Class Reference

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

Collaboration diagram for token:
Collaboration graph
[legend]

Classes

class  Compound
 
class  compound
 

Public Types

enum  tokenType : char {
  UNDEFINED = '\0', ERROR = '\x80', FLAG, PUNCTUATION,
  BOOL, LABEL, FLOAT, DOUBLE,
  WORD, STRING, COMPOUND, DIRECTIVE,
  EXPRESSION, VARIABLE, VERBATIM, FLOAT_SCALAR = FLOAT,
  DOUBLE_SCALAR = DOUBLE, VERBATIMSTRING = VERBATIM
}
 
enum  flagType { NO_FLAG = 0, ASCII = 1, BINARY = 2 }
 
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
}
 

Public Member Functions

constexpr token () noexcept
 
 token (const token &t)
 
 token (token &&t) noexcept
 
 token (punctuationToken p, label lineNum=0) noexcept
 
 token (const label val, label lineNum=0) noexcept
 
 token (const floatScalar val, label lineNum=0) noexcept
 
 token (const doubleScalar val, label lineNum=0) noexcept
 
 token (const word &w, label lineNum=0)
 
 token (const string &str, label lineNum=0)
 
 token (word &&w, label lineNum=0)
 
 token (string &&str, label lineNum=0)
 
 token (token::compound *ptr, label lineNum=0)
 
 token (Istream &is)
 
 ~token ()
 
word name () const
 
tokenType type () const noexcept
 
bool setType (const tokenType tokType) noexcept
 
label lineNumber () const noexcept
 
label lineNumber (const label lineNum) noexcept
 
bool good () const noexcept
 
bool undefined () const noexcept
 
bool error () const noexcept
 
bool isBool () const noexcept
 
bool isFlag () const noexcept
 
bool isPunctuation () const noexcept
 
bool isPunctuation (const punctuationToken p) const noexcept
 
bool isSeparator () const noexcept
 
bool isLabel () const noexcept
 
bool isLabel (const label val) const noexcept
 
bool isFloat () const noexcept
 
bool isDouble () const noexcept
 
bool isScalar () const noexcept
 
bool isNumber () const noexcept
 
bool isWord () const noexcept
 
bool isWord (const std::string &s) const
 
bool isDirective () const noexcept
 
bool isQuotedString () const noexcept
 
bool isString () const noexcept
 
bool isExpression () const noexcept
 
bool isVariable () const noexcept
 
bool isVerbatim () const noexcept
 
bool isStringType () const noexcept
 
bool isCompound () const noexcept
 
bool boolToken () const
 
int flagToken () const
 
punctuationToken pToken () const
 
label labelToken () const
 
floatScalar floatToken () const
 
doubleScalar doubleToken () const
 
scalar scalarToken () const
 
scalar number () const
 
const wordwordToken () const
 
const stringstringToken () const
 
const compoundcompoundToken () const
 
compoundtransferCompoundToken ()
 
compoundtransferCompoundToken (const Istream &is)
 
void reset ()
 
void setBad ()
 
void swap (token &tok)
 
InfoProxy< tokeninfo () const
 
void operator= (const token &tok)
 
void operator= (token &&tok)
 
void operator= (const punctuationToken p)
 
void operator= (const label val)
 
void operator= (const floatScalar val)
 
void operator= (const doubleScalar val)
 
void operator= (const word &w)
 
void operator= (const string &str)
 
void operator= (word &&w)
 
void operator= (string &&str)
 
void operator= (token::compound *ptr)
 
void operator= (autoPtr< token::compound > &&ptr)
 
bool operator== (const token &tok) const
 
bool operator== (const punctuationToken p) const noexcept
 
bool operator== (const label val) const noexcept
 
bool operator== (const floatScalar val) const noexcept
 
bool operator== (const doubleScalar 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 floatScalar val) const noexcept
 
bool operator!= (const doubleScalar val) const noexcept
 
bool operator!= (const std::string &s) const
 
label & lineNumber () noexcept
 
bool isFloatScalar () const
 
bool isDoubleScalar () const
 
floatScalar floatScalarToken () const
 
doubleScalar doubleScalarToken () const
 
void operator= (word *)=delete
 
void operator= (string *)=delete
 

Static Public Member Functions

static token boolean (bool on) noexcept
 
static token flag (int bitmask) noexcept
 
static bool isseparator (int c) noexcept
 

Static Public Attributes

static const token undefinedToken
 
static constexpr const char *const typeName = "token"
 

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 > &ct)
 

Detailed Description

A token holds an item read from Istream.

Source files

Definition at line 64 of file token.H.

Member Enumeration Documentation

◆ tokenType

enum tokenType : char
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

FLOAT_SCALAR 
DOUBLE_SCALAR 
VERBATIMSTRING 

Definition at line 72 of file token.H.

◆ flagType

enum flagType
Enumerator
NO_FLAG 

No flags.

ASCII 

ASCII-mode stream.

BINARY 

BINARY-mode stream.

Definition at line 107 of file token.H.

◆ punctuationToken

enum punctuationToken : char
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 116 of file token.H.

Constructor & Destructor Documentation

◆ token() [1/13]

constexpr token ( )
inlineconstexprnoexcept

Definition at line 90 of file tokenI.H.

◆ token() [2/13]

token ( const token t)
inline

Definition at line 98 of file tokenI.H.

◆ token() [3/13]

token ( token &&  t)
inlinenoexcept

Definition at line 139 of file tokenI.H.

◆ token() [4/13]

token ( punctuationToken  p,
label  lineNum = 0 
)
inlineexplicitnoexcept

Definition at line 150 of file tokenI.H.

References p.

◆ token() [5/13]

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

Definition at line 160 of file tokenI.H.

◆ token() [6/13]

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

Definition at line 170 of file tokenI.H.

◆ token() [7/13]

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

Definition at line 180 of file tokenI.H.

◆ token() [8/13]

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

Definition at line 190 of file tokenI.H.

◆ token() [9/13]

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

Definition at line 200 of file tokenI.H.

◆ token() [10/13]

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

Definition at line 210 of file tokenI.H.

◆ token() [11/13]

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

Definition at line 220 of file tokenI.H.

◆ token() [12/13]

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

Definition at line 230 of file tokenI.H.

◆ token() [13/13]

token ( Istream is)
explicit

Definition at line 117 of file tokenIO.C.

References Istream::read().

Here is the call graph for this function:

◆ ~token()

~token ( )
inline

Definition at line 242 of file tokenI.H.

References reset().

Here is the call graph for this function:

Member Function Documentation

◆ boolean()

Foam::token boolean ( bool  on)
inlinestaticnoexcept

Definition at line 26 of file tokenI.H.

◆ flag()

Foam::token flag ( int  bitmask)
inlinestaticnoexcept

Definition at line 36 of file tokenI.H.

◆ isseparator()

bool isseparator ( int  c)
inlinestaticnoexcept

Definition at line 46 of file tokenI.H.

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

◆ name()

Foam::word name ( ) const

Definition at line 127 of file tokenIO.C.

◆ type()

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

Definition at line 304 of file tokenI.H.

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

Here is the caller graph for this function:

◆ setType()

bool setType ( const tokenType  tokType)
inlinenoexcept

Definition at line 310 of file tokenI.H.

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

Here is the caller graph for this function:

◆ lineNumber() [1/3]

Foam::label lineNumber ( ) const
inlinenoexcept

Definition at line 384 of file tokenI.H.

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

Here is the caller graph for this function:

◆ lineNumber() [2/3]

Foam::label lineNumber ( const label  lineNum)
inlinenoexcept

Definition at line 390 of file tokenI.H.

◆ good()

bool good ( ) const
inlinenoexcept

◆ undefined()

bool undefined ( ) const
inlinenoexcept

Definition at line 404 of file tokenI.H.

◆ error()

bool error ( ) const
inlinenoexcept

Definition at line 410 of file tokenI.H.

◆ isBool()

bool isBool ( ) const
inlinenoexcept

Definition at line 416 of file tokenI.H.

Referenced by Switch::Switch().

Here is the caller graph for this function:

◆ isFlag()

bool isFlag ( ) const
inlinenoexcept

Definition at line 434 of file tokenI.H.

Referenced by UIPstream::read().

Here is the caller graph for this function:

◆ isPunctuation() [1/2]

bool isPunctuation ( ) const
inlinenoexcept

◆ isPunctuation() [2/2]

bool isPunctuation ( const punctuationToken  p) const
inlinenoexcept

Definition at line 458 of file tokenI.H.

References p.

◆ isSeparator()

bool isSeparator ( ) const
inlinenoexcept

Definition at line 468 of file tokenI.H.

◆ isLabel() [1/2]

bool isLabel ( ) const
inlinenoexcept

◆ isLabel() [2/2]

bool isLabel ( const label  val) const
inlinenoexcept

Definition at line 496 of file tokenI.H.

◆ isFloat()

bool isFloat ( ) const
inlinenoexcept

Definition at line 518 of file tokenI.H.

Referenced by token::isFloatScalar().

Here is the caller graph for this function:

◆ isDouble()

bool isDouble ( ) const
inlinenoexcept

Definition at line 536 of file tokenI.H.

Referenced by token::isDoubleScalar().

Here is the caller graph for this function:

◆ isScalar()

bool isScalar ( ) const
inlinenoexcept

Definition at line 554 of file tokenI.H.

Referenced by Foam::operator>>().

Here is the caller graph for this function:

◆ isNumber()

bool isNumber ( ) const
inlinenoexcept

◆ isWord() [1/2]

bool isWord ( ) const
inlinenoexcept

◆ isWord() [2/2]

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

Definition at line 612 of file tokenI.H.

References s.

◆ isDirective()

bool isDirective ( ) const
inlinenoexcept

Definition at line 618 of file tokenI.H.

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

Here is the caller graph for this function:

◆ isQuotedString()

bool isQuotedString ( ) const
inlinenoexcept

Definition at line 640 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

Definition at line 646 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

Definition at line 658 of file tokenI.H.

◆ isVariable()

bool isVariable ( ) const
inlinenoexcept

Definition at line 664 of file tokenI.H.

Referenced by Foam::operator>>().

Here is the caller graph for this function:

◆ isVerbatim()

bool isVerbatim ( ) const
inlinenoexcept

Definition at line 670 of file tokenI.H.

◆ isStringType()

bool isStringType ( ) const
inlinenoexcept

Definition at line 676 of file tokenI.H.

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

Here is the caller graph for this function:

◆ isCompound()

bool isCompound ( ) const
inlinenoexcept

◆ boolToken()

bool boolToken ( ) const
inline

Definition at line 422 of file tokenI.H.

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

Here is the caller graph for this function:

◆ flagToken()

int flagToken ( ) const
inline

Definition at line 440 of file tokenI.H.

Referenced by Foam::printTokenInfo(), UIPstream::read(), and UOPstream::write().

Here is the caller graph for this function:

◆ pToken()

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

◆ labelToken()

Foam::label labelToken ( ) const
inline

◆ floatToken()

Foam::floatScalar floatToken ( ) const
inline

Definition at line 524 of file tokenI.H.

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

Here is the caller graph for this function:

◆ doubleToken()

Foam::doubleScalar doubleToken ( ) const
inline

Definition at line 542 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

Definition at line 564 of file tokenI.H.

Referenced by Foam::operator>>().

Here is the caller graph for this function:

◆ number()

Foam::scalar number ( ) const
inline

◆ wordToken()

const Foam::word & wordToken ( ) const
inline

◆ stringToken()

const Foam::string & stringToken ( ) const
inline

◆ compoundToken()

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

Definition at line 715 of file tokenI.H.

Referenced by mappedPatchBase::constructIOField(), and Foam::printTokenInfo().

Here is the caller graph for this function:

◆ transferCompoundToken() [1/2]

Foam::token::compound & transferCompoundToken ( )

Definition at line 83 of file token.C.

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

Referenced by mappedPatchBase::constructIOField(), List< vectorField >::readList(), FixedList< Type, 3 >::readList(), and UList< Foam::wordRe >::readList().

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

◆ transferCompoundToken() [2/2]

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

Definition at line 105 of file token.C.

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

Here is the call graph for this function:

◆ reset()

void reset ( )
inline

Definition at line 250 of file tokenI.H.

Referenced by Foam::operator>>(), Istream::peekBack(), and ITstream::read().

Here is the caller graph for this function:

◆ setBad()

void setBad ( )
inline

Definition at line 727 of file tokenI.H.

References reset().

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

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

◆ swap()

void swap ( token tok)
inline

Definition at line 291 of file tokenI.H.

◆ info()

InfoProxy<token> info ( ) const
inline

◆ operator=() [1/14]

void operator= ( const token tok)
inline

Definition at line 736 of file tokenI.H.

References reset().

Here is the call graph for this function:

◆ operator=() [2/14]

void operator= ( token &&  tok)
inline

Definition at line 784 of file tokenI.H.

References reset().

Here is the call graph for this function:

◆ operator=() [3/14]

void operator= ( const punctuationToken  p)
inline

Definition at line 797 of file tokenI.H.

References p, and reset().

Here is the call graph for this function:

◆ operator=() [4/14]

void operator= ( const label  val)
inline

Definition at line 805 of file tokenI.H.

References reset().

Here is the call graph for this function:

◆ operator=() [5/14]

void operator= ( const floatScalar  val)
inline

Definition at line 813 of file tokenI.H.

References reset().

Here is the call graph for this function:

◆ operator=() [6/14]

void operator= ( const doubleScalar  val)
inline

Definition at line 821 of file tokenI.H.

References reset().

Here is the call graph for this function:

◆ operator=() [7/14]

void operator= ( const word w)
inline

Definition at line 829 of file tokenI.H.

References reset().

Here is the call graph for this function:

◆ operator=() [8/14]

void operator= ( const string str)
inline

Definition at line 837 of file tokenI.H.

References reset().

Here is the call graph for this function:

◆ operator=() [9/14]

void operator= ( word &&  w)
inline

Definition at line 845 of file tokenI.H.

References reset().

Here is the call graph for this function:

◆ operator=() [10/14]

void operator= ( string &&  str)
inline

Definition at line 853 of file tokenI.H.

References reset(), and s.

Here is the call graph for this function:

◆ operator=() [11/14]

void operator= ( token::compound ptr)
inline

Definition at line 861 of file tokenI.H.

References reset().

Here is the call graph for this function:

◆ operator=() [12/14]

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

Definition at line 869 of file tokenI.H.

References reset().

Here is the call graph for this function:

◆ operator==() [1/6]

bool operator== ( const token tok) const
inline

Definition at line 877 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 928 of file tokenI.H.

References p.

◆ operator==() [3/6]

bool operator== ( const label  val) const
inlinenoexcept

Definition at line 945 of file tokenI.H.

◆ operator==() [4/6]

bool operator== ( const floatScalar  val) const
inlinenoexcept

Definition at line 951 of file tokenI.H.

References Foam::equal().

Here is the call graph for this function:

◆ operator==() [5/6]

bool operator== ( const doubleScalar  val) const
inlinenoexcept

Definition at line 961 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 934 of file tokenI.H.

References s.

◆ operator!=() [1/6]

bool operator!= ( const token tok) const
inline

Definition at line 971 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 977 of file tokenI.H.

References p.

◆ operator!=() [3/6]

bool operator!= ( const label  val) const
inlinenoexcept

Definition at line 983 of file tokenI.H.

References Foam::operator==().

Here is the call graph for this function:

◆ operator!=() [4/6]

bool operator!= ( const floatScalar  val) const
inlinenoexcept

Definition at line 989 of file tokenI.H.

References Foam::operator==().

Here is the call graph for this function:

◆ operator!=() [5/6]

bool operator!= ( const doubleScalar  val) const
inlinenoexcept

Definition at line 995 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 1001 of file tokenI.H.

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

Here is the call graph for this function:

◆ lineNumber() [3/3]

label& lineNumber ( )
inlinenoexcept

Definition at line 663 of file token.H.

◆ isFloatScalar()

bool isFloatScalar ( ) const
inline

Definition at line 667 of file token.H.

References token::isFloat().

Here is the call graph for this function:

◆ isDoubleScalar()

bool isDoubleScalar ( ) const
inline

Definition at line 671 of file token.H.

References token::isDouble().

Here is the call graph for this function:

◆ floatScalarToken()

floatScalar floatScalarToken ( ) const
inline

Definition at line 675 of file token.H.

References token::floatToken().

Here is the call graph for this function:

◆ doubleScalarToken()

doubleScalar doubleScalarToken ( ) const
inline

Definition at line 679 of file token.H.

References token::doubleToken().

Here is the call graph for this function:

◆ operator=() [13/14]

void operator= ( word )
delete

◆ operator=() [14/14]

void operator= ( string )
delete

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 > &  ct 
)
friend

Member Data Documentation

◆ undefinedToken

const Foam::token undefinedToken
static

Definition at line 290 of file token.H.

Referenced by Istream::peekBack(), and Foam::peekTokenAt().

◆ typeName

constexpr const char* const typeName = "token"
staticconstexpr

Definition at line 342 of file token.H.


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