From f4e192564a6e048eef14f21ab4d269874b6bfba3 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 23 May 2018 18:30:01 +0300 Subject: Adapt to inventing package_name type --- bdep/value-traits.hxx | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 bdep/value-traits.hxx (limited to 'bdep/value-traits.hxx') diff --git a/bdep/value-traits.hxx b/bdep/value-traits.hxx new file mode 100644 index 0000000..9984bae --- /dev/null +++ b/bdep/value-traits.hxx @@ -0,0 +1,54 @@ +// file : bdep/value-traits.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BDEP_VALUE_TRAITS_HXX +#define BDEP_VALUE_TRAITS_HXX + +#include +#include // size_t +#include // move() + +#include + +#include + +namespace odb +{ + namespace sqlite + { + template <> + class value_traits: + value_traits + { + public: + using value_type = bpkg::package_name; + using query_type = bpkg::package_name; + using image_type = details::buffer; + + using base_type = value_traits; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + std::string s; + base_type::set_value (s, b, n, is_null); + v = !s.empty () ? value_type (std::move (s)) : value_type (); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const value_type& v) + { + base_type::set_image (b, n, is_null, v.string ()); + } + }; + }; +} + +#endif // BDEP_WRAPPER_TRAITS_HXX -- cgit v1.1