diff options
| author | Xavi Del Campo <xavi.dcr@tutanota.com> | 2020-04-29 18:57:25 +0200 |
|---|---|---|
| committer | Xavi Del Campo <xavi.dcr@tutanota.com> | 2020-04-29 19:41:52 +0200 |
| commit | c3f0add4d3e2b16fa02284bf2d014c8ed93d4700 (patch) | |
| tree | 2d19d5fbf6ef5f236700e2db2b9942ce0fa0d2ab /README.md | |
| download | serializer-c3f0add4d3e2b16fa02284bf2d014c8ed93d4700.tar.gz | |
First commit
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..f3b35ed --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +Serializer/deserializer library for C99 +======================================= + +This library hopes to be useful under certain circumstances where a portable +implementation is desired to read/write data streams yet endianness and +alignment requirements need to be taken into account e.g.: network protocols, +file formats, etc. As the title specifies, only a C99-compliant compiler is +required. + +Only 8-bit and 16/32-bit little-endian and big-endian values are supported. +This means no support for bit fields, as some aspects of bit fields are +implementation-defined. + +Usage +------ + +```{c} +#include "serializer.h" +#include <stdint.h> +#include <stdio.h> + +int main() +{ + struct + { + uint8_t a; + uint16_t b; + uint32_t c; + uint16_t d; + } ex; + + static const uint8_t data[] = + { + 0x01, 0x33, 0xFF, 0xAC, 0xBB, 0xFA, 0xFA, 0xDE, 0xDE + }; + + deserialize("1/le2/be4/be2", &ex, sizeof ex, data, sizeof data); + printf("a=%X, b=%X, c=%X, d=%X\n", + ex.a, ex.b, ex.c, ex.d); + return 0; +} +``` +Output +------ +`a=1, b=FF33, c=ACBBFAFA, d=DEDE` + +TODO +---- +Only deserialization is implemented. Serialization will be implemented in the future. + +64-bit support. |
