token Class Reference

A token holds items read from Istream. More...

Collaboration diagram for token:

Classes

class  compound
 Abstract base class for complex tokens. More...
 
class  Compound
 A templated class for holding compound tokens. More...
 

Public Types

enum  tokenType : char {
  UNDEFINED = 0, PUNCTUATION = char(128), WORD, FUNCTIONNAME,
  VARIABLE, STRING, VERBATIMSTRING, LABEL,
  FLOAT_SCALAR, DOUBLE_SCALAR, LONG_DOUBLE_SCALAR, COMPOUND,
  ERROR
}
 Enumeration defining the types of token. More...
 
enum  punctuationToken : char {
  NULL_TOKEN = '\0', SPACE = ' ', TAB = '\t', NL = '\n',
  END_STATEMENT = ';', BEGIN_LIST = '(', END_LIST = ')', BEGIN_SQR = '[',
  END_SQR = ']', BEGIN_BLOCK = '{', END_BLOCK = '}', COLON = ':',
  COMMA = ',', HASH = '#', BEGIN_STRING = '"', END_STRING = BEGIN_STRING,
  ASSIGN = '=', ADD = '+', SUBTRACT = '-', MULTIPLY = '*',
  DIVIDE = '/'
}
 Standard punctuation tokens. More...
 

Public Member Functions

 token ()
 Construct null. More...
 
 token (const token &)
 Copy constructor. More...
 
 token (punctuationToken, label lineNumber=0)
 Construct punctuation character token. More...
 
 token (const word &, label lineNumber=0)
 Construct word token. More...
 
 token (const string &, label lineNumber=0)
 Construct string token. More...
 
 token (const verbatimString &, label lineNumber=0)
 Construct verbatimString token. More...
 
 token (const label, label lineNumber=0)
 Construct label token. More...
 
 token (const floatScalar, label lineNumber=0)
 Construct floatScalar token. More...
 
 token (const doubleScalar, label lineNumber=0)
 Construct doubleScalar token. More...
 
 token (const longDoubleScalar, label lineNumber=0)
 Construct longDoubleScalar token. More...
 
 token (Istream &)
 Construct from Istream. More...
 
 ~token ()
 Destructor. More...
 
tokenType type () const
 
tokenTypetype ()
 
bool good () const
 
bool undefined () const
 
bool error () const
 
bool isPunctuation () const
 
punctuationToken pToken () const
 
bool isWord () const
 
const wordwordToken () const
 
bool isFunctionName () const
 
const functionNamefunctionNameToken () const
 
bool isVariable () const
 
const variablevariableToken () const
 
bool isString () const
 
const stringstringToken () const
 
bool isVerbatimString () const
 
const verbatimStringverbatimStringToken () const
 
bool isAnyString () const
 
const stringanyStringToken () const
 
bool isLabel () const
 
label labelToken () const
 
bool isFloatScalar () const
 
floatScalar floatScalarToken () const
 
bool isDoubleScalar () const
 
doubleScalar doubleScalarToken () const
 
bool isLongDoubleScalar () const
 
longDoubleScalar longDoubleScalarToken () const
 
bool isScalar () const
 
scalar scalarToken () const
 
bool isNumber () const
 
scalar number () const
 
bool isCompound () const
 
const compoundcompoundToken () const
 
compoundtransferCompoundToken (const Istream &is)
 
label lineNumber () const
 
labellineNumber ()
 
void setBad ()
 Set bad. More...
 
InfoProxy< tokeninfo () const
 Return info proxy. More...
 
void operator= (const token &)
 
void operator= (const punctuationToken)
 
void operator= (word *)
 
void operator= (const word &)
 
void operator= (functionName *)
 
void operator= (const functionName &)
 
void operator= (variable *)
 
void operator= (const variable &)
 
void operator= (string *)
 
void operator= (const string &)
 
void operator= (verbatimString *)
 
void operator= (const verbatimString &)
 
void operator= (const label)
 
void operator= (const floatScalar)
 
void operator= (const doubleScalar)
 
void operator= (const longDoubleScalar)
 
void operator= (compound *)
 
bool operator== (const token &) const
 
bool operator== (const punctuationToken) const
 
bool operator== (const word &) const
 
bool operator== (const functionName &) const
 
bool operator== (const variable &) const
 
bool operator== (const string &) const
 
bool operator== (const verbatimString &) const
 
bool operator== (const label) const
 
bool operator== (const floatScalar) const
 
bool operator== (const doubleScalar) const
 
bool operator== (const longDoubleScalar) const
 
