File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
Expand file tree Collapse file tree 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
2121This library uses ` std::format ` style formatting. For example:
2222
2323```
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
2551```
2652
2753The 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