PB Kabel is an implementation of Googles Protocol Buffers wire format.
It is written in C-99 with no dependencies except small parts of the C standard library (integer types, bool and memcpy)
and PB Kabel does not allocate.
It simply works on unsigned char buffer.
It is completely up to you how these buffers are allocated.
PB Kabel provides a collection of functions to
- calculate necessary buffer sizes,
- encode different native C types to the pb wire format, and
- decode different native C types from the pb wire format.
All functions are side-effect free and thread-safe to call.
PB Kabel does not compile .proto files and does not generate code for you.
However, you can use PB Kabel to write your own implementation that satisfies a given .proto file.
If you want to use this library you simply need to copy the src folder into your project.
To compile you just need a C compiler capable of C-99.
The code does not need any specific flags.
If you are working under Linux a simple
cc -c src/pb_kabel.c
should suffice.
| folder | Use |
|---|---|
src |
Contains all the relevant source files. If you want to use this library yourself, you only need to copy this folder into your own code base. |
unit |
Contains the unit tests of this library. |
integration |
Contains the integration tests of this library. The official Python Protobuf implementation is used here to validate PB Kabel. |
examples |
Contains more complex examples than the integration tests. If you are starting out, you should probably start by looking at the integration tests instead. |
This library uses nob.h to build tests and examples.
For more information about nob.h see tsoding/nob.h.
You can build all the tests (both unit and integration) and the examples with a C compiler by running:
cc nob.c -o nob && ./nob