File tree 1 file changed +27
-1
lines changed
1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,33 @@ The serialization functionality in this repository is useful when explicit contr
21
21
This library uses ` std::format ` style formatting. For example:
22
22
23
23
```
24
- (insert example code)
24
+ struct Hike {
25
+ unsigned int distance;
26
+ int elevation;
27
+ std::optional<std::string>> name;
28
+ std::vector<int> waypoints;
29
+ };
30
+ // ...
31
+ chops::mutable_shared_buffer buf;
32
+
33
+ chops::binary_serialize(buf, "{32ui}{16i}{8ui}{16ui}{16ui}{64i}",
34
+ hike_obj.distance, hike_obj.elevation, hike_obj.name, hike_obj.waypoints);
35
+
36
+ // ...
37
+ net_obj.send(buf);
38
+
39
+ ```
40
+
41
+ The buffer will contain the following:
42
+
43
+ ```
44
+ 32 bit unsigned integer containing distance value
45
+ 16 bit signed integer containing elevation value
46
+ 8 bit unsigned integer corresponding to true or false for the optional
47
+ 16 bit unsigned integer for the size of the name string
48
+ 0 - N 8 bit characters for the name string
49
+ 16 bit unsigned integer for the size of the waypoints vector
50
+ 0 - N 64 bit signed integers for each waypoint value
25
51
```
26
52
27
53
The documentation overview provides a comparison with other serialization libraries as well as a rationale for the design decisions.
You can’t perform that action at this time.
0 commit comments