aboutsummaryrefslogtreecommitdiff
path: root/libbrep/common-traits.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbrep/common-traits.hxx')
-rw-r--r--libbrep/common-traits.hxx39
1 files changed, 38 insertions, 1 deletions
diff --git a/libbrep/common-traits.hxx b/libbrep/common-traits.hxx
index 99002a2..141a738 100644
--- a/libbrep/common-traits.hxx
+++ b/libbrep/common-traits.hxx
@@ -1,5 +1,4 @@
// file : libbrep/common-traits.hxx -*- C++ -*-
-// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
#ifndef LIBBREP_COMMON_TRAITS_HXX
@@ -11,12 +10,50 @@
#include <odb/pgsql/traits.hxx>
+#include <libbutl/target-triplet.hxx>
+
#include <libbpkg/package-name.hxx>
namespace odb
{
namespace pgsql
{
+ // target_triplet
+ //
+ template <>
+ class value_traits<butl::target_triplet, id_string>:
+ value_traits<std::string, id_string>
+ {
+ public:
+ using value_type = butl::target_triplet;
+ using query_type = butl::target_triplet;
+ using image_type = details::buffer;
+
+ using base_type = value_traits<std::string, id_string>;
+
+ 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 (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 ());
+ }
+ };
+
+ // package_name
+ //
template <>
class value_traits<bpkg::package_name, id_string>:
value_traits<std::string, id_string>