Navigation Menu

Skip to content

steinwurf/chunkie

Repository files navigation

chunkie

Linux make-specs Windows make-specs MacOS make-specs Linux CMake Windows CMake MacOS CMake Raspberry Pi Valgrind No Assertions Clang Format Cppcheck

Chunkie provides functionality for serializing an object into a stream and deserializing a stream back into an object. This can be useful when sending big objects such as video frames or files over a network.

The deserializer can reconstruct the original object when all the buffers are inputted in order. If buffers are inputted out of order or some buffers are lost the object cannot be reconstructed.

Note that there is no explicit integrity check before an object is outputted. So if it is critical that erroneous objects are detected an integrity check should be made on outputted symbols. It is possible that an erroneous object can be outputted in circumstances where buffers are lost in a very particular way. Specifically if the tail buffer(s) of an object is lost and the head buffer(s) of the subsequent object is lost, and the remaining size of the subsequent object matches exactly the expected remaining bytes from the first object, an object will be outputted where the head is from the first object and the tail from the second object.

Below two examples of the output when serializing some objects to buffers using chunkie.

Example 1

An object of 20 bytes is serialized into 3 buffers.

Buffer 1

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1 si ze = 2 0
ob je ct 1 d at a
ob je ct 1 d at a

Buffer 2

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
0 si ze = 1 2
ob je ct 1 d at a
ob je ct 1 d at a

Buffer 3

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
0 si ze = 4
ob je ct 1 d at a
1 si ze = .
ob je ct 2 d at a

Example 2

Objects of 4 and 7 bytes respectively serialized into two buffers.

Buffer 1

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1 si ze = 4
ob je ct 3 d at a
1 si ze = 7
ob je ct 4 d at a

Buffer 2

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
0 si ze = 3
ob je ct 4 d at a 1
si ze = 6
ob je ct 5 d at a

Use as Dependency in CMake

To depend on this project when using the CMake build system, add the following in your CMake build script:

add_subdirectory("/path/to/chunkie" chunkie)
target_link_libraries(<my_target> steinwurf::chunkie)

Where <my_target> is replaced by your target.

About

Serializing and deserializing between object and stream

Resources

License

BSD-3-Clause, Unknown licenses found

Licenses found

BSD-3-Clause
LICENSE
Unknown
LICENSE.rst

Stars

Watchers

Forks

Packages

No packages published