NCBI C++ ToolKit
Public Types | Public Member Functions | Private Attributes | List of all members
mu::ParserToken< TBase, TString > Class Template Reference

Search Toolkit Book for mu::ParserToken

Encapsulation of the data for a single formula token. More...

#include <gui/utils/muparser/muParserToken.h>

+ Inheritance diagram for mu::ParserToken< TBase, TString >:
+ Collaboration diagram for mu::ParserToken< TBase, TString >:

Public Types

enum  ETokFlags { flVOLATILE = 1 }
 Additional token flags. More...
 

Public Member Functions

 ParserToken ()
 Constructor (default). More...
 
 ParserToken (const ParserToken &a_Tok)
 Create token from another one. More...
 
ParserTokenoperator= (const ParserToken &a_Tok)
 Assignement operator. More...
 
void Assign (const ParserToken &a_Tok)
 Copy token information from argument. More...
 
void AddFlags (int a_iFlags)
 Add additional flags to the token. More...
 
bool IsFlagSet (int a_iFlags) const
 Check if a certain flag ist set. More...
 
ParserTokenSet (ECmdCode a_iType, const TString &a_strTok=TString())
 Assign a token type. More...
 
ParserTokenSet (const ParserCallback &a_pCallback, const TString &a_sTok)
 Set Callback type. More...
 
ParserTokenSetVal (TBase a_fVal, const TString &a_strTok=TString())
 Make this token a value token. More...
 
ParserTokenSetVar (TBase *a_pVar, const TString &a_strTok)
 make this token a variable token. More...
 
ParserTokenSetString (const TString &a_strTok, std::size_t a_iSize)
 Make this token a variable token. More...
 
void SetIdx (int a_iIdx)
 Set an index associated with the token related data. More...
 
int GetIdx () const
 Return Index associated with the token related data. More...
 
ECmdCode GetCode () const
 Return the token type. More...
 
ETypeCode GetType () const
 
int GetPri () const
 
void * GetFuncAddr () const
 Return the address of the callback function assoziated with function and operator tokens. More...
 
TBase GetVal () const
 \biref Get value of the token. More...
 
TBase * GetVar () const
 Get address of a variable token. More...
 
int GetArgCount () const
 Return the number of function arguments. More...
 
const TString & GetAsString () const
 Return the token identifier. More...
 

Private Attributes

ECmdCode m_iCode
 Type of the token; The token type is a constant of type ECmdCode. More...
 
ETypeCode m_iType
 
void * m_pTok
 Stores Token pointer; not applicable for all tokens. More...
 
int m_iFlags
 Additional flags for the token. More...
 
int m_iIdx
 An otional index to an external buffer storing the token data. More...
 
TString m_strTok
 Token string. More...
 
TString m_strVal
 Value for string variables. More...
 
value_type m_fVal
 
std::unique_ptr< ParserCallbackm_pCallback
 

Detailed Description

template<typename TBase, typename TString>
class mu::ParserToken< TBase, TString >

Encapsulation of the data for a single formula token.

Formula token implementation. Part of the Math Parser Package. Formula tokens can be either one of the following:

Author
(C) 2004 Ingo Berg

Definition at line 61 of file muParserToken.h.

Member Enumeration Documentation

◆ ETokFlags

template<typename TBase , typename TString >
enum mu::ParserToken::ETokFlags

Additional token flags.

Enumerator
flVOLATILE 

Mark a token that depends on a variable or a function that is not conservative.

Definition at line 66 of file muParserToken.h.

Constructor & Destructor Documentation

◆ ParserToken() [1/2]

template<typename TBase , typename TString >
mu::ParserToken< TBase, TString >::ParserToken ( )
inline

Constructor (default).

Sets token to an neutral state of type cmUNKNOWN.

Exceptions
nothrow
See also
ECmdCode

Definition at line 92 of file muParserToken.h.

◆ ParserToken() [2/2]

template<typename TBase , typename TString >
mu::ParserToken< TBase, TString >::ParserToken ( const ParserToken< TBase, TString > &  a_Tok)
inline

Create token from another one.

Implemented by calling Assign(...)

Exceptions
nothrow
Postcondition
m_iType==cmUNKNOWN
See also
Assign

Definition at line 110 of file muParserToken.h.

Member Function Documentation

◆ AddFlags()

template<typename TBase , typename TString >
void mu::ParserToken< TBase, TString >::AddFlags ( int  a_iFlags)
inline

Add additional flags to the token.

Flags are currently used to mark volatile (non optimizeable) functions.

See also
m_iFlags, ETokFlags

Definition at line 153 of file muParserToken.h.

Referenced by mu::ParserBase::ApplyNumFunc(), mu::ParserBase::ApplyStrFunc(), mu::ParserToken< value_type, string_type >::Set(), mu::ParserToken< value_type, string_type >::SetString(), and mu::ParserToken< value_type, string_type >::SetVar().

◆ Assign()

template<typename TBase , typename TString >
void mu::ParserToken< TBase, TString >::Assign ( const ParserToken< TBase, TString > &  a_Tok)
inline

