From 534c5958af6104aea60a9fcb0d823a5c3cfed1bc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Mar 2011 13:09:06 +0200 Subject: SQLite support --- mapping/traits.hxx | 81 ++++-------------------------------------------------- 1 file changed, 5 insertions(+), 76 deletions(-) (limited to 'mapping/traits.hxx') diff --git a/mapping/traits.hxx b/mapping/traits.hxx index 0533360..1009265 100644 --- a/mapping/traits.hxx +++ b/mapping/traits.hxx @@ -5,83 +5,12 @@ #ifndef TRAITS_HXX #define TRAITS_HXX -#include - -#include "person.hxx" // date - -// MySQL implementation. +// Include one of the database system-specific traits implementations. // #if defined(DATABASE_MYSQL) - -#include - -namespace odb -{ - namespace mysql - { - template <> - class value_traits - { - public: - typedef bool value_type; - typedef bool query_type; - typedef details::buffer image_type; - - static void - set_value (bool& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - v = (!is_null && n == 4 && std::strncmp ("true", b.data (), n) == 0); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - bool v) - { - is_null = false; - n = v ? 4 : 5; - - if (n > b.capacity ()) - b.capacity (n); - - std::memcpy (b.data (), (v ? "true" : "false"), n); - } - }; - - template <> - class value_traits - { - public: - typedef date value_type; - typedef date query_type; - typedef MYSQL_TIME image_type; - - static void - set_value (date& v, const MYSQL_TIME& i, bool is_null) - { - if (!is_null) - v = date (i.year, i.month, i.day); - else - v = date (0, 0, 0); - } - - static void - set_image (MYSQL_TIME& i, bool& is_null, const date& v) - { - is_null = false; - i.neg = false; - i.year = v.year (); - i.month = v.month (); - i.day = v.day (); - } - }; - } -} - -#endif // DATABASE_MYSQL +# include "traits-mysql.hxx" +#elif defined(DATABASE_SQLITE) +# include "traits-sqlite.hxx" +#endif #endif // TRAITS_HXX -- cgit v1.1