bool operator!= (const token &) const
 
bool operator!= (const punctuationToken) const
 
bool operator!= (const word &) const
 
bool operator!= (const functionName &) const
 
bool operator!= (const variable &) const
 
bool operator!= (const string &) const
 
bool operator!= (const verbatimString &) const
 
bool operator!= (const label) const
 
bool operator!= (const floatScalar) const
 
bool operator!= (const doubleScalar) const
 
bool operator!= (const longDoubleScalar) const
 

Static Public Attributes

static token undefinedToken
 Static undefined token. More...
 
static const char *const typeName = "token"
 

Friends

Istreamoperator>> (Istream &, token &)
 
Ostreamoperator<< (Ostream &, const token &)
 
Ostreamoperator<< (Ostream &, const punctuationToken &)
 
ostream & operator<< (ostream &, const punctuationToken &)
 
ostream & operator<< (ostream &, const InfoProxy< token > &)
 

Detailed Description

A token holds items read from Istream.

Source files

Definition at line 72 of file token.H.

Member Enumeration Documentation

◆ tokenType

enum tokenType : char

Enumeration defining the types of token.

Enumerator
UNDEFINED 
PUNCTUATION 
WORD 
FUNCTIONNAME 
VARIABLE 
STRING 
VERBATIMSTRING 
LABEL 
FLOAT_SCALAR 
DOUBLE_SCALAR 
LONG_DOUBLE_SCALAR 
COMPOUND 
ERROR 

Definition at line 78 of file token.H.

◆ punctuationToken

enum punctuationToken : char

Standard punctuation tokens.

Enumerator
NULL_TOKEN 
SPACE 
TAB 
NL 
END_STATEMENT 
BEGIN_LIST 
END_LIST 
BEGIN_SQR 
END_SQR 
BEGIN_BLOCK 
END_BLOCK 
COLON 
COMMA 
HASH 
BEGIN_STRING 
END_STRING 
ASSIGN 
ADD 
SUBTRACT 
MULTIPLY 
DIVIDE 

Definition at line 98 of file token.H.

Constructor & Destructor Documentation

◆ token() [1/11]

token ( )
inline

Construct null.

Definition at line 74 of file tokenI.H.

◆ token() [2/11]

◆ token() [3/11]

token ( punctuationToken  p,
label  lineNumber = 0 
)
inline

Construct punctuation character token.

Definition at line 144 of file tokenI.H.

◆ token() [4/11]

token ( const word w,
label  lineNumber = 0 
)
inline

Construct word token.

Definition at line 152 of file tokenI.H.

◆ token() [5/11]

token ( const string s,
label  lineNumber = 0 
)
inline

Construct string token.

Definition at line 160 of file tokenI.H.

◆ token() [6/11]

token ( const verbatimString vs,
label  lineNumber = 0 
)
inline

Construct verbatimString token.

Definition at line 168 of file tokenI.H.

◆ token() [7/11]

token ( const label  l,
label  lineNumber = 0 
)
inline

Construct label token.

Definition at line 176 of file tokenI.H.

◆ token() [8/11]

token ( const floatScalar  s,
label  lineNumber = 0 
)
inline

Construct floatScalar token.

Definition at line 184 of file tokenI.H.

◆ token() [9/11]

token ( const doubleScalar  s,
label  lineNumber = 0 
)
inline

Construct doubleScalar token.

Definition at line 192 of file tokenI.H.

◆ token() [10/11]

token ( const longDoubleScalar  s,
label  lineNumber = 0 
)
inline

Construct longDoubleScalar token.

Definition at line 200 of file tokenI.H.

◆ token() [11/11]

token ( Istream is)

Construct from Istream.

Definition at line 34 of file tokenIO.C.

References Istream::read().

Here is the call graph for this function:

◆ ~token()

~token ( )
inline

Destructor.

Definition at line 210 of file tokenI.H.

Member Function Documentation

◆ type() [1/2]

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

Definition at line 218 of file tokenI.H.

Referenced by token::compound::compound(), and Foam::operator<<().

Here is the caller graph for this function:

◆ type() [2/2]

Foam::token::tokenType & type ( )
inline

Definition at line 223 of file tokenI.H.

◆ good()

bool good ( ) const
inline

Definition at line 228 of file tokenI.H.

References token::ERROR, and token::UNDEFINED.

Referenced by dimensionSet::dimensionSet(), Foam::operator>>(), and primitiveEntry::read().

Here is the caller graph for this function:

◆ undefined()

bool undefined ( ) const
inline

Definition at line 233 of file tokenI.H.

