https://github.com/cloudwu/pbc
A protocol buffers library for C
https://github.com/cloudwu/pbc
Last synced: 4 months ago
JSON representation
A protocol buffers library for C
- Host: GitHub
- URL: https://github.com/cloudwu/pbc
- Owner: cloudwu
- License: mit
- Archived: true
- Created: 2011-11-28T19:16:06.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2022-11-03T03:00:02.000Z (about 3 years ago)
- Last Synced: 2024-09-25T22:42:37.163Z (over 1 year ago)
- Language: C
- Homepage:
- Size: 305 KB
- Stars: 1,619
- Watchers: 163
- Forks: 568
- Open Issues: 74
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
- awesome-c - pbc - Protocol buffers library. [MIT](https://spdx.org/licenses/MIT.html) (Utilities / YAML)
- awesome-c-zh - pbc - 协议缓冲区库。[](https://spdx.org/licenses/MIT.html) (公用事业 / YAML)
- awesome-c - pbc - Protocol buffers library. [MIT](https://spdx.org/licenses/MIT.html) (Utilities / YAML)
README
## PBC
[](https://travis-ci.org/cloudwu/pbc)
PBC is a google protocol buffers library for C without code generation.
## Quick Example
package tutorial;
message Person {
required string name = 1;
required int32 id = 2; // Unique ID number for this person.
optional string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber {
required string number = 1;
optional PhoneType type = 2 [default = HOME];
}
repeated PhoneNumber phone = 4;
}
```C
struct pbc_rmessage * m = pbc_rmessage_new(env, "tutorial.Person", slice);
printf("name = %s\n", pbc_rmessage_string(m , "name" , 0 , NULL));
printf("id = %d\n", pbc_rmessage_integer(m , "id" , 0 , NULL));
printf("email = %s\n", pbc_rmessage_string(m , "email" , 0 , NULL));
int phone_n = pbc_rmessage_size(m, "phone");
int i;
for (i=0;i