oasisexception.h

来自「使用stl技术,(还没看,是听说的)」· C头文件 代码 · 共 99 行

H
99
字号
/******************************************************************************

 * This source file is part of Bad Camel Gaming

 * Copyright (C) 2003  Zephie Greyvenstein

 * See Readme.html for acknowledgements

 *

 * This library is free software; you can redistribute it and/or

 * modify it under the terms of the GNU Lesser General Public

 * License as published by the Free Software Foundation; either

 * version 2.1 of the License, or (at your option) any later version.

 *

 * This library is distributed in the hope that it will be useful,

 * but WITHOUT ANY WARRANTY; without even the implied warranty of

 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

 * Lesser General Public License for more details.

 *

 * You should have received a copy of the GNU Lesser General Public

 * License along with this library; if not, write to the Free Software

 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

 *****************************************************************************/



/******************************************************************************

 * FILENAME    : oasisException.h

 * DESCRIPTION : The exception class

 * AUTHOR      : Zephie Greyvenstein

 *****************************************************************************/



/// Avoid double inclusion

#ifndef __EXCEPTION_H__

#define __EXCEPTION_H__



/// Include common stuff

#include "oasisCommon.h"



/// Define to throw the exception

/// Format : Exception( type, description, sourcefile )

#define oasisError( t, d, s ) throw( Oasis::exception( t, d, s, __FILE__, __LINE__ ) )



namespace Oasis {

  /// The exception class

  class _oasisExport exception {

  public:

    /// Type of exceptions that are thrown

    enum ExceptionType {    

      /// Null pointer

      ET_NULL_POINTER          = 0,      

      /// Item exists

      ET_DUPLICATE_ITEM        = 1,

      /// File gone awol

      ET_FILE_NOT_FOUND        = 2,

      /// Item could not be located

      ET_ITEM_NOT_FOUND        = 3,

      /// Other internal error

      ET_INTERNAL_ERROR        = 4

    };



    /// Constructor

    exception( uint8 errorType,

	       const string &description,

	       const string &sourceFile );

    /// Constructor

    exception( uint8 errorType,

	       const string &description,

	       const string &sourceFile,

	       char *file,

	       uint16 line );

    

    /// Copy constructor

    exception( const exception &rhs );



    /// Deconstructor

    virtual ~exception( );



    /// Assignment operation

    void operator = ( const exception &rhs );



    /// Get full description

    const string &getDescription( void ) const;

    /// Get the error number

    const uint8 getErrorNumber( void ) const;



  private:

    /// The source file

    string source;

    /// The description

    string fullDescription;

    /// The file name

    string fileName;

    /// The line number

    uint16 lineNo;

    /// Exception type

    uint8 exceptionType;



    /// Get the formatted error message

    const string _getErrorMessage( void ) const;

  };

};



#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?