00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _psqlvalue_h_
00021 #define _psqlvalue_h_
00022
00023 #include <pclasses/pexport.h>
00024 #include <pclasses/ptypes.h>
00025 #include <pclasses/ptime.h>
00026 #include <pclasses/psqlerror.h>
00027 #include <string>
00028
00029 namespace P {
00030
00032
00035 class PSQL_EXPORT SQLValue {
00036 public:
00037 virtual ~SQLValue();
00038
00039 inline bool isNull() const throw()
00040 { return m_null; }
00041
00042 virtual void setNull() throw() = 0;
00043
00044 virtual std::string str() const throw() = 0;
00045
00046 protected:
00047 SQLValue(bool null = true);
00048 bool m_null;
00049 };
00050
00052
00055 class PSQL_EXPORT SQLString: public SQLValue {
00056 public:
00058 SQLString();
00060 SQLString(const std::string& str);
00061 ~SQLString();
00062
00063 void setNull() throw();
00064
00065 const std::string& value() const throw();
00066 std::string str() const throw();
00067
00068 SQLString& operator=(const std::string& str);
00069
00070 private:
00071 std::string m_str;
00072 };
00073
00075
00078 class PSQL_EXPORT SQLInt: public SQLValue {
00079 public:
00081 SQLInt();
00083 SQLInt(int val);
00084 ~SQLInt();
00085
00086 void setNull() throw();
00087
00088 int value() const throw();
00089 std::string str() const throw();
00090
00091 SQLInt& operator=(int val);
00092
00093 private:
00094 int m_val;
00095 };
00096
00097
00098 #ifdef HAVE_64BIT_INT
00099
00101
00104 class PSQL_EXPORT SQLBigInt: public SQLValue {
00105 public:
00107 SQLBigInt();
00109 SQLBigInt(int64_t val);
00110 ~SQLBigInt();
00111
00112 void setNull() throw();
00113
00114 int64_t value() const throw();
00115 std::string str() const throw();
00116
00117 SQLBigInt& operator=(int64_t val);
00118
00119 private:
00120 int64_t m_val;
00121 };
00122
00123 #endif
00124
00126
00129 class PSQL_EXPORT SQLDouble: public SQLValue {
00130 public:
00132 SQLDouble();
00134 SQLDouble(const double& val);
00135 ~SQLDouble();
00136
00137 void setNull() throw();
00138
00139 const double& value() const throw();
00140 std::string str() const throw();
00141
00142 SQLDouble& operator=(const double& val);
00143
00144 private:
00145 double m_val;
00146 };
00147
00149
00152 class PSQL_EXPORT SQLDateTime: public SQLValue {
00153 public:
00155 SQLDateTime();
00157 SQLDateTime(const DateTime& dt);
00158 ~SQLDateTime();
00159
00160 void setNull() throw();
00161
00162 const DateTime& value() const throw();
00163 std::string str() const throw();
00164
00165 SQLDateTime& operator=(const DateTime& val);
00166
00167 private:
00168 DateTime m_val;
00169 };
00170
00171 }
00172
00173 #endif