GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Crinson/pbc: A protocol buffers library for C

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

152 Commits
152 Commits

Folders and files

NameName
Last commit message
Last commit date
binding/lua
binding/lua
 
 
pbc.xcodeproj
pbc.xcodeproj
 
 
pbc
pbc
 
 
src
src
 
 
test
test
 
 
tool
tool
 
 
.gitignore
.gitignore
 
 
Android.mk
Android.mk
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
license.txt
license.txt
 
 
pbc.h
pbc.h
 
 
pbc.sln
pbc.sln
 
 
pbc.vcxproj
pbc.vcxproj
 
 
pbc.vcxproj.filters
pbc.vcxproj.filters
 
 

Repository files navigation

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;
}
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 detail.

Pattern API

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

See test/pattern.c for detail.

pattern api is faster, and less memory used, and you can access data from native C struct .

Extension

PBC support extension with a simple way . PBC will add a prefix to every extension field name.

Service

Not supported

Enum

With message API , you can use both string and integer as the enum type , and with pattern api it must be integer.

Lua bindings

cd bindings/lua && make

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

Question ?

  • Send me an 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

About

A protocol buffers library for C

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.