protocol-buffers

protocol buffers - store an double array, 1D, 2D and 3D

核能气质少年 提交于 2019-12-02 20:32:11
How can be an array of double (1D) stored using protocol buffer? What about multi-dimensional (2D or 3D) dense arrays? An array of double would be best stored via repeated double foo = 5 [packed=true]; repeated makes it act as a list, allowing multiple items; packed avoids a header per item. There is no direct support for rectangular (or higher) arrays in protobuf. The closest is to store something like: repeated innerType foo = 5; // note, can't be "packed" message innerType { repeated double foo = 1 [packed=true]; } this is broadly akin to a jagged array, but with an element between each

How do I generate a .proto file from a C# class decorated with attributes?

泄露秘密 提交于 2019-12-02 20:24:19
Trying to get my mind around google protobuf. I found some implementation of protobuf in C# but they seems to lack one feature: the ability to generate .proto files automatically from an existing C# class decorated with attributes. The reason I want to do it this way instead of going from auto-generated C# classes from .proto file is because I already have the C# classes defined in my project and I don't want to duplicate them just to satisfy ProtoBuf. Does anyone have encountered such a scenario? Update Is this possible to just decorate a C# class and not use a .proto file to use protobuf?

simple protobuf compilation with gradle

左心房为你撑大大i 提交于 2019-12-02 20:21:41
If you're looking for sample gradle protobuf project look here . I'm having hard time with gradle and protobuf, i want to create a simple gradle project that will take any proto files from default src/main/proto , src/test/proto and compile them to src/main/java , src/test/java accordingly, then pack that into a jar and publish to local repo. Unfortunately i'm new to gradle and cant figure out how the original project is composed. Here is my unfinished build.gradle file apply plugin: 'java' apply plugin: "com.google.protobuf" buildscript { repositories { mavenCentral() } dependencies {

Google Protobuf ByteString vs. Byte[]

隐身守侯 提交于 2019-12-02 20:20:42
I am working with google protobuf in Java. I see that it is possible to serialize a protobuf message to String, byte[], ByteString, etc: (Source: https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/MessageLite ) I don't know what a ByteString is. I got the following definition from the the protobuf API documentation (source: https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/ByteString ): "Immutable sequence of bytes. Substring is supported by sharing the reference to the immutable underlying bytes, as with String." It is

How does protocol buffer handle versioning?

倾然丶 夕夏残阳落幕 提交于 2019-12-02 20:10:59
How does protocol buffers handle type versioning? For example, when I need to change a type definition over time? Like adding and removing fields. Google designed protobuf to be pretty forgiving with versioning: unexpected data is either stored as "extensions" (making it round-trip safe), or silently dropped, depending on the implementation new fields are generally added as "optional", meaning that old data can be loaded successfully however: do not renumber fields - that would break existing data you should not normally change the way any given field is stored (i.e. from a fixed-with 32-bit

Date and time type for use with Protobuf

ε祈祈猫儿з 提交于 2019-12-02 19:58:37
I'm considering to use Protocol Buffers for data exchange between a Linux and a Windows based system. Whats the recommended format for sending date/time (timestamp) values? The field should be small when serialized. Although you aren't saying which languages you are using or what kind of precision you need, I would suggest using Unix time encoded into a int64 . It is fairly easy to handle in most languages and platforms (see here for a Windows example), and Protobufs will use a varint-encoding keeping the size small without limiting the representable range too much. There is Timestamp message

How to convert from Json to Protobuf?

家住魔仙堡 提交于 2019-12-02 19:03:27
I'm new to using protobuf, and was wondering if there is a simple way to convert a json stream/string to a protobuf stream/string in Java? For example, protoString = convertToProto(jsonString) I have a json string that I want to parse into a protobuf message. So, I want to first convert the json string to protobuf, and then call Message.parseFrom() on it. Thanks in advance for the help! With proto3 you can do this using JsonFormat . It parses directly from the JSON representation, so there is no need for separately calling MyMessage.parseFrom(...) . Something like this should work: JsonFormat

Is there a definitive *nix command line tool for inspecting protocol buffers? [closed]

若如初见. 提交于 2019-12-02 19:02:15
I'm looking for a command-line utility that will, at a minimum, render binary protobuf data in human-readable form. Filtering and selection options (along the lines of cut for text) would be nice, but the primary object is to make the data visible for debugging purposes. If there is no definitive tool for the job, links to relevant packages are fine. The Protocol Compiler -- protoc -- has this functionality built-in via the --decode and --decode_raw flags. This is the same tool you use to generate code from a .proto file so is likely already installed. For example: protoc --decode_raw <

Available Game network protocol definition languages and code generation

丶灬走出姿态 提交于 2019-12-02 18:29:58
I've been looking for a good general purpose binary network protocol definition framework to provide a way to write real-time game servers and clients (think World Of Warcraft or Quake III) in multiple languages (e.g. Java backend server and iPhone front-end client written in Objective-C and Cocoa). I want to support Java Flash clients, iPhone clients and C# clients on windows (and XNA clients on XBOX). I'm looking for a way to efficiently send/receive messages over a TCP/IP or UDP socket stream connection. I'm not looking for something that can be sent over an HTTP Web Service, like JSON or

CMake with Google Protocol Buffers

倖福魔咒の 提交于 2019-12-02 18:18:53
I'm trying to use cmake to build my little project using protocol buffers. There's a root directory with a number of subdirectories with a number of libraries and executables. My first thought was to have my .proto-files in a subdirectory, but when I read this answer I made a library out of it instead. But when I try to include a messages header in my executable it can't find it. Error message: fatal error: msgs.pb.h: No such file or directory #include "msgs.pb.h" ^ compilation terminated. I'm running it by creating a dir "build" and then "cmake .. && make" from inside it. I've looked and it