📄 except.h
字号:
/******************************************************************************
文件名 :Except.h
版本号 : 1.0
作者 : Amos Peng
生成日期 :2008-07-08
最近修改 :
功能描述 :异常类及子类
函数列表 :
*******************************************************************************/
#ifndef _EXCEPT_H_
#define _EXCEPT_H_
// Includes
#include <exception>
#include <string>
// Part of expreval namespace
namespace ExprEval
{
// Forward declarations
class CExpression;
// Exception class
//--------------------------------------------------------------------------
class CException : public ::std::exception
{
public:
// Types of exceptions (to simplify some error handling)
// Each exception must set m_type in the construct
// Each exception should have a different type
enum Type
{
Type_Exception = 1,
Type_NotFoundException,
Type_AlreadyExistsException,
Type_NullPointerException,
Type_MathException,
Type_DivideByZeroException,
Type_NoValueListException,
Type_NoFunctionListException,
Type_AbortException,
Type_EmptyExpressionException,
Type_UnknownTokenException,
Type_InvalidArgumentCountException,
Type_ConstantAssignException,
Type_ConstantReferenceException,
Type_SyntaxException,
Type_UnmatchedParenthesisException
};
CException();
virtual ~CException() throw();
Type GetType() const;
const ::std::string& GetValue() const;
void SetStart(::std::string::size_type start);
void SetEnd(::std::string::size_type end);
::std::string::size_type GetStart() const;
::std::string::size_type GetEnd() const;
protected:
Type m_type;
::std::string m_value;
::std::string::size_type m_start, m_end;
};
// Not found exception (for functions)
//--------------------------------------------------------------------------
class CNotFoundException : public CException
{
public:
CNotFoundException(const ::std::string &name);
};
// Already exists exception (function or value already exists)
//--------------------------------------------------------------------------
class CAlreadyExistsException : public CException
{
public:
CAlreadyExistsException(const ::std::string &name);
};
// A null pointer was passed
//--------------------------------------------------------------------------
class CNullPointerException : public CException
{
public:
CNullPointerException(const ::std::string &method);
};
// A bad math error occured
//--------------------------------------------------------------------------
class CMathException : public CException
{
public:
CMathException(const ::std::string &function);
};
// Divide by zero exception
//--------------------------------------------------------------------------
class CDivideByZeroException : public CException
{
public:
CDivideByZeroException();
};
// No value list exception (if expression uses variables or constants
// but list does not exist) during parsing
//--------------------------------------------------------------------------
class CNoValueListException : public CException
{
public:
CNoValueListException();
};
// No function list exception (if expression uses functions) during parsing
//--------------------------------------------------------------------------
class CNoFunctionListException : public CException
{
public:
CNoFunctionListException();
};
// Abort exception (if DoTestAbort returns true)
//--------------------------------------------------------------------------
class CAbortException : public CException
{
public:
CAbortException();
};
// Empty expression (for parsing or evaluation)
//--------------------------------------------------------------------------
class CEmptyExpressionException : public CException
{
public:
CEmptyExpressionException();
};
// Unknown token in expression string
//--------------------------------------------------------------------------
class CUnknownTokenException : public CException
{
public:
CUnknownTokenException();
};
// Invalid argument count to function
//--------------------------------------------------------------------------
class CInvalidArgumentCountException : public CException
{
public:
CInvalidArgumentCountException(const ::std::string &function);
};
// Assign to a constant
//--------------------------------------------------------------------------
class CConstantAssignException : public CException
{
public:
CConstantAssignException(const ::std::string &value);
};
// Pass constant by reference
//--------------------------------------------------------------------------
class CConstantReferenceException : public CException
{
public:
CConstantReferenceException(const ::std::string &value);
};
// A general syntax exception
//--------------------------------------------------------------------------
class CSyntaxException : public CException
{
public:
CSyntaxException();
};
// Unmatched parenthesis
//--------------------------------------------------------------------------
class CUnmatchedParenthesisException : public CException
{
public:
CUnmatchedParenthesisException();
};
} // namespace ExprEval
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -