7#include <userver/storages/postgres/io/buffer_io.hpp>
8#include <userver/storages/postgres/io/buffer_io_base.hpp>
9#include <userver/utils/macaddr.hpp>
11USERVER_NAMESPACE_BEGIN
15using Macaddr = USERVER_NAMESPACE::
utils::Macaddr;
16using Macaddr8 = USERVER_NAMESPACE::
utils::Macaddr8;
22struct MacaddrFormatterBase : BufferFormatterBase<T> {
23 using BaseType = BufferFormatterBase<T>;
25 using BaseType::BaseType;
27 template <
typename Buffer>
28 void operator()(
const UserTypes& types, Buffer& buffer) {
29 for (
const auto val :
this->value.GetOctets()) {
30 io::WriteBuffer(types, buffer,
static_cast<
char>(val));
36struct MacaddrBufferParser : BufferParserBase<T> {
37 using BaseType = BufferParserBase<T>;
38 using BaseType::BaseType;
40 typename T::OctetsType octets;
41 const uint8_t* byte_cptr = buffer.buffer;
42 for (
auto& val : octets) {
46 this->value = T(octets);
54struct BufferFormatter<Macaddr> : detail::MacaddrFormatterBase<Macaddr> {
55 using BaseType = detail::MacaddrFormatterBase<Macaddr>;
57 using BaseType::BaseType;
62struct BufferFormatter<Macaddr8> : detail::MacaddrFormatterBase<Macaddr8> {
63 using BaseType = detail::MacaddrFormatterBase<Macaddr8>;
65 using BaseType::BaseType;
70struct BufferParser<Macaddr> : detail::MacaddrBufferParser<Macaddr> {
71 using BaseType = detail::MacaddrBufferParser<Macaddr>;
73 using BaseType::BaseType;
78struct BufferParser<Macaddr8> : detail::MacaddrBufferParser<Macaddr8> {
79 using BaseType = detail::MacaddrBufferParser<Macaddr8>;
81 using BaseType::BaseType;
85struct CppToSystemPg<Macaddr> : PredefinedOid<PredefinedOids::kMacaddr> {};
88struct CppToSystemPg<Macaddr8> : PredefinedOid<PredefinedOids::kMacaddr8> {};