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 #ifndef MYSQLPP_NOEXCEPTIONS_H
00039 #define MYSQLPP_NOEXCEPTIONS_H
00040
00041 namespace mysqlpp {
00042
00043 #if !defined(DOXYGEN_IGNORE)
00044
00045 class MYSQLPP_EXPORT NoExceptions;
00046 #endif
00047
00053
00054 class MYSQLPP_EXPORT OptionalExceptions
00055 {
00056 public:
00060 OptionalExceptions(bool e = true) :
00061 exceptions_(e)
00062 {
00063 }
00064
00066 virtual ~OptionalExceptions() { }
00067
00069 void enable_exceptions() { exceptions_ = true; }
00070
00072 void disable_exceptions() { exceptions_ = false; }
00073
00075 bool throw_exceptions() const { return exceptions_; }
00076
00077 protected:
00082 void set_exceptions(bool e) { exceptions_ = e; }
00083
00086 friend class NoExceptions;
00087
00088 private:
00089 bool exceptions_;
00090 };
00091
00092
00101
00102 class MYSQLPP_EXPORT NoExceptions
00103 {
00104 public:
00110 NoExceptions(OptionalExceptions& a) :
00111 assoc_(a),
00112 exceptions_were_enabled_(a.throw_exceptions())
00113 {
00114 assoc_.disable_exceptions();
00115 }
00116
00120 ~NoExceptions()
00121 {
00122 assoc_.set_exceptions(exceptions_were_enabled_);
00123 }
00124
00125 private:
00126 OptionalExceptions& assoc_;
00127 bool exceptions_were_enabled_;
00128
00129
00130
00131 NoExceptions(const NoExceptions&);
00132 NoExceptions& operator=(const NoExceptions&);
00133 };
00134
00135 }
00136
00137 #endif // MYSQLPP_NOEXCEPTIONS_H
00138