mirror of
https://github.com/fumiama/simple-protobuf.git
synced 2026-06-05 00:10:24 +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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user