Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

psqlvalue.h

Go to the documentation of this file.
00001 /*
00002  *   P::Classes - Portable C++ Application Framework
00003  *   Copyright (C) 2000-2002  Christian Prochnow <cproch@seculogix.de>
00004  *
00005  *   This library is free software; you can redistribute it and/or
00006  *   modify it under the terms of the GNU Lesser General Public
00007  *   License as published by the Free Software Foundation; either
00008  *   version 2 of the License, or (at your option) any later version.
00009  *
00010  *   This library is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *   Lesser General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU Lesser General Public
00016  *   License along with this library; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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

Generated on Fri Mar 12 21:08:31 2004 for P::Classes by doxygen 1.3.3