MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / regex_example

Function regex_example

examples/src/bson_examples.cpp:282–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282void 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
303void oid_example()
304{

Callers 1

mainFunction · 0.85

Calls 3

encode_bsonFunction · 0.85
atMethod · 0.80
tagMethod · 0.45

Tested by

no test coverage detected