Copy token information from argument.

Exceptions
nothrow

Definition at line 133 of file muParserToken.h.

Referenced by mu::ParserToken< value_type, string_type >::operator=(), and mu::ParserToken< value_type, string_type >::ParserToken().

◆ GetArgCount()

template<typename TBase , typename TString >
int mu::ParserToken< TBase, TString >::GetArgCount ( ) const
inline

Return the number of function arguments.

Valid only if m_iType==CmdFUNC.

Definition at line 416 of file muParserToken.h.

Referenced by mu::ParserBase::ApplyFunc(), mu::ParserBase::ApplyNumFunc(), and mu::ParserBase::ApplyStrFunc().

◆ GetAsString()

template<typename TBase , typename TString >
const TString& mu::ParserToken< TBase, TString >::GetAsString ( ) const
inline

Return the token identifier.

If m_iType is cmSTRING the token identifier is the value of the string argument for a string function.

Returns
m_strTok
Exceptions
nothrow
See also
m_strTok

Definition at line 435 of file muParserToken.h.

Referenced by mu::ParserBase::ApplyFunc(), mu::ParserBase::ApplyNumFunc(), mu::ParserBase::ApplyStrFunc(), mu::ParserTokenReader::IsFunTok(), mu::ParserTokenReader::IsInfixOpTok(), mu::ParserTokenReader::IsOprt(), mu::ParserTokenReader::IsUndefVarTok(), and mu::ParserBase::ParseString().

◆ GetCode()

template<typename TBase , typename TString >
ECmdCode mu::ParserToken< TBase, TString >::GetCode ( void  ) const
inline

Return the token type.

Returns
m_iType
Exceptions
nothrow

Definition at line 324 of file muParserToken.h.

Referenced by mu::ParserBase::ApplyFunc(), mu::ParserBase::GetOprtPri(), mu::ParserTokenReader::IsBuiltIn(), and mu::ParserBase::ParseString().

◆ GetFuncAddr()

template<typename TBase , typename TString >
void* mu::ParserToken< TBase, TString >::GetFuncAddr ( ) const
inline

Return the address of the callback function assoziated with function and operator tokens.

Returns
The pointer stored in m_pTok.
Exceptions
exception_typeif token type is non of:
  • cmFUNC
  • cmSTRFUNC
  • cmPOSTOP
  • cmINFIXOP
  • cmOPRT_BIN
See also
ECmdCode

Definition at line 376 of file muParserToken.h.

Referenced by mu::ParserBase::ApplyFunc(), mu::ParserBase::ApplyNumFunc(), and mu::ParserBase::ApplyStrFunc().

◆ GetIdx()

template<typename TBase , typename TString >
int mu::ParserToken< TBase, TString >::GetIdx ( ) const
inline

Return Index associated with the token related data.

In cmSTRFUNC - This is the index to a string table in the main parser.

Exceptions
exception_typeif m_iIdx<0 or m_iType!=cmSTRING
Returns
The index the result will take in the Bytecode calculatin array (m_iIdx).

Definition at line 310 of file muParserToken.h.

◆ GetPri()

template<typename TBase , typename TString >
int mu::ParserToken< TBase, TString >::GetPri ( ) const
inline

Definition at line 350 of file muParserToken.h.

Referenced by mu::ParserBase::GetOprtPri().

◆ GetType()

template<typename TBase , typename TString >
ETypeCode mu::ParserToken< TBase, TString >::GetType ( void  ) const
inline

Definition at line 337 of file muParserToken.h.

Referenced by mu::ParserBase::ApplyBinOprt(), and mu::ParserBase::ApplyFunc().

◆ GetVal()

template<typename TBase , typename TString >
TBase mu::ParserToken< TBase, TString >::GetVal ( ) const
inline

\biref Get value of the token.

Only applicable to variable and value tokens.

Exceptions
exception_typeif token is no value/variable token.

Definition at line 387 of file muParserToken.h.

Referenced by mu::ParserBase::ApplyBinOprt(), mu::ParserBase::ApplyNumFunc(), and mu::ParserBase::ParseString().

◆ GetVar()

template<typename TBase , typename TString >
TBase* mu::ParserToken< TBase, TString >::GetVar ( ) const
inline

Get address of a variable token.

Valid only if m_iType==CmdVar.

Exceptions
exception_typeif token is no variable token.

Definition at line 403 of file muParserToken.h.

Referenced by mu::ParserBase::ParseString().

◆ IsFlagSet()

template<typename TBase , typename TString >
bool mu::ParserToken< TBase, TString >::IsFlagSet ( int  a_iFlags) const
inline

Check if a certain flag ist set.

Exceptions
nothrow

Definition at line 163 of file muParserToken.h.

Referenced by mu::ParserBase::ApplyBinOprt(), mu::ParserBase::ApplyNumFunc(), and mu::ParserBase::ApplyStrFunc().

◆ operator=()

