kea-custom-hooks
FeM custom hooks libraries for Kea DHCP
pqxx_compat.cpp
Go to the documentation of this file.
1#include "kch_config.h"
2
3#if KCH_PQXX_MAJOR_VERSION < 7
4#include <pqxx/binarystring>
5
6namespace util
7{
8pqxx::binarystring to_binstr(const std::vector<std::uint8_t>& bytea)
9{
10 return pqxx::binarystring{bytea.data(), bytea.size()};
11}
12
13std::vector<std::uint8_t> to_bytea(const pqxx::binarystring& bstr)
14{
15 std::vector<std::uint8_t> bytea;
16 bytea.reserve(bstr.size());
17
18 for (const auto& ch : bstr)
19 bytea.push_back(static_cast<std::uint8_t>(ch));
20
21 return bytea;
22}
23} // namespace util
24#endif
std::vector< uint8_t > to_bytea(byte_string_view str)
Convert a byte string to a byte array.
Definition: bytea_utils.cpp:18
pqxx::binarystring to_binstr(const std::vector< std::uint8_t > &bytea)
Convert a byte array to a binary string.
Definition: pqxx_compat.cpp:8