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, 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 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 isVariable () const
 
bool isString () const
 
const stringstringToken () 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= (string *)
 
void operator= (const string &)
 
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 string &) 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 string &) 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 69 of file token.H.

Member Enumeration Documentation

◆ tokenType

enum tokenType : char

Enumeration defining the types of token.

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

Definition at line 75 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 94 of file token.H.

Constructor & Destructor Documentation

◆ token() [1/10]

token ( )
inline

Construct null.

Definition at line 62 of file tokenI.H.

◆ token() [2/10]

◆ token() [3/10]

token ( punctuationToken  p,
label  lineNumber = 0 
)
inline

Construct punctuation character token.

Definition at line 121 of file tokenI.H.

◆ token() [4/10]

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

Construct word token.

Definition at line 129 of file tokenI.H.

◆ token() [5/10]

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

Construct string token.

Definition at line 137 of file tokenI.H.

◆ token() [6/10]

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

Construct label token.

Definition at line 145 of file tokenI.H.

◆ token() [7/10]

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

Construct floatScalar token.

Definition at line 153 of file tokenI.H.

◆ token() [8/10]

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

Construct doubleScalar token.

Definition at line 161 of file tokenI.H.

◆ token() [9/10]

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

Construct longDoubleScalar token.

Definition at line 169 of file tokenI.H.

◆ token() [10/10]

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 179 of file tokenI.H.

Member Function Documentation

◆ type() [1/2]

◆ type() [2/2]

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

Definition at line 192 of file tokenI.H.

◆ good()

bool good ( ) const
inline

Definition at line 197 of file tokenI.H.

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

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

Here is the caller graph for this function:

◆ undefined()

bool undefined ( ) const
inline

Definition at line 202 of file tokenI.H.

References token::UNDEFINED.

◆ error()

bool error ( ) const
inline

Definition at line 207 of file tokenI.H.

References token::ERROR.

◆ isPunctuation()

◆ pToken()

◆ isWord()

◆ wordToken()

◆ isVariable()

bool isVariable ( ) const
inline

Definition at line 248 of file tokenI.H.

References token::VARIABLE.

Referenced by ifeqEntry::expand().

Here is the caller graph for this function:

◆ isString()

bool isString ( ) const
inline

Definition at line 253 of file tokenI.H.

References token::STRING, token::VARIABLE, and token::VERBATIMSTRING.

Referenced by ifeqEntry::equalToken(), ifeqEntry::expand(), and Foam::operator>>().

Here is the caller graph for this function:

◆ stringToken()

◆ isLabel()

◆ labelToken()

◆ isFloatScalar()

bool isFloatScalar ( ) const
inline

Definition at line 289 of file tokenI.H.

References token::FLOAT_SCALAR.

◆ floatScalarToken()

Foam::floatScalar floatScalarToken ( ) const
inline

Definition at line 294 of file tokenI.H.

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

Referenced by ifeqEntry::equalToken(), and Foam::operator<<().

Here is the caller graph for this function:

◆ isDoubleScalar()

bool isDoubleScalar ( ) const
inline

Definition at line 308 of file tokenI.H.

References token::DOUBLE_SCALAR.

◆ doubleScalarToken()

Foam::doubleScalar doubleScalarToken ( ) const
inline

Definition at line 313 of file tokenI.H.

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

Referenced by ifeqEntry::equalToken(), and Foam::operator<<().

Here is the caller graph for this function:

◆ isLongDoubleScalar()

bool isLongDoubleScalar ( ) const
inline

Definition at line 327 of file tokenI.H.

References token::LONG_DOUBLE_SCALAR.

◆ longDoubleScalarToken()

Foam::longDoubleScalar longDoubleScalarToken ( ) const
inline

Definition at line 332 of file tokenI.H.

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

Referenced by ifeqEntry::equalToken(), and Foam::operator<<().

Here is the caller graph for this function:

◆ isScalar()

bool isScalar ( ) const
inline

Definition at line 346 of file tokenI.H.

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

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

Here is the caller graph for this function:

◆ scalarToken()

Foam::scalar scalarToken ( ) const
inline

◆ isNumber()

bool isNumber ( ) const
inline

Definition at line 377 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 382 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 404 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 418 of file tokenI.H.

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

