muParser API -  1.35
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Member Functions | List of all members
mu::ParserTokenReader Class Reference

Token reader for the ParserBase class. More...

#include <muParserTokenReader.h>

Public Member Functions

 ParserTokenReader (ParserBase *a_pParent)
 Constructor. More...
 
ParserTokenReaderClone (ParserBase *a_pParent) const
 Create instance of a ParserTokenReader identical with this and return its pointer. More...
 
void AddValIdent (identfun_type a_pCallback)
 
void SetVarCreator (facfun_type a_pFactory, void *pUserData)
 
void SetFormula (const string_type &a_strFormula)
 Initialize the token Reader. More...
 
void SetArgSep (char_type cArgSep)
 
int GetPos () const
 Return the current position of the token reader in the formula string. More...
 
const string_typeGetExpr () const
 Return a reference to the formula. More...
 
varmap_typeGetUsedVar ()
 Return a map containing the used variables only.
 
char_type GetArgSep () const
 
void IgnoreUndefVar (bool bIgnore)
 Set Flag that controls behaviour in case of undefined variables being found. More...
 
void ReInit ()
 Reset the token reader to the start of the formula. More...
 
token_type ReadNextToken ()
 Read the next token from the string.
 

Detailed Description

Token reader for the ParserBase class.

Definition at line 54 of file muParserTokenReader.h.

Constructor & Destructor Documentation

mu::ParserTokenReader::ParserTokenReader ( ParserBase a_pParent)

Constructor.

Create a Token reader and bind it to a parser object.

Precondition
[assert] a_pParser may not be NULL
Postcondition
#m_pParser==a_pParser
Parameters
a_pParentParent parser object of the token reader.

Definition at line 113 of file muParserTokenReader.cpp.

Referenced by Clone().

114  :m_pParser(a_pParent)
115  ,m_strFormula()
116  ,m_iPos(0)
117  ,m_iSynFlags(0)
118  ,m_bIgnoreUndefVar(false)
119  ,m_pFunDef(NULL)
120  ,m_pPostOprtDef(NULL)
121  ,m_pInfixOprtDef(NULL)
122  ,m_pOprtDef(NULL)
123  ,m_pConstDef(NULL)
124  ,m_pStrVarDef(NULL)
125  ,m_pVarDef(NULL)
126  ,m_pFactory(NULL)
127  ,m_pFactoryData(NULL)
128  ,m_vIdentFun()
129  ,m_UsedVar()
130  ,m_fZero(0)
131  ,m_iBrackets(0)
132  ,m_lastTok()
133  ,m_cArgSep(',')
134  {
135  assert(m_pParser);
136  SetParent(m_pParser);
137  }

Member Function Documentation

ParserTokenReader * mu::ParserTokenReader::Clone ( ParserBase a_pParent) const

Create instance of a ParserTokenReader identical with this and return its pointer.

This is a factory method the calling function must take care of the object destruction.

Returns
A new ParserTokenReader object.
Exceptions
nothrow

Definition at line 148 of file muParserTokenReader.cpp.

149  {
150  std::auto_ptr<ParserTokenReader> ptr(new ParserTokenReader(*this));
151  ptr->SetParent(a_pParent);
152  return ptr.release();
153  }
ParserTokenReader(ParserBase *a_pParent)
Constructor.
const string_type & mu::ParserTokenReader::GetExpr ( ) const

Return a reference to the formula.

Returns
#m_strFormula
Exceptions
nothrow

Definition at line 198 of file muParserTokenReader.cpp.

199  {
200  return m_strFormula;
201  }
int mu::ParserTokenReader::GetPos ( ) const

Return the current position of the token reader in the formula string.

Returns
#m_iPos
Exceptions
nothrow

Definition at line 187 of file muParserTokenReader.cpp.

188  {
189  return m_iPos;
190  }
void mu::ParserTokenReader::IgnoreUndefVar ( bool  bIgnore)

Set Flag that controls behaviour in case of undefined variables being found.

If true, the parser does not throw an exception if an undefined variable is found. otherwise it does. This variable is used internally only! It suppresses a "undefined variable" exception in GetUsedVar(). Those function should return a complete list of variables including those the are not defined by the time of it's call.

Definition at line 231 of file muParserTokenReader.cpp.

232  {
233  m_bIgnoreUndefVar = bIgnore;
234  }
void mu::ParserTokenReader::ReInit ( )

Reset the token reader to the start of the formula.

The syntax flags will be reset to a value appropriate for the start of a formula.

Postcondition
#m_iPos==0, #m_iSynFlags = noOPT | noBC | noPOSTOP | noSTR
Exceptions
nothrow
See also
ESynCodes

Definition at line 245 of file muParserTokenReader.cpp.

Referenced by SetFormula().

246  {
247  m_iPos = 0;
248  m_iSynFlags = sfSTART_OF_LINE;
249  m_iBrackets = 0;
250  m_UsedVar.clear();
251  m_lastTok = token_type();
252  }
void mu::ParserTokenReader::SetFormula ( const string_type a_strFormula)

Initialize the token Reader.

Sets the formula position index to zero and set Syntax flags to default for initial formula parsing.

Precondition
[assert] triggered if a_szFormula==0

Definition at line 216 of file muParserTokenReader.cpp.

217  {
218  m_strFormula = a_strFormula;
219  ReInit();
220  }
void ReInit()
Reset the token reader to the start of the formula.

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