Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

gql++/object.h

Go to the documentation of this file.
00001 /* This is for emacs: -*-Mode: C++;-*- */ 00002 #if !defined(__INC_GQL_OBJECT_H) 00003 #define __INC_GQL_OBJECT_H 00004 00005 #include <string> 00006 00007 #include <sigc++/object.h> 00008 00009 #include <gql++/exception.h> 00010 00011 namespace GQL 00012 { 00013 00014 class SQLType 00015 { 00016 public: 00017 enum TypeCode 00018 { 00019 VOID, 00020 BOOLEAN, BOOL = BOOLEAN, 00021 DATE, 00022 DECIMAL, NUMERIC = DECIMAL, 00023 FLOAT, 00024 SMALLINT, 00025 INTEGER, INT = INTEGER, 00026 INTERVAL, 00027 TIME, 00028 TIME_WITH_TZ, 00029 TIMESTAMP_WITH_TZ, 00030 CHARACTER, CHAR = CHARACTER, 00031 CHARACTER_VARYING, VARCHAR = CHARACTER_VARYING, 00032 BLOB, 00033 00034 MAX_TYPE 00035 }; 00036 00037 SQLType(); 00038 SQLType(TypeCode type, ...); 00039 SQLType(const std::string& str); 00040 00041 std::string as_string() const; 00042 00043 TypeCode typecode() const { return(type_); } 00044 int length() const { return(length_); } 00045 int decimals() const { return(decimals_); } 00046 private: 00047 TypeCode type_; 00048 int length_; 00049 int decimals_; 00050 }; 00051 00052 class Blob : public SigC::Object 00053 { 00054 public: 00055 virtual ~Blob(); 00056 00057 enum openmode 00058 { 00059 in = 0x01, 00060 out = 0x02 00061 }; 00062 enum seek_dir { beg, cur, end }; 00063 00064 virtual void open(openmode om = in) = 0; 00065 virtual bool is_open() = 0; 00066 virtual void close() = 0; 00067 00068 virtual int write(const void *data, int len) = 0; 00069 virtual int read(void *data, int len) = 0; 00070 virtual int seek(int offset, seek_dir whence) = 0; 00071 virtual int tell() const = 0; 00072 protected: 00073 Blob() { } 00074 }; 00075 00076 class SQLObject : public SigC::Object 00077 { 00078 public: 00079 SQLObject() { 00080 is_null_ = true; 00081 } 00082 virtual ~SQLObject() { } 00083 00084 void set_null() { is_null_ = true; } 00085 bool is_null() const { return is_null_; } 00086 00087 virtual std::string output() const = 0; 00088 virtual bool input(const std::string& s) = 0; 00089 00090 virtual std::string to_string() const = 0; 00091 virtual long to_int() const = 0; 00092 virtual double to_real() const = 0; 00093 virtual bool to_boolean() const = 0; 00094 virtual Blob *to_blob() const = 0; 00095 virtual SQLType to_type() const = 0; 00096 00097 virtual void from_string(const std::string& s) = 0; 00098 virtual void from_int(long l) = 0; 00099 virtual void from_real(double d) = 0; 00100 virtual void from_boolean(bool b) = 0; 00101 virtual void from_type(const SQLType& type) = 0; 00103 virtual void from_blob(const Blob *blob) = 0; 00104 protected: 00105 void set_null(bool null) { is_null_ = null; } 00106 private: 00107 bool is_null_; 00108 }; 00109 00110 class BasicSQLObject : public SQLObject 00111 { 00112 public: 00113 BasicSQLObject(); 00114 virtual ~BasicSQLObject(); 00115 00116 virtual std::string output() const; 00117 virtual bool input(const std::string& s); 00118 00119 virtual std::string to_string() const; 00120 virtual long to_int() const; 00121 virtual double to_real() const; 00122 virtual bool to_boolean() const; 00123 virtual Blob *to_blob() const; 00124 virtual SQLType to_type() const; 00125 00126 virtual void from_string(const std::string& s); 00127 virtual void from_int(long l); 00128 virtual void from_real(double d); 00129 virtual void from_boolean(bool b); 00130 virtual void from_type(const SQLType& type); 00131 virtual void from_blob(const Blob *blob = 0); 00132 protected: 00133 enum Type { VOID, STRING, INT, FLOAT, TYPE }; 00134 00135 Type type() const { return type_; } 00136 private: 00137 Type type_; 00138 std::string value_; 00139 }; 00140 00141 } 00142 00143 00144 #endif

Generated on Wed Jul 28 18:38:00 2004 for gql by doxygen 1.3.7