ex.hpp

См. документацию.
00001 /*
00002 
00003 Copyright (c) 2002-2005, Yauheni Akhotnikau
00004 All rights reserved.
00005 
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are met:
00008 
00009 - Redistributions of source code must retain the above copyright notice, this
00010 list of conditions and the following disclaimer.
00011 
00012 - Redistributions in binary form must reproduce the above copyright notice, this
00013 list of conditions and the following disclaimer in the documentation and/or
00014 other materials provided with the distribution.
00015 
00016 - The name of the author may not be used to endorse or promote products derived
00017 from this software without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00020 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00021 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00022 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00024 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00027 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00028 OF SUCH DAMAGE.
00029 
00030 */
00031 
00037 #if !defined( _OESS_1__DEFS__EX_HPP_ )
00038 #define _OESS_1__DEFS__EX_HPP_
00039 
00040 #include <oess_1/defs/h/declspec.hpp>
00041 
00042 #include <sstream>
00043 #include <exception>
00044 
00045 #include <oess_1/defs/h/err_code.hpp>
00046 
00047 namespace oess_1 {
00048 
00049 //
00050 // ex_t
00051 //
00052 
00056 class OESS_1__DEFS__TYPE  ex_t :
00057   public std::exception
00058 {
00059   public :
00060     ex_t( const err_code_t & err );
00061     ex_t( const ex_t & x );
00062     virtual ~ex_t() throw();
00063 
00064     ex_t &
00065     operator=( const ex_t & x );
00066 
00067     const err_code_t &
00068     query_err_code() const;
00069 
00072     virtual const char *
00073     what() const throw();
00074 
00075   private :
00076     err_code_t  m_err;
00077 
00079     std::string m_text_representation;
00080 
00082     void
00083     make_text_representation() throw();
00084 };
00085 
00086 //
00087 // logic_ex_t
00088 //
00089 
00094 class OESS_1__DEFS__TYPE  logic_ex_t : public ex_t {
00095   public :
00096     logic_ex_t( const err_code_t & err );
00097     logic_ex_t( const logic_ex_t & x );
00098     virtual ~logic_ex_t() throw();
00099 
00100     logic_ex_t &
00101     operator=( const logic_ex_t & x );
00102 };
00103 
00104 //
00105 // physic_ex_t
00106 //
00107 
00112 class OESS_1__DEFS__TYPE  physic_ex_t : public ex_t {
00113   public :
00114     physic_ex_t( const err_code_t & err );
00115     physic_ex_t( const physic_ex_t & x );
00116     virtual ~physic_ex_t() throw();
00117 
00118     physic_ex_t &
00119     operator=( const physic_ex_t & x );
00120 };
00121 
00122 //
00123 // Макросы для более легкого информирования об ошибках
00124 //
00125 
00134 #define OESS_THROW_LOGIC( c, m )\
00135 { \
00136   std::ostringstream msg; \
00137   msg << m; \
00138   throw oess_1::logic_ex_t( oess_1_make_err( c, msg.str() ) ); \
00139 }
00140 
00149 #define OESS_THROW_PHYSIC( c, m )\
00150 { \
00151   std::ostringstream msg; \
00152   msg << m; \
00153   throw oess_1::physic_ex_t( oess_1_make_err( c, msg.str() ) ); \
00154 }
00155 
00156 } /* namespace oess_1 */
00157 
00158 #endif

Документация по ObjESSty. Последние изменения: Fri Oct 13 18:35:36 2006. Создано системой  doxygen 1.4.7
Hosted by uCoz