References token::UNDEFINED.

◆ error()

bool error ( ) const
inline

Definition at line 238 of file tokenI.H.

References token::ERROR.

◆ isPunctuation()

◆ pToken()

◆ isWord()

◆ wordToken()

◆ isFunctionName()

bool isFunctionName ( ) const
inline

Definition at line 279 of file tokenI.H.

References token::FUNCTIONNAME.

Referenced by ifeqEntry::execute(), keyType::operator=(), and Foam::operator>>().

Here is the caller graph for this function:

◆ functionNameToken()

const Foam::functionName & functionNameToken ( ) const
inline

◆ isVariable()

bool isVariable ( ) const
inline

Definition at line 297 of file tokenI.H.

References token::VARIABLE.

Referenced by keyType::operator=(), and Foam::operator>>().

Here is the caller graph for this function:

◆ variableToken()

const Foam::variable & variableToken ( ) const
inline

Definition at line 302 of file tokenI.H.

References variable::null, variable::typeName, token::VARIABLE, and token::variableTokenPtr_.

Referenced by Foam::operator<<(), keyType::operator=(), token::operator==(), and Foam::operator>>().

Here is the caller graph for this function:

◆ isString()

bool isString ( ) const
inline

Definition at line 315 of file tokenI.H.

References token::STRING.

Referenced by keyType::operator=(), Foam::operator>>(), and functionEntry::readFuncNameArgs().

Here is the caller graph for this function:

◆ stringToken()

const Foam::string & stringToken ( ) const
inline

Definition at line 320 of file tokenI.H.

References string::null, token::STRING, token::stringTokenPtr_, and string::typeName.

Referenced by Foam::operator<<(), keyType::operator=(), token::operator==(), Foam::operator>>(), and functionEntry::readFuncNameArgs().

Here is the caller graph for this function:

◆ isVerbatimString()

bool isVerbatimString ( ) const
inline

Definition at line 333 of file tokenI.H.

References token::VERBATIMSTRING.

Referenced by Foam::operator>>().

Here is the caller graph for this function:

◆ verbatimStringToken()

const Foam::verbatimString & verbatimStringToken ( ) const
inline

Definition at line 338 of file tokenI.H.

References verbatimString::null, verbatimString::typeName, token::VERBATIMSTRING, and token::verbatimStringTokenPtr_.

Referenced by Foam::operator<<(), token::operator==(), and Foam::operator>>().

Here is the caller graph for this function:

◆ isAnyString()

bool isAnyString ( ) const
inline

◆ anyStringToken()

◆ isLabel()

◆ labelToken()

◆ isFloatScalar()

bool isFloatScalar ( ) const
inline

Definition at line 410 of file tokenI.H.

References token::FLOAT_SCALAR.

◆ floatScalarToken()

Foam::floatScalar floatScalarToken ( ) const
inline

Definition at line 415 of file tokenI.H.

References token::FLOAT_SCALAR, and token::floatScalarToken_.

Referenced by Foam::operator<<().

Here is the caller graph for this function:

◆ isDoubleScalar()

bool isDoubleScalar ( ) const
inline

Definition at line 429 of file tokenI.H.

References token::DOUBLE_SCALAR.

◆ doubleScalarToken()

Foam::doubleScalar doubleScalarToken ( ) const
inline

Definition at line 434 of file tokenI.H.

References token::DOUBLE_SCALAR, and token::doubleScalarToken_.

Referenced by Foam::operator<<().

Here is the caller graph for this function:

◆ isLongDoubleScalar()

bool isLongDoubleScalar ( ) const
inline

Definition at line 448 of file tokenI.H.

References token::LONG_DOUBLE_SCALAR.

◆ longDoubleScalarToken()

Foam::longDoubleScalar longDoubleScalarToken ( ) const
inline

Definition at line 453 of file tokenI.H.

References token::LONG_DOUBLE_SCALAR, and token::longDoubleScalarTokenPtr_.

Referenced by Foam::operator<<().

Here is the caller graph for this function:

◆ isScalar()

bool isScalar ( ) const
inline

Definition at line 467 of file tokenI.H.

References token::DOUBLE_SCALAR, token::FLOAT_SCALAR, and token::LONG_DOUBLE_SCALAR.

Referenced by token::isNumber(), and token::number().

Here is the caller graph for this function:

◆ scalarToken()

Foam::scalar scalarToken ( ) const
inline

Definition at line 477 of file tokenI.H.

