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

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

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

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

206  :m_strMsg(szMsg)
207  , m_strFormula()
208  , m_strTok(sTok)
209  , m_iPos(iPos)
210  , m_iErrc(ecGENERIC)
211  , m_ErrMsg(ParserErrorMsg::Instance())
212  {
213  stringstream_type stream;
214  stream << (int)m_iPos;
215  ReplaceSubString(m_strMsg, _T("$POS$"), stream.str());
216  ReplaceSubString(m_strMsg, _T("$TOK$"), m_strTok);
217  }
#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:311
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 314 of file muParserError.cpp.

315  {
316  return m_iPos;
317  }

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