3 ms·
Indeed. Here's how from the command line: protoc -o schema.pb schema.proto The meta-schema for compiled .proto files can be found here [1]. In fact, I kno
by sigil 15y ago
Indeed. Here's how from the command line:
protoc -o schema.pb schema.proto
The meta-schema for compiled .proto files can be found here [1]. In fact, I know of several protobuf implementations [2] [3] that avoid parsing .proto files by working with their compiled message form.
I use protobuf as a storage format for record streams. It's nice for binary data (documents, images, thumbnails, etc) where JSON string escaping would be wasteful. Each protobuf record in the file is preceded by a length and a magic number specifying record type, and the first record in the file embeds the compiled .proto schema.
This means it's possible to read and work with a record stream without specifying the schema separately, and without generating any code.
Disclaimer: I'm the author of the lwpb Python protobuf library.
[1] http://code.google.com/p/protobuf/source/browse/trunk/src/google/protobuf/descriptor.proto http://code.google.com/p/protobuf/source/browse/trunk/src/go...
[2] https://github.com/acg/lwpb https://github.com/acg/lwpb
[3] https://github.com/haberman/upb https://github.com/haberman/upb