Antiprism 0.23

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions

# mu::ParserToken< TBase, TString > Class Template Reference

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

`#include <muParserToken.h>`

List of all members.

## Public Member Functions
| ParserToken ()
| Constructor (default).
| ParserToken (const ParserToken &a_Tok)
| Create token from another one.
ParserToken & | operator= (const ParserToken &a_Tok)
| Assignement operator.
void | Assign (const ParserToken &a_Tok)
| Copy token information from argument.
ParserToken & | Set (ECmdCode a_iType, const TString &a_strTok=TString())
| Assign a token type.
ParserToken & | Set (const ParserCallback &a_pCallback, const TString &a_sTok)
| Set Callback type.
ParserToken & | SetVal (TBase a_fVal, const TString &a_strTok=TString())
| Make this token a value token.
ParserToken & | SetVar (TBase *a_pVar, const TString &a_strTok)
| make this token a variable token.
ParserToken & | SetString (const TString &a_strTok, std::size_t a_iSize)
| Make this token a variable token.
void | SetIdx (int a_iIdx)
| Set an index associated with the token related data.
int | GetIdx () const
| Return Index associated with the token related data.
ECmdCode | GetCode () const
| Return the token type.
generic_fun_type | GetFuncAddr () const
| Return the address of the callback function assoziated with function and operator tokens.
TBase | GetVal () const
TBase * | GetVar () const
| Get address of a variable token.
int | GetArgCount () const
| Return the number of function arguments.
const TString & | GetAsString () const
| Return the token identifier.

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

- value
- variable
- function with numerical arguments
- functions with a string as argument
- prefix operators
- infix operators
- binary operator

Author:
  (C) 2004-2012 Ingo Berg

## Constructor & Destructor Documentation

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

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

## Member Function Documentation

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 |

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.

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

template<typename TBase, typename TString>

ECmdCode mu::ParserToken< TBase, TString >::GetCode | ( |  | ) | const`[inline]`

Return the token type.

Returns:
  #m_iType

Exceptions:

  nothrow |

template<typename TBase, typename TString>

generic_fun_type 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_type | if token type is non of: cmFUNC cmSTRFUNC cmPOSTOP cmINFIXOP cmOPRT_BIN

See also:
  ECmdCode

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_type | if #m_iIdx<0 or #m_iType!=cmSTRING

Returns:
  The index the result will take in the Bytecode calculatin array (#m_iIdx).

template<typename TBase, typename TString>

TBase mu::ParserToken< TBase, TString >::GetVal | ( |  | ) | const`[inline]`

Get value of the token.

Only applicable to variable and value tokens.

Exceptions:

  exception_type | if token is no value/variable token.

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_type | if token is no variable token.

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 |

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

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_iIdx | The index the string function result will take in the bytecode parser.

Exceptions:

  exception_type | if #a_iIdx<0 or #m_iType!=cmSTRING

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 |

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 |

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 |

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

- base/muparser/muParserToken.h