attached is a port of google protobuf

Information for inst:protobuf-2.2.0

Comment:
c++ protocol buffers

Description:
Protocol buffers are a flexible, efficient, automated mechanism for serializing
structured data - think XML, but smaller, faster, and simpler. You define how
you want your data to be structured once, then you can use special generated
source code to easily write and read your structured data to and from a variety
of data streams and using a variety of languages. You can even update your data
structure without breaking deployed programs that are compiled against the "old"
format.

Maintainer: Vincent Auclair <[email protected]>

WWW: http://code.google.com/p/protobuf/

It uses the installed gtest instead of the shipped one for regressions tests.
This is only the c++ part. There are also a java and python part in it.
Which I am not currently planning to port.

Comments ?
This was also ported for the ACSEL. (same as gtest, glog) So it would be nice if
it could be mentioned in the commit message. :)
This is the 2.2.0 version as the 2.2.0a is only a debian fix.
The 2.3.0 is in release candidate.

I am copying the website example here :

You write a .proto file like this:

message Person {
  required int32 id = 1;
  required string name = 2;
  optional string email = 3;
}

Then you compile it with protoc, the protocol buffer compiler,
to produce code in C++, Java, or Python.

Then, if you are using C++, you use that code like this:

Person person;
person.set_id(123);
person.set_name("Bob");
person.set_email("[email protected]");

fstream out("person.pb", ios::out | ios::binary | ios::trunc);
person.SerializeToOstream(&out);
out.close();

Or like this:

Person person;
fstream in("person.pb", ios::in | ios::binary);
if (!person.ParseFromIstream(&in)) {
  cerr << "Failed to parse person.pb." << endl;
  exit(1);
}

cout << "ID: " << person.id() << endl;
cout << "name: " << person.name() << endl;
if (person.has_email()) {
  cout << "e-mail: " << person.email() << endl;
}

-- 
Vincent Auclair        -      auclair.vincent[ at ]gmail.com
(+33) 6 80 77 59 67

Attachment: protobuf.tar.gz
Description: GNU Zip compressed data

Reply via email to