From 08de79b43a09b02a7b8feae2a9c12005d4bbb878 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 30 Jul 2010 13:23:50 +0200 Subject: Add value type traits --- odb/traits.hxx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'odb/traits.hxx') diff --git a/odb/traits.hxx b/odb/traits.hxx index 8aee00c..aa98ae1 100644 --- a/odb/traits.hxx +++ b/odb/traits.hxx @@ -7,6 +7,7 @@ #define ODB_TRAITS_HXX #include +#include #include #include @@ -88,6 +89,30 @@ namespace odb pointer_traits::pointer_type> pointer_ops; }; + + template + struct value_traits + { + typedef V value_type; + + template + static void + set_value (value_type& v, I i, bool is_null) + { + if (!is_null) + v = value_type (i); + else + v = value_type (); + } + + template + static void + set_image (I& i, bool& is_null, value_type v) + { + is_null = false; + i = I (v); + } + }; } #endif // ODB_TRAITS_HXX -- cgit v1.1