| 280 | } |
| 281 | |
| 282 | void regex_example() |
| 283 | { |
| 284 | std::vector<uint8_t> input = { |
| 285 | 0x16,0x00,0x00,0x00, // Document has 22 bytes |
| 286 | 0x0B, // Regular expression |
| 287 | 0x72,0x65,0x67,0x65,0x78,0x00, // "regex" |
| 288 | 0x5E,0x61,0x62,0x63,0x64,0x00, // "^abcd" |
| 289 | 0x69,0x6C,0x78,0x00, // "ilx" |
| 290 | 0x00 // terminating null |
| 291 | }; |
| 292 | |
| 293 | json j = bson::decode_bson<json>(input); |
| 294 | |
| 295 | std::cout << "(1) " << j << "\n\n"; |
| 296 | std::cout << "(2) " << j.at("regex").tag() << "\n\n"; |
| 297 | |
| 298 | std::vector<uint8_t> output; |
| 299 | bson::encode_bson(j, output); |
| 300 | assert(output == input); |
| 301 | } |
| 302 | |
| 303 | void oid_example() |
| 304 | { |
no test coverage detected