template<typename TBase , typename TString >
ParserToken& mu::ParserToken< TBase, TString >::operator= ( const ParserToken< TBase, TString > &  a_Tok)
inline

Assignement operator.

Copy token state from another token and return this. Implemented by calling Assign(...).

Exceptions
nothrow

Definition at line 122 of file muParserToken.h.

◆ Set() [1/2]

template<typename TBase , typename TString >
ParserToken& mu::ParserToken< TBase, TString >::Set ( const ParserCallback a_pCallback,
const TString &  a_sTok 
)
inline

Set Callback type.

Definition at line 206 of file muParserToken.h.

◆ Set() [2/2]

template<typename TBase , typename TString >
ParserToken& mu::ParserToken< TBase, TString >::Set ( ECmdCode  a_iType,
const TString &  a_strTok = TString() 
)
inline

Assign a token type.

Token may not be of type value, variable or function. Those have seperate set functions.

Precondition
[assert] a_iType!=cmVAR
[assert] a_iType!=cmVAL
[assert] a_iType!=cmFUNC
Postcondition
m_fVal = 0
m_pTok = 0

Definition at line 187 of file muParserToken.h.

Referenced by mu::ParserTokenReader::IsArgSep(), mu::ParserTokenReader::IsBuiltIn(), mu::ParserTokenReader::IsEOF(), mu::ParserTokenReader::IsFunTok(), mu::ParserTokenReader::IsInfixOpTok(), mu::ParserTokenReader::IsOprt(), and mu::ParserTokenReader::IsPostOpTok().

◆ SetIdx()

template<typename TBase , typename TString >
void mu::ParserToken< TBase, TString >::SetIdx ( int  a_iIdx)
inline

Set an index associated with the token related data.

In cmSTRFUNC - This is the index to a string table in the main parser.

Parameters
a_iIdxThe index the string function result will take in the bytecode parser.
Exceptions
exception_typeif #a_iIdx<0 or m_iType!=cmSTRING

Definition at line 294 of file muParserToken.h.

Referenced by mu::ParserBase::ParseString().

◆ SetString()

template<typename TBase , typename TString >
ParserToken& mu::ParserToken< TBase, TString >::SetString ( const TString &  a_strTok,
std::size_t  a_iSize 
)
inline

Make this token a variable token.

Member variables not necessary for variable tokens will be invalidated.

Exceptions
nothrow

Definition at line 272 of file muParserToken.h.

Referenced by mu::ParserTokenReader::IsString(), and mu::ParserTokenReader::IsStrVarTok().

◆ SetVal()

template<typename TBase , typename TString >
ParserToken& mu::ParserToken< TBase, TString >::SetVal ( TBase  a_fVal,
const TString &  a_strTok = TString() 
)
inline

Make this token a value token.

Member variables not necessary for value tokens will be invalidated.

Exceptions
nothrow

Definition at line 231 of file muParserToken.h.

Referenced by mu::ParserBase::ApplyNumFunc(), mu::ParserBase::ApplyStrFunc(), and mu::ParserTokenReader::IsValTok().

◆ SetVar()

template<typename TBase , typename TString >
ParserToken& mu::ParserToken< TBase, TString >::SetVar ( TBase *  a_pVar,
const TString &  a_strTok 
)
inline

make this token a variable token.

Member variables not necessary for variable tokens will be invalidated.

Exceptions
nothrow

Definition at line 252 of file muParserToken.h.

Referenced by mu::ParserTokenReader::IsUndefVarTok(), and mu::ParserTokenReader::IsVarTok().

Member Data Documentation

◆ m_fVal

template<typename TBase , typename TString >
value_type mu::ParserToken< TBase, TString >::m_fVal
private

◆ m_iCode

template<typename TBase , typename TString >
ECmdCode mu::ParserToken< TBase, TString >::m_iCode
private

◆ m_iFlags

template<typename TBase , typename TString >
int mu::ParserToken< TBase, TString >::m_iFlags
private

◆ m_iIdx

template<typename TBase , typename TString >
int mu::ParserToken< TBase, TString >::m_iIdx
private

◆ m_iType

template<typename TBase , typename TString >
ETypeCode mu::ParserToken< TBase, TString >::m_iType
private

◆ m_pCallback

template<typename TBase , typename TString >
std::unique_ptr<ParserCallback> mu::ParserToken< TBase, TString >::m_pCallback
private

◆ m_pTok

template<typename TBase , typename TString >
void* mu::ParserToken< TBase, TString >::m_pTok
private

◆ m_strTok

template<typename TBase , typename TString >
TString mu::ParserToken< TBase, TString >::m_strTok
private

◆ m_strVal

template<typename TBase , typename TString >
TString mu::ParserToken< TBase, TString >::m_strVal
private

Value for string variables.

Definition at line 79 of file muParserToken.h.

Referenced by mu::ParserToken< value_type, string_type >::Assign().


The documentation for this class was generated from the following file:
Modified on Mon Apr 22 04:01:28 2024 by modify_doxy.py rev. 669887