diff options
author | Constantin Michael <constantin@codesynthesis.com> | 2011-11-07 15:02:14 +0200 |
---|---|---|
committer | Constantin Michael <constantin@codesynthesis.com> | 2011-11-08 14:46:33 +0200 |
commit | 655fc5c0827d56b6eaa86f80c904d9a607530fcb (patch) | |
tree | cf4679282bb15dd15c73ff429e0b20428eb58650 /odb/oracle/auto-descriptor.hxx | |
parent | 60d4d13a85130ccdc3b232e420bc3c18683846b9 (diff) |
Implement support for Oracle temporal types
Diffstat (limited to 'odb/oracle/auto-descriptor.hxx')
-rw-r--r-- | odb/oracle/auto-descriptor.hxx | 63 |
1 files changed, 46 insertions, 17 deletions
diff --git a/odb/oracle/auto-descriptor.hxx b/odb/oracle/auto-descriptor.hxx index f55925d..6bc97d6 100644 --- a/odb/oracle/auto-descriptor.hxx +++ b/odb/oracle/auto-descriptor.hxx @@ -17,41 +17,64 @@ namespace odb { namespace oracle { + enum descriptor_type + { + dt_default = 0, + dt_param, + dt_lob, + dt_timestamp, + dt_interval_ym, + dt_interval_ds + }; + + LIBODB_ORACLE_EXPORT void + oci_descriptor_free (void* descriptor, descriptor_type type); + // // descriptor_type_traits // template <typename D> - struct descriptor_type_traits; + struct default_descriptor_type_traits; template <> - struct descriptor_type_traits<OCIParam> - { static const ub4 dtype; }; + struct default_descriptor_type_traits<OCIParam> + { static const descriptor_type dtype = dt_param; }; template <> - struct descriptor_type_traits<OCILobLocator> - { static const ub4 dtype; }; - + struct default_descriptor_type_traits<OCILobLocator> + { static const descriptor_type dtype = dt_lob; }; // - // descriptor_traits + // auto_descriptor_base // - LIBODB_ORACLE_EXPORT void - oci_descriptor_free (void* descriptor, ub4 type); + template <typename D, descriptor_type Type> + struct auto_descriptor_base + { + static void + release (D* d) + { + oci_descriptor_free (d, Type); + } + }; template <typename D> - struct descriptor_traits + struct auto_descriptor_base<D, dt_default> { static void release (D* d) { - oci_descriptor_free (d, descriptor_type_traits<D>::dtype); + oci_descriptor_free (d, default_descriptor_type_traits<D>::dtype); } }; - template <typename D> - class auto_descriptor + // + // auto_descriptor + // + + template <typename D, descriptor_type T = dt_default> + class auto_descriptor: auto_descriptor_base<D, T> { public: auto_descriptor (D* d = 0) @@ -62,25 +85,31 @@ namespace odb ~auto_descriptor () { if (d_ != 0) - descriptor_traits<D>::release (d_); + release (d_); } - operator D* () + operator D* () const { return d_; } - D* + D*& get () { return d_; } + D* + get () const + { + return d_; + } + void reset (D* d = 0) { if (d_ != 0) - descriptor_traits<D>::release (d_); + release (d_); d_ = d; } |