00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00048 #ifndef STLSOFT_INCL_STLSOFT_ERROR_HPP_CONTRACT_VIOLATION
00049 #define STLSOFT_INCL_STLSOFT_ERROR_HPP_CONTRACT_VIOLATION
00050
00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00052 # define STLSOFT_VER_STLSOFT_ERROR_HPP_CONTRACT_VIOLATION_MAJOR 2
00053 # define STLSOFT_VER_STLSOFT_ERROR_HPP_CONTRACT_VIOLATION_MINOR 0
00054 # define STLSOFT_VER_STLSOFT_ERROR_HPP_CONTRACT_VIOLATION_REVISION 2
00055 # define STLSOFT_VER_STLSOFT_ERROR_HPP_CONTRACT_VIOLATION_EDIT 20
00056 #endif
00057
00058
00059
00060
00061
00062 #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
00063 # include <stlsoft/stlsoft.h>
00064 #endif
00065 #ifndef STLSOFT_INCL_STLSOFT_ERROR_HPP_UNRECOVERABLE
00066 # include <stlsoft/error/unrecoverable.hpp>
00067 #endif
00068
00069 #ifndef STLSOFT_INCL_STRING
00070 # define STLSOFT_INCL_STRING
00071 # include <string>
00072 #endif
00073
00074
00075
00076
00077
00078 #ifndef _STLSOFT_NO_NAMESPACE
00079 namespace stlsoft
00080 {
00081 #endif
00082
00083
00084
00085
00086
00094 class contract_violation
00095 : public unrecoverable
00096 {
00099 private:
00100 #ifdef STLSOFT_CF_std_NAMESPACE
00101 typedef stlsoft_ns_qual_std(string) string_type;
00102 #else
00103 # if defined(STLSOFT_COMPILER_IS_WATCOM)
00104 class string_type
00105 : public stlsoft_ns_qual_std(string)
00106 {
00107 private:
00108 typedef stlsoft_ns_qual_std(string) parent_class_type;
00109 public:
00110 string_type(char const* s) : parent_class_type(s) {}
00111 string_type() : parent_class_type() {}
00112 string_type(string_type const& rhs) : parent_class_type(rhs) {}
00113 public:
00114 char const* c_str() const { return *this; }
00115 bool empty() const { return (NULL == this->c_str() || '\0' == *this->c_str()); }
00116 };
00117 # else
00118 # error No other non-std compiler supported
00119 # endif
00120 #endif
00121 public:
00123 typedef unrecoverable parent_class_type;
00125 typedef contract_violation class_type;
00127
00130 public:
00132 contract_violation()
00133 : parent_class_type(NULL)
00134 , m_error()
00135 {}
00141 ss_explicit_k contract_violation( void (*pfnHandler)())
00142 : parent_class_type(pfnHandler)
00143 , m_error()
00144 {}
00145 ss_explicit_k contract_violation( char const *error
00146 , void (*pfnHandler)() = NULL)
00147 : parent_class_type(pfnHandler)
00148 , m_error(error)
00149 {}
00150 ss_explicit_k contract_violation( string_type const &error
00151 , void (*pfnHandler)() = NULL)
00152 : parent_class_type(pfnHandler)
00153 , m_error(error)
00154 {}
00158 contract_violation(class_type const& rhs)
00159 : parent_class_type(rhs)
00160 , m_error(rhs.m_error)
00161 {}
00162 virtual ~contract_violation() stlsoft_throw_0()
00163 {}
00165
00168 public:
00170 virtual char const* what() const throw()
00171 {
00172 return m_error.empty() ? default_message_() : m_error.c_str();
00173 }
00175
00178 private:
00179 static char const *default_message_()
00180 {
00181 return "contract violation";
00182 }
00184
00187 private:
00188 const string_type m_error;
00190
00191
00192 private:
00193 class_type& operator =(class_type const&);
00194 };
00195
00196
00197
00198 #ifndef _STLSOFT_NO_NAMESPACE
00199 }
00200 #endif
00201
00202
00203
00204 #endif
00205
00206