Seamly2D
Code documentation
qmu::QmuParserToken< TBase, TString > Class Template Reference

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

#include <qmuparsertoken.h>

Collaboration diagram for qmu::QmuParserToken< TBase, TString >:

Public Member Functions

 QmuParserToken ()
 Constructor (default). More...
 
 QmuParserToken (const QmuParserToken &a_Tok)
 Create token from another one. More...
 
QmuParserTokenoperator= (const QmuParserToken &a_Tok)
 Assignement operator. More...
 
void Assign (const QmuParserToken &a_Tok)
 Copy token information from argument. More...
 
QmuParserTokenSet (ECmdCode a_iType, const TString &a_strTok=TString())
 Assign a token type. More...
 
QmuParserTokenSet (const QmuParserCallback &a_pCallback, const TString &a_sTok)
 Set Callback type. More...
 
QmuParserTokenSetVal (TBase a_fVal, const TString &a_strTok=TString())
 Make this token a value token. More...
 
QmuParserTokenSetVar (TBase *a_pVar, const TString &a_strTok)
 make this token a variable token. More...
 
QmuParserTokenSetString (const TString &a_strTok, int 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
 
EOprtAssociativity GetAssociativity () const
 
generic_fun_type GetFuncAddr () const
 Return the address of the callback function assoziated with function and operator tokens. More...
 
TBase GetVal () const
 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...
 

Static Public Member Functions

template<class FunctionPtr >
static FunctionPtr union_cast (void *objectPtr)
 

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_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...
 
qreal m_fVal
 the value More...
 
std::unique_ptr< QmuParserCallbackm_pCallback
 

Detailed Description

template<typename TBase, typename TString>
class qmu::QmuParserToken< 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:

  • value
  • variable
  • function with numerical arguments
  • functions with a string as argument
  • prefix operators
  • infix operators
  • binary operator
Author
(C) 2004-2013 Ingo Berg

Definition at line 58 of file qmuparsertoken.h.

Constructor & Destructor Documentation

◆ QmuParserToken() [1/2]

template<typename TBase , typename TString >
qmu::QmuParserToken< TBase, TString >::QmuParserToken ( )
inline

Constructor (default).

Sets token to an neutral state of type cmUNKNOWN.

Exceptions
nothrow
See also
ECmdCode

Definition at line 69 of file qmuparsertoken.h.

◆ QmuParserToken() [2/2]

template<typename TBase , typename TString >
qmu::QmuParserToken< TBase, TString >::QmuParserToken ( const QmuParserToken< 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 83 of file qmuparsertoken.h.

References qmu::QmuParserToken< TBase, TString >::Assign().

Member Function Documentation

◆ Assign()

◆ GetArgCount()

template<typename TBase , typename TString >
int qmu::QmuParserToken< TBase, TString >::GetArgCount ( ) const
inline

Return the number of function arguments.

Valid only if m_iType==CmdFUNC.

Definition at line 444 of file qmuparsertoken.h.

References qmu::ecINTERNAL_ERROR, and qmu::QmuParserToken< TBase, TString >::m_pCallback.

Referenced by qmu::QmuParserBase::ApplyFunc(), and qmu::QmuParserBase::ApplyStrFunc().

◆ GetAssociativity()

template<typename TBase , typename TString >
EOprtAssociativity qmu::QmuParserToken< TBase, TString >::GetAssociativity ( ) const
inline

◆ GetAsString()

template<typename TBase , typename TString >
const TString& qmu::QmuParserToken< 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 466 of file qmuparsertoken.h.

References qmu::QmuParserToken< TBase, TString >::m_strTok.

Referenced by qmu::QmuParserBase::ApplyFunc(), qmu::QmuParserBase::ApplyStrFunc(), qmu::QmuParserBase::CreateRPN(), qmu::QmuParserTokenReader::IsFunTok(), qmu::QmuParserTokenReader::IsInfixOpTok(), qmu::QmuParserTokenReader::IsUndefVarTok(), and qmu::QmuParserBase::StackDump().

◆ GetCode()

◆ GetFuncAddr()

template<typename TBase , typename TString >
generic_fun_type qmu::QmuParserToken< 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
QmuParserErrorif token type is non of:
  • cmFUNC
  • cmSTRFUNC
  • cmPOSTOP
  • cmINFIXOP
  • cmOPRT_BIN
See also
ECmdCode

Definition at line 361 of file qmuparsertoken.h.

References qmu::QmuParserToken< TBase, TString >::m_pCallback.

Referenced by qmu::QmuParserBase::ApplyFunc(), and qmu::QmuParserBase::ApplyStrFunc().

◆ GetIdx()

template<typename TBase , typename TString >
int qmu::QmuParserToken< 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
QmuParserErrorif m_iIdx<0 or m_iType!=cmSTRING
Returns
The index the result will take in the Bytecode calculatin array (m_iIdx).

Definition at line 259 of file qmuparsertoken.h.

References qmu::cmSTRING, qmu::ecINTERNAL_ERROR, qmu::QmuParserToken< TBase, TString >::m_iCode, and qmu::QmuParserToken< TBase, TString >::m_iIdx.

◆ GetPri()

template<typename TBase , typename TString >
int qmu::QmuParserToken< TBase, TString >::GetPri ( ) const
inline

◆ GetType()

template<typename TBase , typename TString >
ETypeCode qmu::QmuParserToken< TBase, TString >::GetType ( ) const
inline

◆ GetVal()

◆ GetVar()

template<typename TBase , typename TString >
TBase* qmu::QmuParserToken< TBase, TString >::GetVar ( ) const
inline

Get address of a variable token.

Valid only if m_iType==CmdVar.

Exceptions
QmuParserErrorif token is no variable token.

Definition at line 428 of file qmuparsertoken.h.

References qmu::cmVAR, qmu::ecINTERNAL_ERROR, qmu::QmuParserToken< TBase, TString >::m_iCode, and qmu::QmuParserToken< TBase, TString >::m_pTok.

Referenced by qmu::QmuParserBase::CreateRPN().

◆ operator=()

template<typename TBase , typename TString >
QmuParserToken& qmu::QmuParserToken< TBase, TString >::operator= ( const QmuParserToken< 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 98 of file qmuparsertoken.h.

References qmu::QmuParserToken< TBase, TString >::Assign().

◆ Set() [1/2]

◆ Set() [2/2]

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

◆ SetIdx()

template<typename TBase , typename TString >
void qmu::QmuParserToken< 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
QmuParserErrorif #a_iIdx<0 or m_iType!=cmSTRING

Definition at line 240 of file qmuparsertoken.h.

References qmu::cmSTRING, qmu::ecINTERNAL_ERROR, qmu::QmuParserToken< TBase, TString >::m_iCode, and qmu::QmuParserToken< TBase, TString >::m_iIdx.

Referenced by qmu::QmuParserBase::CreateRPN().

◆ SetString()

template<typename TBase , typename TString >
QmuParserToken& qmu::QmuParserToken< TBase, TString >::SetString ( const TString &  a_strTok,
int  a_iSize 
)
inline

◆ SetVal()

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

◆ SetVar()

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

◆ union_cast()

template<typename TBase , typename TString >
template<class FunctionPtr >
static FunctionPtr qmu::QmuParserToken< TBase, TString >::union_cast ( void *  objectPtr)
inlinestatic

Definition at line 330 of file qmuparsertoken.h.

Member Data Documentation

◆ m_fVal

template<typename TBase , typename TString >
qreal qmu::QmuParserToken< TBase, TString >::m_fVal
private

◆ m_iCode

◆ m_iIdx

◆ m_iType

◆ m_pCallback

◆ m_pTok

◆ m_strTok

◆ m_strVal

template<typename TBase , typename TString >
TString qmu::QmuParserToken< TBase, TString >::m_strVal
private

Value for string variables.

Definition at line 476 of file qmuparsertoken.h.

Referenced by qmu::QmuParserToken< TBase, TString >::Assign().


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