muParser API -  1.35
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.

Part of the math parser package.

Definition at line 74 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 128 of file muParserError.cpp.

129  :m_strMsg()
130  , m_strFormula()
131  , m_strTok()
132  , m_iPos(-1)
133  , m_iErrc(a_iErrc)
134  , m_ErrMsg(ParserErrorMsg::Instance())
135  {
136  m_strMsg = m_ErrMsg[m_iErrc];
137  stringstream_type stream;
138  stream << (int)m_iPos;
139  ReplaceSubString(m_strMsg, _T("$POS$"), stream.str());
140  ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok);
141  }
#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:309
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 159 of file muParserError.cpp.

163  :m_strMsg()
164  , m_strFormula(sExpr)
165  , m_strTok(sTok)
166  , m_iPos(iPos)
167  , m_iErrc(iErrc)
168  , m_ErrMsg(ParserErrorMsg::Instance())
169  {
170  m_strMsg = m_ErrMsg[m_iErrc];
171  stringstream_type stream;
172  stream << (int)m_iPos;
173  ReplaceSubString(m_strMsg, _T("$POS$"), stream.str());
174  ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok);
175  }
#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:309
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 183 of file muParserError.cpp.

184  :m_strMsg()
185  , m_strFormula()
186  , m_strTok(sTok)
187  , m_iPos(iPos)
188  , m_iErrc(iErrc)
189  , m_ErrMsg(ParserErrorMsg::Instance())
190  {
191  m_strMsg = m_ErrMsg[m_iErrc];
192  stringstream_type stream;
193  stream << (int)m_iPos;
194  ReplaceSubString(m_strMsg, _T("$POS$"), stream.str());
195  ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok);
196  }
#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:309
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 204 of file muParserError.cpp.

205  :m_strMsg(szMsg)
206  , m_strFormula()
207  , m_strTok(sTok)
208  , m_iPos(iPos)
209  , m_iErrc(ecGENERIC)
210  , m_ErrMsg(ParserErrorMsg::Instance())
211  {
212  stringstream_type stream;
213  stream << (int)m_iPos;
214  ReplaceSubString(m_strMsg, _T("$POS$"), stream.str());
215  ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok);
216  }
#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:309
Generic error.
Definition: muParserDef.h:263

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 313 of file muParserError.cpp.

314  {
315  return m_iPos;
316  }

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