8 #ifndef LIB_PG_ASYNC_SRC_TIP_DB_PG_DETAIL_PROTOCOL_PARSERS_HPP_
9 #define LIB_PG_ASYNC_SRC_TIP_DB_PG_DETAIL_PROTOCOL_PARSERS_HPP_
11 #include <boost/logic/tribool.hpp>
29 char most_sighificant_nibble_;
31 bytea_parser() : state_(expecting_backslash), most_sighificant_nibble_(0) {}
33 template <
typename InputIterator,
typename OutputIterator >
34 std::pair< boost::tribool, InputIterator >
35 parse(InputIterator begin, InputIterator end, OutputIterator data)
37 boost::tribool result = boost::indeterminate;
38 while (begin != end) {
39 result = consume(data, *begin++);
41 return std::make_pair(result, begin);
47 state_ = expecting_backslash;
48 most_sighificant_nibble_ = 0;
51 template <
typename OutputIterator >
53 consume( OutputIterator data,
char input )
56 case expecting_backslash:
59 return boost::indeterminate;
71 if (std::isxdigit(input)) {
72 most_sighificant_nibble_ = hex_to_byte(input);
74 return boost::indeterminate;
79 if (std::isxdigit(input)) {
80 *data++ = (hex_to_byte(input) << 4) | most_sighificant_nibble_;
std::pair< boost::tribool, InputIterator > parse(InputIterator begin, InputIterator end, OutputIterator data)