diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-07-10 15:17:14 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-07-10 15:17:14 +0200 |
commit | 6d012073a48ca7044eea6835bed02220b28fc48c (patch) | |
tree | 5e3bb8338c8d3e70d3c2766b76be4df8b8d4be74 /odb/pgsql/details/conversion.hxx | |
parent | b59e98f95c37d8ec19884e346ae613793774158d (diff) |
Add support for custom database type mapping
New pragma qualifier, map, and specifiers: as, to, from. New tests:
<database>/custom.
Diffstat (limited to 'odb/pgsql/details/conversion.hxx')
-rw-r--r-- | odb/pgsql/details/conversion.hxx | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/odb/pgsql/details/conversion.hxx b/odb/pgsql/details/conversion.hxx new file mode 100644 index 0000000..230be2a --- /dev/null +++ b/odb/pgsql/details/conversion.hxx @@ -0,0 +1,59 @@ +// file : odb/pgsql/details/conversion.hxx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_PGSQL_DETAILS_CONVERSION_HXX +#define ODB_PGSQL_DETAILS_CONVERSION_HXX + +#include <odb/pgsql/traits.hxx> + +#include <odb/details/meta/answer.hxx> + +namespace odb +{ + // @@ Revise this. + // + namespace details {} + + namespace pgsql + { + namespace details + { + using namespace odb::details; + + // Detect whether conversion is specified in type_traits. + // + template <typename T> + meta::yes + conversion_p_test (typename type_traits<T>::conversion*); + + template <typename T> + meta::no + conversion_p_test (...); + + template <typename T> + struct conversion_p + { + static const bool value = + sizeof (conversion_p_test<T> (0)) == sizeof (meta::yes); + }; + + template <typename T, bool = conversion_p<T>::value> + struct conversion; + + template <typename T> + struct conversion<T, true> + { + static const char* to () {return type_traits<T>::conversion::to ();} + }; + + template <typename T> + struct conversion<T, false> + { + static const char* to () {return 0;} + }; + } + } +} + +#endif // ODB_PGSQL_DETAILS_CONVERSION_HXX |