Here is the caller graph for this function:

◆ lineNumber() [2/2]

Foam::label & lineNumber ( )
inline

Definition at line 423 of file tokenI.H.

◆ setBad()

void setBad ( )
inline

Set bad.

Definition at line 429 of file tokenI.H.

References token::ERROR.

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

Here is the caller graph for this function:

◆ info()

◆ operator=() [1/11]

◆ operator=() [2/11]

void operator= ( const punctuationToken  p)
inline

Definition at line 491 of file tokenI.H.

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

◆ operator=() [3/11]

void operator= ( word wPtr)
inline

Definition at line 498 of file tokenI.H.

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

◆ operator=() [4/11]

void operator= ( const word w)
inline

Definition at line 505 of file tokenI.H.

References token::operator=().

Here is the call graph for this function:

◆ operator=() [5/11]

void operator= ( string sPtr)
inline

Definition at line 510 of file tokenI.H.

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

◆ operator=() [6/11]

void operator= ( const string s)
inline

Definition at line 517 of file tokenI.H.

References token::operator=().

Here is the call graph for this function:

◆ operator=() [7/11]

void operator= ( const label  l)
inline

Definition at line 522 of file tokenI.H.

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

◆ operator=() [8/11]

void operator= ( const floatScalar  s)
inline

Definition at line 529 of file tokenI.H.

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

Here is the call graph for this function:

◆ operator=() [9/11]

void operator= ( const doubleScalar  s)
inline

Definition at line 536 of file tokenI.H.

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

Here is the call graph for this function:

◆ operator=() [10/11]

void operator= ( const longDoubleScalar  s)
inline

Definition at line 543 of file tokenI.H.

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

◆ operator=() [11/11]

void operator= ( compound cPtr)
inline

Definition at line 550 of file tokenI.H.

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

◆ operator==() [1/8]

◆ operator==() [2/8]

bool operator== ( const punctuationToken  p) const
inline

Definition at line 607 of file tokenI.H.

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

◆ operator==() [3/8]

bool operator== ( const word w) const
inline

Definition at line 612 of file tokenI.H.

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

Here is the call graph for this function:

◆ operator==() [4/8]

bool operator== ( const string s) const
inline

Definition at line 617 of file tokenI.H.

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

Here is the call graph for this function:

◆ operator==() [5/8]

bool operator== ( const label  l) const
inline

Definition at line 626 of file tokenI.H.

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

◆ operator==() [6/8]

bool operator== ( const floatScalar  s) const
inline

Definition at line 631 of file tokenI.H.

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

Here is the call graph for this function:

◆ operator==() [7/8]

bool operator== ( const doubleScalar  s) const
inline

Definition at line 636 of file tokenI.H.

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

Here is the call graph for this function:

◆ operator==() [8/8]

bool operator== ( const longDoubleScalar  s) const
inline

Definition at line 641 of file tokenI.H.

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

Here is the call graph for this function:

◆ operator!=() [1/8]

bool operator!= ( const token t) const
inline

Definition at line 649 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [2/8]

bool operator!= ( const punctuationToken  p) const
inline

Definition at line 654 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [3/8]

bool operator!= ( const word w) const
inline

Definition at line 659 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [4/8]

bool operator!= ( const string s) const
inline

Definition at line 664 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [5/8]

bool operator!= ( const label  l) const
inline

Definition at line 684 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [6/8]

bool operator!= ( const floatScalar  s) const
inline

Definition at line 669 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [7/8]

bool operator!= ( const doubleScalar  s) const
inline

Definition at line 674 of file tokenI.H.

References token::operator==().

Here is the call graph for this function:

◆ operator!=() [8/8]

bool operator!= ( const longDoubleScalar  s) const
inline

Definition at line 679 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 233 of file token.H.

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

◆ punctuationToken_

punctuationToken punctuationToken_

◆ wordTokenPtr_

word* wordTokenPtr_

◆ stringTokenPtr_

string* stringTokenPtr_

◆ labelToken_

◆ floatScalarToken_

◆ doubleScalarToken_

◆ longDoubleScalarTokenPtr_

◆ compoundTokenPtr_

compound* compoundTokenPtr_
mutable

◆ typeName

const char *const typeName = "token"
static

Definition at line 273 of file token.H.


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