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

Error class of the parser. More...

#include <muParserError.h>

Public Member Functions

 ParserError ()
 Default constructor.
 
 ParserError (EErrorCodes a_iErrc)
 This Constructor is used for internal exceptions only. More...
 
 ParserError (const string_type &sMsg)
 Construct an error from a message text.
 
 ParserError (EErrorCodes a_iErrc, const string_type &sTok, const string_type &sFormula=string_type(), int a_iPos=-1)
 Construct an error object. More...
 
 ParserError (EErrorCodes a_iErrc, int a_iPos, const string_type &sTok)
 Construct an error object. More...
 
 ParserError (const char_type *a_szMsg, int a_iPos=-1, const string_type &sTok=string_type())
 Construct an error object. More...
 
 ParserError (const ParserError &a_Obj)
 Copy constructor.
 
ParserErroroperator= (const ParserError &a_Obj)
 Assignment operator.
 
void SetFormula (const string_type &a_strFormula)
 Set the expression related to this error.
 
const string_typeGetExpr () const
 gets the expression related tp this error.
 
const string_typeGetMsg () const
 Returns the message string for this error.
 
int GetPos () const
 Return the formula position related to the error. More...
 
const string_typeGetToken () const
 Return string related with this token (if available).
 
EErrorCodes GetCode () const
 Return the error code.
 

Detailed Description

Error class of the parser.

Author
Ingo Berg

Part of the math parser package.

Definition at line 128 of file muParserError.h.

Constructor & Destructor Documentation

mu::ParserError::ParserError ( EErrorCodes  a_iErrc)
explicit

This Constructor is used for internal exceptions only.

It does not contain any information but the error code.

Definition at line 134 of file muParserError.cpp.

135  :m_strMsg()
136  ,m_strFormula()
137  ,m_strTok()
138  ,m_iPos(-1)
139  ,m_iErrc(a_iErrc)
140  ,m_ErrMsg(ParserErrorMsg::Instance())
141  {
142  m_strMsg = m_ErrMsg[m_iErrc];
143  stringstream_type stream;
144  stream << (int)m_iPos;
145  ReplaceSubString(m_strMsg, _T("$POS$"), stream.str());
146  ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok);
147  }
#define _T(x)
Activate this option in order to compile with OpenMP support.
Definition: muParserDef.h:69
std::basic_stringstream< char_type, std::char_traits< char_type >, std::allocator< char_type > > stringstream_type
Typedef for easily using stringstream that respect the parser stringtype.
Definition: muParserDef.h:264
mu::ParserError::ParserError ( EErrorCodes  iErrc,
const string_type sTok,
const string_type sExpr = string_type(),
int  iPos = -1 
)

Construct an error object.

Parameters
[in]a_iErrcthe error code.
[in]sTokThe token string related to this error.
[in]sExprThe expression related to the error.
[in]a_iPosthe position in the expression where the error occurred.

Definition at line 165 of file muParserError.cpp.

169  :m_strMsg()
170  ,m_strFormula(sExpr)
171  ,m_strTok(sTok)
172  ,m_iPos(iPos)
173  ,m_iErrc(iErrc)
174  ,m_ErrMsg(ParserErrorMsg::Instance())
175  {
176  m_strMsg = m_ErrMsg[m_iErrc];
177  stringstream_type stream;
178  stream << (int)m_iPos;
179  ReplaceSubString(m_strMsg, _T("$POS$"), stream.str());
180  ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok);
181  }
#define _T(x)
Activate this option in order to compile with OpenMP support.
Definition: muParserDef.h:69
std::basic_stringstream< char_type, std::char_traits< char_type >, std::allocator< char_type > > stringstream_type
Typedef for easily using stringstream that respect the parser stringtype.
Definition: muParserDef.h:264
mu::ParserError::ParserError ( EErrorCodes  iErrc,
int  iPos,
const string_type sTok 
)

Construct an error object.

Parameters
[in]iErrcthe error code.
[in]iPosthe position in the expression where the error occurred.
[in]sTokThe token string related to this error.

Definition at line 189 of file muParserError.cpp.

190  :m_strMsg()
191  ,m_strFormula()
192  ,m_strTok(sTok)
193  ,m_iPos(iPos)
194  ,m_iErrc(iErrc)
195  ,m_ErrMsg(ParserErrorMsg::Instance())
196  {
197  m_strMsg = m_ErrMsg[m_iErrc];
198  stringstream_type stream;
199  stream << (int)m_iPos;
200  ReplaceSubString(m_strMsg, _T("$POS$"), stream.str());
201  ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok);
202  }
#define _T(x)
Activate this option in order to compile with OpenMP support.
Definition: muParserDef.h:69
std::basic_stringstream< char_type, std::char_traits< char_type >, std::allocator< char_type > > stringstream_type
Typedef for easily using stringstream that respect the parser stringtype.
Definition: muParserDef.h:264
mu::ParserError::ParserError ( const char_type szMsg,
int  iPos = -1,
const string_type sTok = string_type() 
)

Construct an error object.

Parameters
[in]szMsgThe error message text.
[in]iPosthe position related to the error.
[in]sTokThe token string related to this error.

Definition at line 210 of file muParserError.cpp.

211  :m_strMsg(szMsg)
212  ,m_strFormula()
213  ,m_strTok(sTok)
214  ,m_iPos(iPos)
215  ,m_iErrc(ecGENERIC)
216  ,m_ErrMsg(ParserErrorMsg::Instance())
217  {
218  stringstream_type stream;
219  stream << (int)m_iPos;
220  ReplaceSubString(m_strMsg, _T("$POS$"), stream.str());
221  ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok);
222  }
#define _T(x)
Activate this option in order to compile with OpenMP support.
Definition: muParserDef.h:69
std::basic_stringstream< char_type, std::char_traits< char_type >, std::allocator< char_type > > stringstream_type
Typedef for easily using stringstream that respect the parser stringtype.
Definition: muParserDef.h:264
Generic error.
Definition: muParserError.h:83

Member Function Documentation

int mu::ParserError::GetPos ( ) const

Return the formula position related to the error.

If the error is not related to a distinct position this will return -1

Definition at line 319 of file muParserError.cpp.

320  {
321  return m_iPos;
322  }

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