value.h
Go to the documentation of this file.00001
00002
00003 #ifndef _LIBGDAMM_VALUE_H
00004 #define _LIBGDAMM_VALUE_H
00005
00006 #include <glibmm.h>
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <glibmm/object.h>
00031 #include <libgda/gda-value.h>
00032
00033
00034 namespace Gnome
00035 {
00036
00037 namespace Gda
00038 {
00039
00045 enum ValueType
00046 {
00047 VALUE_TYPE_NULL,
00048 VALUE_TYPE_BIGINT,
00049 VALUE_TYPE_BIGUINT,
00050 VALUE_TYPE_BINARY,
00051 VALUE_TYPE_BLOB,
00052 VALUE_TYPE_BOOLEAN,
00053 VALUE_TYPE_DATE,
00054 VALUE_TYPE_DOUBLE,
00055 VALUE_TYPE_GEOMETRIC_POINT,
00056 VALUE_TYPE_GOBJECT,
00057 VALUE_TYPE_INTEGER,
00058 VALUE_TYPE_LIST,
00059 VALUE_TYPE_MONEY,
00060 VALUE_TYPE_NUMERIC,
00061 VALUE_TYPE_SINGLE,
00062 VALUE_TYPE_SMALLINT,
00063 VALUE_TYPE_SMALLUINT,
00064 VALUE_TYPE_STRING,
00065 VALUE_TYPE_TIME,
00066 VALUE_TYPE_TIMESTAMP,
00067 VALUE_TYPE_TINYINT,
00068 VALUE_TYPE_TINYUINT,
00069 VALUE_TYPE_TYPE,
00070 VALUE_TYPE_UINTEGER,
00071 VALUE_TYPE_UNKNOWN
00072 };
00073
00074 }
00075
00076 }
00077
00078
00079 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00080 namespace Glib
00081 {
00082
00083 template <>
00084 class Value<Gnome::Gda::ValueType> : public Glib::Value_Enum<Gnome::Gda::ValueType>
00085 {
00086 public:
00087 static GType value_type() G_GNUC_CONST;
00088 };
00089
00090 }
00091 #endif
00092
00093
00094 namespace Gnome
00095 {
00096
00097 namespace Gda
00098 {
00099
00100
00101 typedef GdaDate Date;
00102 typedef GdaGeometricPoint GeometricPoint;
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 typedef GdaTime Time;
00118 typedef GdaTimestamp Timestamp;
00119
00120 class Value
00121 {
00122 public:
00123 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00124 typedef Value CppObjectType;
00125 typedef GdaValue BaseObjectType;
00126 #endif
00127
00128 Value();
00129
00130
00131 explicit Value(GdaValue* castitem, bool make_a_copy = false);
00132
00133 Value(const Value& src);
00134 Value& operator=(const Value& src);
00135
00136 ~Value();
00137
00138 GdaValue* gobj() { return gobject_; }
00139 const GdaValue* gobj() const { return gobject_; }
00140
00142 GdaValue* gobj_copy() const;
00143
00144 protected:
00145 GdaValue* gobject_;
00146
00147 private:
00148
00149
00150 public:
00151
00152
00153
00154 static Value create_as_bigint(gint64 val);
00155
00156
00157
00158
00159
00160 static Value create_as_biguint(guint64 val);
00161
00162
00163 explicit Value(const void* val, long size);
00164
00165
00166
00167
00168
00169 explicit Value(bool val);
00170
00171 explicit Value(const Date& val);
00172
00173 explicit Value(double val);
00174
00175 explicit Value(const GeometricPoint& val);
00176
00177 explicit Value(const GObject *val);
00178
00179 explicit Value(int val);
00180
00181 explicit Value(const GdaValueList *val);
00182
00183 explicit Value(const GdaMoney *val);
00184
00185 explicit Value(const GdaNumeric *val);
00186
00187 explicit Value(float val);
00188
00189 explicit Value(gshort val);
00190
00191 explicit Value(gushort val);
00192
00193 explicit Value(const Glib::ustring& val);
00194
00195
00196
00197 explicit Value(const char* val);
00198
00199 explicit Value(const Time& val);
00200
00201 explicit Value(const Timestamp& val);
00202
00203
00204
00205
00206
00207 static Value create_as_time_t(time_t val);
00208 explicit Value(gchar val);
00209
00210 explicit Value(guchar val);
00211
00212 explicit Value(ValueType val);
00213
00214 explicit Value(guint val);
00215
00216 explicit Value(const Glib::ustring& as_string, ValueType type);
00217
00218
00219
00220
00221 bool operator==(const Value& src) const;
00222 bool operator!=(const Value& src) const;
00223
00224
00225 ValueType get_value_type() const;
00226
00227 bool is_null() const;
00228
00229 bool is_number() const;
00230
00231
00232 gint64 get_bigint() const;
00233
00234 void set(gint64 val);
00235
00236 guint64 get_biguint() const;
00237
00238 void set(guint64 val);
00239
00240
00241
00242 const gpointer get_binary(long& size) const;
00243
00244 void set(gconstpointer val, long size);
00245
00246
00247
00248 const GdaBlob* get_blob() const;
00249
00250 void set(const GdaBlob* val);
00251
00252 bool get_bool() const;
00253
00254 void set(bool val);
00255
00256 Date get_date() const;
00257
00258 void set(const Date& val);
00259
00260 double get_double() const;
00261
00262 void set(double val);
00263
00264 GeometricPoint get_geometric_point() const;
00265
00266 void set(const GeometricPoint& val);
00267
00268 Glib::RefPtr<const Glib::Object> get_gobject();
00269
00270 void set(const Glib::RefPtr<Glib::Object>& val);
00271
00272 int get_integer() const;
00273
00274 void set(int val);
00275
00276 const GdaValueList* get_list();
00277
00278 void set(const GdaValueList *val);
00279
00280 void set_null();
00281
00282 const GdaMoney* get_money() const;
00283
00284 void set(const GdaMoney *val);
00285
00286 const GdaNumeric* get_numeric() const;
00287
00288 void set(const GdaNumeric *val);
00289
00290 float get_single() const;
00291
00292 void set(float val);
00293
00294 gshort get_smallint() const;
00295
00296 void set(gshort val);
00297
00298 gushort get_smalluint() const;
00299
00300 void set(gushort val);
00301
00302 Glib::ustring get_string() const;
00303
00304 void set(const Glib::ustring& val);
00305
00306 Time get_time() const;
00307
00308 void set(const Time& val);
00309
00310 Timestamp get_timestamp() const;
00311
00312 void set(const Timestamp& val);
00313
00314 gchar get_tinyint() const;
00315
00316 void set(gchar val);
00317
00318 guchar get_tinyuint();
00319
00320 void set(guchar val);
00321
00322 guint get_uinteger() const;
00323
00324 void set(guint val);
00325
00326 ValueType get_vtype() const;
00327
00328 void set(GdaValueType type);
00329
00330 bool set_from_string(const Glib::ustring& as_string, ValueType type);
00331
00332
00333
00334
00335
00336
00337 Glib::ustring to_string() const;
00338
00339
00340
00341
00342 static Glib::ustring type_to_string(ValueType type);
00343
00344 static ValueType type_from_string(const Glib::ustring& type);
00345
00346
00347 };
00348
00349 }
00350 }
00351
00352
00353 namespace Glib
00354 {
00355
00361 Gnome::Gda::Value wrap(GdaValue* object, bool take_copy = false);
00362
00363 }
00364
00365 #endif
00366