| 50 | |
| 51 | template <typename Ch, typename Traits, typename Alloc, typename A, typename B> |
| 52 | struct pair_translator { |
| 53 | typedef std::basic_string<Ch, Traits, Alloc> internal_type; |
| 54 | typedef std::pair<A, B> external_type; |
| 55 | typedef boost::property_tree::customize_stream<Ch, Traits, A> customizeA; |
| 56 | typedef boost::property_tree::customize_stream<Ch, Traits, B> customizeB; |
| 57 | |
| 58 | inline boost::optional<external_type> get_value(const internal_type &v) const { |
| 59 | std::basic_istringstream<Ch, Traits, Alloc> stream(v); |
| 60 | external_type value; |
| 61 | customizeA::extract(stream, value.first); |
| 62 | customizeB::extract(stream, value.second); |
| 63 | if (stream.fail() || stream.bad() || stream.get() != Traits::eof()) return { }; |
| 64 | return value; |
| 65 | } |
| 66 | inline boost::optional<internal_type> put_value(const external_type &v) const { |
| 67 | std::basic_ostringstream<Ch, Traits, Alloc> stream; |
| 68 | customizeA::insert(stream, v.first); |
| 69 | stream << " "; |
| 70 | customizeB::insert(stream, v.second); |
| 71 | if (stream) return stream.str(); |
| 72 | else return { }; |
| 73 | } |
| 74 | }; |
| 75 | template <typename Source, typename A, typename B> |
| 76 | struct get_pair_translator { |
| 77 | typedef pair_translator<typename Source::value_type, |
nothing calls this directly
no outgoing calls
no test coverage detected