MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / main

Function main

examples/print.cpp:16–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14const char* f2 = "test";
15
16int main(int argc, char** argv)
17{
18 std::cout << test::StructSimple() << std::endl << std::endl;
19 std::cout << test::StructOptional() << std::endl << std::endl;
20 std::cout << test::StructNested() << std::endl << std::endl;
21
22 // Print bytes struct
23 test::StructBytes struct_bytes;
24 struct_bytes.f1.assign((const uint8_t*)f1, (const uint8_t*)f1 + strlen(f1));
25 struct_bytes.f2.emplace();
26 struct_bytes.f2.value().assign((const uint8_t*)f2, (const uint8_t*)f2 + strlen(f2));
27 std::cout << struct_bytes << std::endl << std::endl;
28
29 // Print array struct
30 test::StructArray struct_array;
31 struct_array.f1[0] = (uint8_t)48;
32 struct_array.f1[1] = (uint8_t)65;
33 struct_array.f2[0] = (uint8_t)97;
34 struct_array.f2[1] = std::nullopt;
35 struct_array.f3[0] = std::vector<uint8_t>(3, 48);
36 struct_array.f3[1] = std::vector<uint8_t>(3, 65);
37 struct_array.f4[0] = std::vector<uint8_t>(3, 97);
38 struct_array.f4[1] = std::nullopt;
39 struct_array.f5[0] = test::EnumSimple::ENUM_VALUE_1;
40 struct_array.f5[1] = test::EnumSimple::ENUM_VALUE_2;
41 struct_array.f6[0] = test::EnumSimple::ENUM_VALUE_1;
42 struct_array.f6[1] = std::nullopt;
43 struct_array.f7[0] = test::FlagsSimple::FLAG_VALUE_1 | test::FlagsSimple::FLAG_VALUE_2;
44 struct_array.f7[1] = test::FlagsSimple::FLAG_VALUE_1 | test::FlagsSimple::FLAG_VALUE_2 | test::FlagsSimple::FLAG_VALUE_3;
45 struct_array.f8[0] = test::FlagsSimple::FLAG_VALUE_1 | test::FlagsSimple::FLAG_VALUE_2;
46 struct_array.f8[1] = std::nullopt;
47 struct_array.f9[0] = test::StructSimple();
48 struct_array.f9[1] = test::StructSimple();
49 struct_array.f10[0] = test::StructSimple();
50 struct_array.f10[1] = std::nullopt;
51 std::cout << struct_array << std::endl << std::endl;
52
53 // Print vector struct
54 test::StructVector struct_vector;
55 struct_vector.f1.emplace_back((uint8_t)48);
56 struct_vector.f1.emplace_back((uint8_t)65);
57 struct_vector.f2.emplace_back((uint8_t)97);
58 struct_vector.f2.emplace_back(std::nullopt);
59 struct_vector.f3.emplace_back(std::vector<uint8_t>(3, 48));
60 struct_vector.f3.emplace_back(std::vector<uint8_t>(3, 65));
61 struct_vector.f4.emplace_back(std::vector<uint8_t>(3, 97));
62 struct_vector.f4.emplace_back(std::nullopt);
63 struct_vector.f5.emplace_back(test::EnumSimple::ENUM_VALUE_1);
64 struct_vector.f5.emplace_back(test::EnumSimple::ENUM_VALUE_2);
65 struct_vector.f6.emplace_back(test::EnumSimple::ENUM_VALUE_1);
66 struct_vector.f6.emplace_back(std::nullopt);
67 struct_vector.f7.emplace_back(test::FlagsSimple::FLAG_VALUE_1 | test::FlagsSimple::FLAG_VALUE_2);
68 struct_vector.f7.emplace_back(test::FlagsSimple::FLAG_VALUE_1 | test::FlagsSimple::FLAG_VALUE_2 | test::FlagsSimple::FLAG_VALUE_3);
69 struct_vector.f8.emplace_back(test::FlagsSimple::FLAG_VALUE_1 | test::FlagsSimple::FLAG_VALUE_2);
70 struct_vector.f8.emplace_back(std::nullopt);
71 struct_vector.f9.emplace_back(test::StructSimple());
72 struct_vector.f9.emplace_back(test::StructSimple());
73 struct_vector.f10.emplace_back(test::StructSimple());

Callers

nothing calls this directly

Calls 7

assignMethod · 0.80
emplaceMethod · 0.80
emplace_backMethod · 0.80
StructSimpleClass · 0.50
StructOptionalClass · 0.50
StructNestedClass · 0.50
valueMethod · 0.45

Tested by

no test coverage detected