References token::DOUBLE_SCALAR, token::doubleScalarToken_, token::FLOAT_SCALAR, token::floatScalarToken_, token::LONG_DOUBLE_SCALAR, and token::longDoubleScalarTokenPtr_.

Referenced by token::number().

Here is the caller graph for this function:

◆ isNumber()

bool isNumber ( ) const
inline

Definition at line 498 of file tokenI.H.

References token::isScalar(), and token::LABEL.

Referenced by CrankNicolsonDdtScheme< Type >::CrankNicolsonDdtScheme(), Foam::operator>>(), dimensionSet::read(), and specieCoeffs::specieCoeffs().

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

◆ number()

Foam::scalar number ( ) const
inline

Definition at line 503 of file tokenI.H.

References token::isScalar(), token::LABEL, token::labelToken_, and token::scalarToken().

Referenced by CrankNicolsonDdtScheme< Type >::CrankNicolsonDdtScheme(), genericFvPatchField< Type >::genericFvPatchField(), Foam::operator>>(), dimensionSet::read(), and specieCoeffs::specieCoeffs().

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

◆ isCompound()

bool isCompound ( ) const
inline

◆ compoundToken()

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

Definition at line 525 of file tokenI.H.

References token::COMPOUND, and token::compoundTokenPtr_.

Referenced by genericFvPatchField< Type >::genericFvPatchField(), genericPointPatchField< Type >::genericPointPatchField(), and Foam::operator<<().

Here is the caller graph for this function:

◆ transferCompoundToken()

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

◆ lineNumber() [1/2]

Foam::label lineNumber ( ) const
inline

Definition at line 539 of file tokenI.H.

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

Here is the caller graph for this function:

◆ lineNumber() [2/2]

Foam::label & lineNumber ( )
inline

Definition at line 544 of file tokenI.H.

◆ setBad()

void setBad ( )
inline

Set bad.

Definition at line 550 of file tokenI.H.

References token::ERROR.

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

Here is the caller graph for this function:

◆ info()

◆ operator=() [1/17]

◆ operator=() [2/17]

void operator= ( const punctuationToken  p)
inline

Definition at line 623 of file tokenI.H.

References p, token::PUNCTUATION, and token::punctuationToken_.

◆ operator=() [3/17]

void operator= ( word wPtr)
inline

Definition at line 630 of file tokenI.H.

References token::WORD, and token::wordTokenPtr_.

◆ operator=() [4/17]

void operator= ( const word w)
inline

Definition at line 637 of file tokenI.H.

References token::operator=().

Here is the call graph for this function:

◆ operator=() [5/17]

void operator= ( functionName fnPtr)
inline

Definition at line 642 of file tokenI.H.

References token::FUNCTIONNAME, and token::functionNameTokenPtr_.

◆ operator=() [6/17]

void operator= ( const functionName fn)
inline

Definition at line 649 of file tokenI.H.

References token::operator=().

Here is the call graph for this function:

◆ operator=() [7/17]

void operator= ( variable vPtr)
inline

Definition at line 654 of file tokenI.H.

References token::VARIABLE, and token::variableTokenPtr_.

◆ operator=() [8/17]

void operator= ( const variable v)
inline

Definition at line 661 of file tokenI.H.

References token::operator=().

Here is the call graph for this function:

◆ operator=() [9/17]

void operator= ( string sPtr)
inline

Definition at line 666 of file tokenI.H.

References token::STRING, and token::stringTokenPtr_.

◆ operator=() [10/17]

void operator= ( const string s)
inline

Definition at line 673 of file tokenI.H.

References token::operator=().

Here is the call graph for this function:

◆ operator=() [11/17]

void operator= ( verbatimString vsPtr)
inline

Definition at line 678 of file tokenI.H.

References token::VERBATIMSTRING, and token::verbatimStringTokenPtr_.

◆ operator=() [12/17]

void operator= ( const verbatimString vs)
inline

Definition at line 685 of file tokenI.H.

References token::operator=().

Here is the call graph for this function:

◆ operator=() [13/17]

void operator= ( const label  l)
inline

Definition at line 690 of file tokenI.H.

References token::LABEL, and token::labelToken_.

◆ operator=() [14/17]

void operator= ( const floatScalar  s)
inline

Definition at line 697 of file tokenI.H.

References token::FLOAT_SCALAR, token::floatScalarToken_, and s().

Here is the call graph for this function:

◆ operator=() [15/17]

void operator= ( const doubleScalar  s)
inline

Definition at line 704 of file tokenI.H.

References token::DOUBLE_SCALAR, token::doubleScalarToken_, and s().

Here is the call graph for this function:

