1
0
mirror of https://github.com/fumiama/simple-protobuf.git synced 2026-06-05 00:10:24 +08:00
2023-07-08 19:54:56 +08:00
2021-05-19 12:44:16 +08:00
2021-06-08 20:01:05 +08:00
2021-06-11 15:13:59 +08:00
2023-07-08 19:54:56 +08:00
2021-05-18 09:27:38 +08:00
2021-05-18 09:27:38 +08:00
2023-07-08 19:54:56 +08:00
2023-07-08 19:54:56 +08:00

simple-protobuf

English | 简体中文

A simplified variant of Google's ProtoBuf.

format

A simple-protobuf file can be filled into a C struct directly, but no pointer is supported.

The sp file format is shown below.

[struct_len] + n*[[type][data_len][data]]
  1. type is a length-variable LE number(less than 2^57^) indicating the aligned type length of each struct item.
  2. *_len is a length-variable LE number(less than 2^57^) indicating the length of *.
  3. data contains data_len bytes of the data.

usage

You can read test.c to find out the detailed usage.

Save a struct

1. Create items type length info array

This array has type uint64_t, which indicates the aligned length of each struct item. You should call align_struct to get that array.

2. Call set_pb to save

Read into a struct

1. Open file

2. Call get_pb to read

Description
A simplified variant of Google's ProtoBuf.
Readme GPL-3.0 91 KiB
Languages
C 91.8%
CMake 8.2%