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 class NoExceptions;
00044
00050
00051 class OptionalExceptions
00052 {
00053 public:
00057 OptionalExceptions(bool e = true) :
00058 exceptions_(e)
00059 {
00060 }
00061
00063 virtual ~OptionalExceptions() { }
00064
00066 void enable_exceptions() { exceptions_ = true; }
00067
00069 void disable_exceptions() { exceptions_ = false; }
00070
00072 bool throw_exceptions() const { return exceptions_; }
00073
00074 protected:
00079 void set_exceptions(bool e) { exceptions_ = e; }
00080
00083 friend class NoExceptions;
00084
00085 private:
00086 bool exceptions_;
00087 };
00088
00089
00098
00099 class NoExceptions
00100 {
00101 public:
00107 NoExceptions(OptionalExceptions& a) :
00108 assoc_(a),
00109 exceptions_were_enabled_(a.throw_exceptions())
00110 {
00111 assoc_.disable_exceptions();
00112 }
00113
00117 ~NoExceptions()
00118 {
00119 assoc_.set_exceptions(exceptions_were_enabled_);
00120 }
00121
00122 private:
00123 OptionalExceptions& assoc_;
00124 bool exceptions_were_enabled_;
00125
00126
00127
00128 NoExceptions(const NoExceptions&);
00129 NoExceptions& operator=(const NoExceptions&);
00130 };
00131
00132 }
00133
00134 #endif // MYSQLPP_NOEXCEPTIONS_H
00135