Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here

pbc

A protocol buffers library for C

Subscribe to updates I use pbc


Statistics on pbc

Number of watchers on Github 1047
Number of open issues 45
Average time to close an issue 13 days
Main language C
Average time to merge a PR about 7 hours
Open pull requests 6+
Closed pull requests 8+
Last commit over 3 years ago
Repo Created over 8 years ago
Repo Last Updated over 2 years ago
Size 302 KB
Organization / Authorcloudwu
Contributors10
Page Updated
Do you use pbc? Leave a review!
View open issues (45)
View pbc activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating pbc for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

PBC

travis-ci status

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;
}
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<phone_n;i++) {
    struct pbc_rmessage * p = pbc_rmessage_message(m , "phone", i);
    printf("\tnumber[%d] = %s\n",i,pbc_rmessage_string(p , "number", i ,NULL));
    printf("\ttype[%d] = %s\n",i,pbc_rmessage_string(p, "type", i, NULL));
}

pbc_rmessage_delete(m);

Message API

You can use wmessage for encoding , and rmessage for decoding.

See test/addressbook.c for details.

Pattern API

If you need better performance , you can use pbc_pattern_xxx api .

See test/pattern.c for details.

Pattern api is faster and less memory used because it can access data in native C struct.

Extension

PBC support extension in a very simple way . PBC add a specific prefix to every extension field name.

Service

Not supported

Enum

With message API , you can use both string and integer as enum type . They must be integer in Pattern API.

Lua bindings

cd bindings/lua && make

See https://github.com/cloudwu/pbc/tree/master/binding/lua/README.md

Question ?

  • Send me email : http://www.codingnow.com/2000/gmail.gif
  • My Blog : http://blog.codingnow.com
  • Design : http://blog.codingnow.com/2011/12/protocol_buffers_for_c.html (in Chinese)
  • Build for Visual Studio 2012 : https://github.com/miaodadao/pbc
pbc open issues Ask a question     (View All Issues)
  • almost 4 years pbc 在iOS编译报错
  • almost 4 years 关于解析repeated的message问题请教!
  • almost 4 years protobuf 模块设置为全局变量,不同模块需要register不同.pb
  • almost 4 years protobuf.decode 后有一个字段解析是nil,付给全局变量,该字段设置后, 下一次另一个消息decode 如果该字段应该也是nil的 但是里面发现有值,就是之前设置的。
  • almost 4 years 调用parser.register报错
  • about 4 years Lua5.1使用pbc解析int64返回是number type
  • over 4 years 关于PBC解析含有List数据格式
  • over 4 years pbc 解析 decode context error
  • over 4 years pbc指针模式decode时出现context error
  • over 4 years Is there a plan on supporting protobuf3.0
  • almost 5 years 热更新pb
  • almost 5 years 请问optional的message怎么判断是否是默认值呢?
  • about 5 years makefile has a little problem
  • about 5 years error building lua binding
  • over 5 years about 'optional' field .
  • over 5 years 有个optional int32 相关的 bug
  • over 5 years 使用pbc中的lua decode api,产生了unicode乱码问题
  • over 5 years Arm 平台WP8 编译pbc报错
  • about 6 years lua中怎么样取出enum的值
  • about 6 years double or float type problems
  • over 6 years pbc在arm平台上会不会有字节序的问题?编译器是arm-none-linux-gnueabi-gcc
  • over 6 years message嵌套
  • over 6 years repeate字段无数据,解包修改后,会影响后续所有此字段无数据的包。
  • over 6 years hi, 这个库大概需要占用多少内存呢?
pbc open pull requests (View All Pulls)
  • Add extern C and dllexport for luaopen().
  • Fix writing dirty data to default table
  • 1.fix build error on android ndk r10e
  • fixed from PVS-Studio
  • 增加gc的手动调用方法
  • Add support for cmake, add scripts to build pbc for iOS and Android
pbc questions on Stackoverflow (View All Questions)
  • PBC: get hash from an element
  • c++ call function in PBC Library in PNaCl
  • how do I implement identity-based signature scheme using PBC library
  • PBC element_to_bytes error "prints garbage" Unable to convert element to string
  • DllImport:RegisterCallback(pbc, url) and BindMonikerToStream(pmk, pbc)
  • android wifi direct. setting PBC message and peer list
  • Ported version of PBC BCE library for pnacl
  • Install 32 bit PBC library on 64 bit machine
  • Regarding how to install PBC
  • Illegal instruction (core dumped) with PBC library
  • the difference between element_to_bytes() and element_snprint() in pbc library
  • PBC on Windows - Unable to save element
  • PBC on Windows: CryptGenRandom()
  • Running PBC in Windows - Visual Studio
  • Pairing Based Cryptography (PBC) Signature library (pbc_sig-0.0.8) Making failed
  • Can't link/include GMP when installing Crypt::PBC on Cygwin
  • Pair Based Cryptography library (PBC) Heap corruption on call to element_to_mpz()
  • Element mul in PBC Library
  • java.lang.UnsatisfiedLinkError: Unable to load library 'jpbc-pbc': The specified module could not be found
  • How to calculate center of mass of a cluster broken by PBC?
pbc list of languages used
Other projects in C