Insert using stream operators (see print_next for example of extracting with stream ops.)
| 135 | |
| 136 | // Insert using stream operators (see print_next for example of extracting with stream ops.) |
| 137 | static void insert_stream_operators() { |
| 138 | std::cout << std::endl << "== Insert with stream operators." << std::endl; |
| 139 | proton::value v; |
| 140 | |
| 141 | // Create an array of INT with values [1, 2, 3] |
| 142 | proton::codec::encoder e(v); |
| 143 | e << proton::codec::start::array(proton::INT) |
| 144 | << int32_t(1) << int32_t(2) << int32_t(3) |
| 145 | << proton::codec::finish(); |
| 146 | print(v); |
| 147 | |
| 148 | // Create a mixed-type list of the values [42, 0, "x"]. |
| 149 | proton::codec::encoder e2(v); |
| 150 | e2 << proton::codec::start::list() |
| 151 | << int32_t(42) << false << proton::symbol("x") |
| 152 | << proton::codec::finish(); |
| 153 | print(v); |
| 154 | |
| 155 | // Create a map { "k1":42, "k2": false } |
| 156 | proton::codec::encoder e3(v); |
| 157 | e3 << proton::codec::start::map() |
| 158 | << "k1" << int32_t(42) |
| 159 | << proton::symbol("k2") << false |
| 160 | << proton::codec::finish(); |
| 161 | print(v); |
| 162 | } |
| 163 | |
| 164 | int main(int, char**) { |
| 165 | try { |