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

value.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 // Generated by gtkmmproc -- DO NOT MODIFY!
00003 #ifndef _LIBGDAMM_VALUE_H
00004 #define _LIBGDAMM_VALUE_H
00005 
00006 #include <glibmm.h>
00007 
00008 /* $Id: value.hg,v 1.8.2.4 2005/07/13 14:41:13 murrayc Exp $ */
00009 // -*- C++ -*- //
00010 
00011 /* value.h
00012  *
00013  * Copyright 2003 libgdamm Development Team
00014  *
00015  * This library is free software; you can redistribute it and/or
00016  * modify it under the terms of the GNU Library General Public
00017  * License as published by the Free Software Foundation; either
00018  * version 2 of the License, or (at your option) any later version.
00019  *
00020  * This library is distributed in the hope that it will be useful,
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023  * Library General Public License for more details.
00024  *
00025  * You should have received a copy of the GNU Library General Public
00026  * License along with this library; if not, write to the Free
00027  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00028  */
00029 
00030 #include <glibmm/object.h>
00031 #include <libgda/gda-value.h> //TODO: Patch libgda to use the struct _ technique.
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 } // namespace Gda
00075 
00076 } // namespace Gnome
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 } // namespace Glib
00091 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00092 
00093 
00094 namespace Gnome
00095 {
00096 
00097 namespace Gda
00098 {
00099 
00100 
00101 typedef GdaDate Date;
00102 typedef GdaGeometricPoint GeometricPoint;
00103 
00104 /*  TODO:
00105 typedef struct {
00106         gchar *currency;
00107         gdouble amount;
00108 } GdaMoney;
00109 
00110 typedef struct {
00111         gchar *number;
00112         long precision;
00113         long width;
00114 } GdaNumeric;
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 /* DOXYGEN_SHOULD_SKIP_THIS */
00127 
00128   Value();
00129 
00130   // Use make_a_copy=true when getting it directly from a struct.
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 //We can't have this constructor because gint64 and int are the same on 64-bit systems:
00153 //explicit Value(gint64 val);
00154   static Value create_as_bigint(gint64 val);
00155   
00156 
00157 //We can't have this constructor because guint64 and unsigned int are the same on 64-bit systems:
00158 //explicit Value(gint64 val);
00159 // explicit Value(guint64 val);
00160    static Value create_as_biguint(guint64 val);
00161   
00162 
00163   explicit Value(const void* val, long size); 
00164   
00165 
00166   //gda_value_new_blob() is not implemented. explicit Value(const GdaBlob *val);
00167   //__IGNORE(gda_value_new_blob)
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   //If this constructor does not exists, then Value("something") uses Value(bool) instead of Value(ustring).
00197   explicit Value(const char* val);
00198 
00199   explicit Value(const Time& val);
00200   
00201   explicit Value(const Timestamp& val);
00202   
00203   
00204   //This causes ambiguity with another constructor on 64-bit systems:
00205   //explicit Value(time_t val);
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   //TODO: explicit Value(const xmlNodePtr node);
00219   //__IGNORE(gda_value_new_from_xml)
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   //TODO: The const here is quite meaningless:
00241   
00242   const gpointer get_binary(long& size) const;
00243   
00244   void set(gconstpointer val, long size);
00245 
00246   //TODO: The const here is quite meaningless:
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   //Use the copy constructor instead: _WRAP_METHOD(bool set_from_value(const Value& from), gda_value_set_from_value)
00333   
00334 
00335   //TODO: Wrap this as some stream operator thing?
00336   
00337   Glib::ustring to_string() const;
00338 
00339   //TODO: _WRAP_METHOD(xmlNodePtr gda_value_to_xml(), gda_value_to_xml)
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 } // namespace Gda
00350 } // namespace Gnome
00351 
00352 
00353 namespace Glib
00354 {
00355 
00361 Gnome::Gda::Value wrap(GdaValue* object, bool take_copy = false);
00362 
00363 } // namespace Glib
00364 
00365 #endif /* _LIBGDAMM_VALUE_H */
00366 

Generated on Fri Jul 29 23:19:39 2005 for libgdamm by  doxygen 1.4.4