8 #ifndef LIB_PG_ASYNC_INCLUDE_TIP_DB_PG_PROTOCOL_IO_TRAITS_INL_
9 #define LIB_PG_ASYNC_INCLUDE_TIP_DB_PG_PROTOCOL_IO_TRAITS_INL_
14 #include <tip/util/endian.hpp>
26 template <
typename InputIterator >
30 typedef std::iterator_traits< InputIterator > iter_traits;
31 typedef typename iter_traits::value_type iter_value_type;
32 static_assert(std::is_same< iter_value_type, byte >::type::value,
33 "Input iterator must be over a char container");
34 assert( (end - begin) >= size() &&
"Buffer size is insufficient" );
36 char* p =
reinterpret_cast<char*
>(&tmp);
38 while (p != e && begin != end) {
41 tmp = util::endian::big_to_native(tmp);
42 std::swap( base_type::value, tmp );
46 template <
typename T >
50 return (*
this)( std::back_inserter(buffer) );
53 template <
typename T >
54 template <
typename OutputIterator >
64 T tmp = util::endian::native_to_big(base_type::value);
65 char const* p =
reinterpret_cast<char const*
>(&tmp);
66 char const* e = p + size();
74 template <
typename T >
75 template <
typename InputIterator >
78 (InputIterator begin, InputIterator end)
80 typedef std::iterator_traits< InputIterator > iter_traits;
81 typedef typename iter_traits::value_type iter_value_type;
82 static_assert(std::is_same< iter_value_type, byte >::type::value,
83 "Input iterator must be over a char container");
86 is >> base_type::value;
91 template <
typename InputIterator >
94 (InputIterator begin, InputIterator end)
96 typedef InputIterator iterator_type;
97 typedef std::iterator_traits< iterator_type > iter_traits;
98 typedef typename iter_traits::value_type iter_value_type;
99 static_assert(std::is_same< iter_value_type, byte >::type::value,
100 "Input iterator must be over a char container");
106 for (; begin != end && *begin; ++begin) {
107 tmp.push_back(*begin);
111 base_type::value.swap(tmp);
115 template <
typename InputIterator >
118 (InputIterator begin, InputIterator end)
120 typedef InputIterator iterator_type;
121 typedef std::iterator_traits< iterator_type > iter_traits;
122 typedef typename iter_traits::value_type iter_value_type;
123 static_assert(std::is_same< iter_value_type, byte >::type::value,
124 "Input iterator must be over a char container");
127 iterator_type tmp = protocol_read< TEXT_DATA_FORMAT >(begin, end, literal);
128 if (use_literal(literal)) {
134 template <
typename InputIterator >
137 (InputIterator begin, InputIterator end)
139 typedef InputIterator iterator_type;
140 typedef std::iterator_traits< iterator_type > iter_traits;
141 typedef typename iter_traits::value_type iter_value_type;
142 static_assert(std::is_same< iter_value_type, byte >::type::value,
143 "Input iterator must be over a char container");
145 assert( (end - begin) >= size() &&
"Buffer size is insufficient" );
146 base_type::value = *begin++;
150 template <
typename InputIterator >
153 (InputIterator begin, InputIterator end)
155 typedef InputIterator iterator_type;
156 typedef std::iterator_traits< iterator_type > iter_traits;
157 typedef typename iter_traits::value_type iter_value_type;
158 static_assert(std::is_same< iter_value_type, byte >::type::value,
159 "Input iterator must be over a char container");
160 std::vector<byte> data;
164 base_type::value.data.swap(data);
165 return result.second;
170 template <
typename InputIterator >
173 (InputIterator begin, InputIterator end)
175 typedef InputIterator iterator_type;
176 typedef std::iterator_traits< iterator_type > iter_traits;
177 typedef typename iter_traits::value_type iter_value_type;
178 static_assert(std::is_same< iter_value_type, byte >::type::value,
179 "Input iterator must be over a char container");
182 std::swap(base_type::value.data, tmp);
std::vector< byte > container_type
std::decay< T >::type value_type
std::pair< boost::tribool, InputIterator > parse(InputIterator begin, InputIterator end, OutputIterator data)
boost::int_t< 32 >::exact integer
4-byte integer, to match PostgreSQL integer and serial types
Base structure for a binary data parser. Has no definition.