◆ operator=() [16/17]

void operator= ( const longDoubleScalar  s)
inline

Definition at line 711 of file tokenI.H.

References token::LONG_DOUBLE_SCALAR, and token::longDoubleScalarTokenPtr_.

◆ operator=() [17/17]

void operator= ( compound cPtr)
inline

Definition at line 718 of file tokenI.H.

References token::COMPOUND, and token::compoundTokenPtr_.

◆ operator==() [1/11]

◆ operator==() [2/11]

bool operator== ( const punctuationToken  p) const
inline

Definition at line 782 of file tokenI.H.

References token::PUNCTUATION, and token::punctuationToken_.

◆ operator==() [3/11]

bool operator== ( const word w) const
inline

Definition at line 787 of file tokenI.H.

References token::WORD, and token::wordToken().

Here is the call graph for this function:

◆ operator==() [4/11]

bool operator== ( const functionName fn) const
inline

Definition at line 792 of file tokenI.H.

References token::FUNCTIONNAME, and token::functionNameToken().

Here is the call graph for this function:

◆ operator==() [5/11]

bool operator== ( const variable v) const
inline

Definition at line 797 of file tokenI.H.

References token::VARIABLE, and token::variableToken().

Here is the call graph for this function:

◆ operator==() [6/11]

bool operator== ( const string s) const
inline

Definition at line 802 of file tokenI.H.

References token::STRING, and token::stringToken().

Here is the call graph for this function:

◆ operator==() [7/11]

bool operator== ( const verbatimString vs) const
inline

Definition at line 807 of file tokenI.H.

References token::VERBATIMSTRING, and token::verbatimStringToken().

Here is the call graph for this function:

◆ operator==() [8/11]

bool operator== ( const label  l) const
inline

Definition at line 812 of file tokenI.H.

References token::LABEL, and token::labelToken_.

◆ operator==() [9/11]

bool operator== ( const floatScalar  s) const
inline

Definition at line 817 of file tokenI.H.

References Foam::equal(), token::FLOAT_SCALAR, and token::floatScalarToken_.

Here is the call graph for this function:

◆ operator==() [10/11]

bool operator== ( const doubleScalar  s) const
inline

Definition at line 822 of file tokenI.H.

References token::DOUBLE_SCALAR, token::doubleScalarToken_, and Foam::equal().

Here is the call graph for this function:

◆ operator==() [11/11]

bool operator== ( const longDoubleScalar  s) const
inline

Definition at line 827 of file tokenI.H.

References Foam::equal(), token::LONG_DOUBLE_SCALAR, and token::longDoubleScalarTokenPtr_.

Here is the call graph for this function:

◆ operator!=() [1/11]

bool operator!= ( const token t) const
inline

Definition at line 835 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [2/11]

bool operator!= ( const punctuationToken  p) const
inline

Definition at line 840 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [3/11]

bool operator!= ( const word w) const
inline

Definition at line 845 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [4/11]

bool operator!= ( const functionName fn) const
inline

Definition at line 850 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [5/11]

bool operator!= ( const variable v) const
inline

Definition at line 855 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [6/11]

bool operator!= ( const string s) const
inline

Definition at line 860 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [7/11]

bool operator!= ( const verbatimString vs) const
inline

Definition at line 865 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [8/11]

bool operator!= ( const label  l) const
inline

Definition at line 885 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [9/11]

bool operator!= ( const floatScalar  s) const
inline

Definition at line 870 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [10/11]

bool operator!= ( const doubleScalar  s) const
inline

Definition at line 875 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [11/11]

bool operator!= ( const longDoubleScalar  s) const
inline

Definition at line 880 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator>>

Istream& operator>> ( Istream ,
token  
)
friend

◆ operator<< [1/4]

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

◆ operator<< [2/4]

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

◆ operator<< [3/4]

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

◆ operator<< [4/4]

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

Member Data Documentation

◆ undefinedToken

token undefinedToken
static

Static undefined token.

Definition at line 237 of file token.H.

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

◆ punctuationToken_

punctuationToken punctuationToken_

◆ wordTokenPtr_

◆ functionNameTokenPtr_

◆ variableTokenPtr_

◆ stringTokenPtr_

◆ verbatimStringTokenPtr_

◆ labelToken_

◆ floatScalarToken_

◆ doubleScalarToken_

◆ longDoubleScalarTokenPtr_

◆ compoundTokenPtr_

compound* compoundTokenPtr_
mutable

◆ typeName

const char *const typeName = "token"
static

Definition at line 280 of file token.H.


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