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.

References clear().

Here is the call graph for this function:

Member Function Documentation

◆ type() [1/2]

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

Definition at line 218 of file tokenI.H.

Referenced by 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.

Referenced by 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.

◆ error()

bool error ( ) const
inline

Definition at line 238 of file tokenI.H.

◆ isPunctuation()

◆ pToken()

◆ isWord()

◆ wordToken()

◆ isFunctionName()

bool isFunctionName ( ) const
inline

Definition at line 279 of file tokenI.H.

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

Here is the caller graph for this function:

◆ functionNameToken()

const Foam::functionName & functionNameToken ( ) const
inline

Definition at line 284 of file tokenI.H.

References functionName::null, and functionName::typeName.

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

Here is the caller graph for this function:

◆ isVariable()

bool isVariable ( ) const
inline

Definition at line 297 of file tokenI.H.

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, and variable::typeName.

Referenced by Foam::operator<<(), keyType::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.

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, and string::typeName.

Referenced by Foam::operator<<(), keyType::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.

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, and verbatimString::typeName.

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

Here is the caller graph for this function:

◆ isAnyString()

bool isAnyString ( ) const
inline

Definition at line 351 of file tokenI.H.

◆ anyStringToken()

const Foam::string & anyStringToken ( ) const
inline

Definition at line 363 of file tokenI.H.

References string::null, and string::typeName.

Referenced by functionEntry::readFuncNameArgs().

Here is the caller graph for this function:

◆ isLabel()

◆ labelToken()

◆ isFloatScalar()

bool isFloatScalar ( ) const
inline

Definition at line 410 of file tokenI.H.

◆ floatScalarToken()

Foam::floatScalar floatScalarToken ( ) const
inline

Definition at line 415 of file tokenI.H.

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.

◆ doubleScalarToken()

Foam::doubleScalar doubleScalarToken ( ) const
inline

Definition at line 434 of file tokenI.H.

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.

◆ longDoubleScalarToken()

Foam::longDoubleScalar longDoubleScalarToken ( ) const
inline

Definition at line 453 of file tokenI.H.

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.

◆ scalarToken()

Foam::scalar scalarToken ( ) const
inline

Definition at line 477 of file tokenI.H.

◆ isNumber()

bool isNumber ( ) const
inline

Definition at line 498 of file tokenI.H.

References isScalar.

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

Here is the caller graph for this function:

◆ number()

Foam::scalar number ( ) const
inline

◆ isCompound()

bool isCompound ( ) const
inline

Definition at line 520 of file tokenI.H.

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

Here is the caller graph for this function:

◆ compoundToken()

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

Definition at line 525 of file tokenI.H.

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)

Definition at line 92 of file token.C.

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

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

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

◆ 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 clear().

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

Here is the call graph for this function:
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 clear(), and p.

Here is the call graph for this function:

◆ operator=() [3/17]

void operator= ( word wPtr)
inline

Definition at line 630 of file tokenI.H.

References clear().

Here is the call graph for this function:

◆ operator=() [4/17]

void operator= ( const word w)
inline

Definition at line 637 of file tokenI.H.

◆ operator=() [5/17]

void operator= ( functionName fnPtr)
inline

Definition at line 642 of file tokenI.H.

References clear().

Here is the call graph for this function:

◆ operator=() [6/17]

void operator= ( const functionName fn)
inline

Definition at line 649 of file tokenI.H.

◆ operator=() [7/17]

void operator= ( variable vPtr)
inline

Definition at line 654 of file tokenI.H.

References clear().

Here is the call graph for this function:

◆ operator=() [8/17]

void operator= ( const variable v)
inline

Definition at line 661 of file tokenI.H.

◆ operator=() [9/17]

void operator= ( string sPtr)
inline

Definition at line 666 of file tokenI.H.

References clear().

Here is the call graph for this function:

◆ operator=() [10/17]

void operator= ( const string s)
inline

Definition at line 673 of file tokenI.H.

References s().

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 clear().

Here is the call graph for this function:

◆ operator=() [12/17]

void operator= ( const verbatimString vs)
inline

Definition at line 685 of file tokenI.H.

◆ operator=() [13/17]

void operator= ( const label  l)
inline

Definition at line 690 of file tokenI.H.

References clear().

Here is the call graph for this function:

◆ operator=() [14/17]

void operator= ( const floatScalar  s)
inline

Definition at line 697 of file tokenI.H.

References clear(), 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 clear(), 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 clear(), and s().

Here is the call graph for this function:

◆ operator=() [17/17]

void operator= ( compound cPtr)
inline

Definition at line 718 of file tokenI.H.

References clear().

Here is the call graph for this function:

◆ operator==() [1/11]

◆ operator==() [2/11]

bool operator== ( const punctuationToken  p) const
inline

Definition at line 782 of file tokenI.H.

References p.

◆ operator==() [3/11]

bool operator== ( const word w) const
inline

Definition at line 787 of file tokenI.H.

◆ operator==() [4/11]

bool operator== ( const functionName fn) const
inline

Definition at line 792 of file tokenI.H.

◆ operator==() [5/11]

bool operator== ( const variable v) const
inline

Definition at line 797 of file tokenI.H.

◆ operator==() [6/11]

bool operator== ( const string s) const
inline

Definition at line 802 of file tokenI.H.

References s().

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.

◆ operator==() [8/11]

bool operator== ( const label  l) const
inline

Definition at line 812 of file tokenI.H.

◆ operator==() [9/11]

bool operator== ( const floatScalar  s) const
inline

Definition at line 817 of file tokenI.H.

References Foam::equal(), and s().

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 Foam::equal(), and s().

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(), and s().

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 Foam::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 Foam::operator==(), and p.

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 Foam::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 Foam::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 Foam::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 Foam::operator==(), and s().

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 Foam::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 Foam::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 Foam::operator==(), and s().

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 Foam::operator==(), and s().

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 Foam::operator==(), and s().

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_

Definition at line 250 of file token.H.

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

◆ wordTokenPtr_

word* wordTokenPtr_

Definition at line 251 of file token.H.

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

◆ functionNameTokenPtr_

functionName* functionNameTokenPtr_

Definition at line 252 of file token.H.

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

◆ variableTokenPtr_

variable* variableTokenPtr_

Definition at line 253 of file token.H.

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

◆ stringTokenPtr_

string* stringTokenPtr_

Definition at line 254 of file token.H.

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

◆ verbatimStringTokenPtr_

verbatimString* verbatimStringTokenPtr_

Definition at line 255 of file token.H.

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

◆ labelToken_

label labelToken_

Definition at line 256 of file token.H.

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

◆ floatScalarToken_

floatScalar floatScalarToken_

Definition at line 257 of file token.H.

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

◆ doubleScalarToken_

doubleScalar doubleScalarToken_

Definition at line 258 of file token.H.

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

◆ longDoubleScalarTokenPtr_

longDoubleScalar* longDoubleScalarTokenPtr_

Definition at line 259 of file token.H.

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

◆ compoundTokenPtr_

compound* compoundTokenPtr_
mutable

Definition at line 260 of file token.H.

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

◆ 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: