mirror of
https://github.com/fumiama/simple-protobuf.git
synced 2026-06-09 10:30:27 +08:00
更改README
This commit is contained in:
15
README.md
15
README.md
@@ -13,7 +13,7 @@ The sp file format is shown below.
|
||||
[struct_len] + n*[[type][data_len][data]]
|
||||
```
|
||||
|
||||
1. `type` is an one-byte number indicating the type length(2^type^bytes) of this struct item.
|
||||
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.
|
||||
|
||||
@@ -21,18 +21,11 @@ The sp file format is shown below.
|
||||
You can read `test.c` to find out the detailed usage.
|
||||
|
||||
## Save a struct
|
||||
### 1. Create items type info array
|
||||
### 1. Create items type length info array
|
||||
|
||||
This array has type `uint8_t`, which indicates the length of each struct item. Note that the length of each item must be 2^n^.
|
||||
|
||||
### 2. Align items type info array
|
||||
|
||||
You can use function `align_struct` to align each item to the proper size.
|
||||
|
||||
If you are sure that your struct has been aligned, you won't need to run `align_struct`.
|
||||
|
||||
### 3. Call set_pb to save
|
||||
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
|
||||
|
||||
|
||||
12
README_ZH.md
12
README_ZH.md
@@ -11,7 +11,7 @@ Google ProtoBuf的简化变体。
|
||||
[struct_len] + n*[[type][data_len][data]]
|
||||
```
|
||||
|
||||
1. `type` 指明该项的类型,亦即其在结构体中实际占用的空间的对数。
|
||||
1. `type` 是一个小于 2^57^ 的变长数字,指明该项的类型,亦即其在结构体中对齐后实际占用的空间。
|
||||
2. `*_len` 是一个小于 2^57^ 的变长数字。
|
||||
3. `data` 是 `data_len` 长度的数据。
|
||||
|
||||
@@ -19,15 +19,11 @@ Google ProtoBuf的简化变体。
|
||||
比较简单,详见`test.c`。
|
||||
|
||||
## 保存结构体
|
||||
### 1. 创建 items_type 数组
|
||||
### 1. 调用 align_struct 创建 items_len 数组
|
||||
|
||||
是结构体所有项的`type`组成的数组。
|
||||
该数组由结构体所有项的`type`组成。
|
||||
|
||||
### 2. 类型对齐
|
||||
|
||||
接下来需要用`align_struct`进行对齐。如果您已经将数组对齐或结构体本身是对齐的,则无需此步骤。
|
||||
|
||||
### 3. 调用 set_pb 保存
|
||||
### 2. 调用 set_pb 保存
|
||||
|
||||
|
||||
## 读入结构体
|
||||
|
||||
Reference in New Issue
Block a user