protocol-buffers

How can I send multiple types of objects across Protobuf?

笑着哭i 提交于 2019-11-30 07:23:39
I'm implementing a client-server application, and am looking into various ways to serialize and transmit data. I began working with Xml Serializers, which worked rather well, but generate data slowly, and make large objects, especially when they need to be sent over the net. So I started looking into Protobuf, and protobuf-net. My problem lies in the fact that protobuf doesn't sent type information with it. With Xml Serializers, I was able to build a wrapper which would send and receive any various (serializable) object over the same stream, since object serialized into Xml contain the type

How can I use protocol buffers for Python on windows?

时间秒杀一切 提交于 2019-11-30 07:10:47
I have been trying to use protocol buffers in my Python program, but cannot get it to work. I'm running a Windows 8 machine and have tried Python 2.7.6 and Python 3.3. I downloaded the binary protocol buffer compiler for Python and used it to generate myProto_pb2.py from my myProto.proto file, but when I get the following error when I run my Python program: from the "import myProto_pb2" line, I get the following error when using Python 2.7.6 from protocol buffers version 2.5: from google.protobuf import descriptor as _descriptor ImportError: No module named google.protobuf How can I correctly

Protobuf3: How to describe map of repeated string?

家住魔仙堡 提交于 2019-11-30 07:08:53
The Official documentation about map type says: map<key_type, value_type> map_field = N; ...where the key_type can be any integral or string type (so, any scalar type except for floating point types and bytes). The value_type can be any type . I want to define a map<string, repeated string> field, but it seems illegal on my libprotoc 3.0.0 , which complains Expected ">" . So I wonder if there is any way to put repeated string into map. A Possible workaround could be: message ListOfString { repeated string value = 1; } // Then define: map<string, ListOfString> mapToRepeatedString = 1; But

Compile protobuf with xCode 5

时间秒杀一切 提交于 2019-11-30 06:53:06
问题 I want to use protobuf(https://code.google.com/p/protobuf/) in my project Did you successfully compile protobuf with xCode 5, Please help to share your experience? Thanks. 回答1: If you don't mind building Google Protobuf yourself then a good alternative to using Cocoapods is to run the bash script here. https://gist.github.com/BennettSmith/7150245 This script will produce a proper build of Google Protobuf that supports the i386, armv7, armv7s, arm64 and x86_64 architectures. It will produce a

ImportError: No module named google.protobuf

佐手、 提交于 2019-11-30 06:41:51
问题 I am following this guide (https://developers.google.com/protocol-buffers/docs/pythontutorial) and using the exact sample of addressbook.proto. Post the content of compiler generated addressbook_pb2.py file as well. When I run the following simple program, there is error saying, cannot find google.protobuf, any ideas how to resolve this issue? Thanks. BTW, using Python 2.7 on Mac OSX. from addressbook_pb2 import Person p = Person() p.email = "abc" print p.email Here is the automated generated

Parse Google Protocol Buffers datagram without .proto file?

早过忘川 提交于 2019-11-30 05:31:16
问题 is it possible to parse an incoming google protocol buffers datagram without any .proto file? I merely now its been serialized using protocol buffers but have no idea about the IDL file. I'm looking for a way to just iterate through any value by some sort of reflection? Is this possible? Thank you! 回答1: protoc --decode_raw < my_file You need to take the following things into account when inspecting the output: None of the field names are visible, just the tag numbers. All varint-fields are

How cross-platform is Google's Protocol Buffer's handling of floating-point types in practice?

情到浓时终转凉″ 提交于 2019-11-30 04:42:25
Google's Protocol Buffers allows you to store floats and doubles in messages. I looked through the implementation source code wondering how they managed to do this in a cross-platform manner, and what I stumbled upon was: inline uint32 WireFormatLite::EncodeFloat(float value) { union {float f; uint32 i;}; f = value; return i; } inline float WireFormatLite::DecodeFloat(uint32 value) { union {float f; uint32 i;}; i = value; return f; } inline uint64 WireFormatLite::EncodeDouble(double value) { union {double f; uint64 i;}; f = value; return i; } inline double WireFormatLite::DecodeDouble(uint64

Wheel files : What is the meaning of “none-any” in protobuf-3.4.0-py2.py3-none-any.whl

☆樱花仙子☆ 提交于 2019-11-30 03:13:32
问题 I used pip to get .whl file for numpy pip wheel --wheel-dir=./ numpy and I have got numpy-1.13.3-cp27-cp27mu-linux_armv7l.whl because I am using ARM platform, but when run pip for protobuf pip wheel --wheel-dir=./ protobuf I got protobuf-3.4.0-py2.py3-none-any.whl So, why isn't linux_armv7l like the case of numpy, I didn't alter the machine and searched for that difference but no information. thanks for advice . 回答1: Let's split package names by components: numpy — package name 1.13.3 —

Protobuf to json in python

夙愿已清 提交于 2019-11-30 03:11:06
I have an object that I de-serialize using protobuf in Python. When I print the object it looks like a python object, however when I try to convert it to json I have all sorts of problems. For example, if I use json.dumps() I get that the object (the generated code from protoc) does not contain a _ dict _ error. If I use jsonpickle I get UnicodeDecodeError: 'utf8' codec can't decode byte 0x9d in position 97: invalid start byte . Test code below is using jsonpickle with the error shown above. if len(sys.argv) < 2: print ("Error: missing ser file") sys.exit() else : fileLocation = sys.argv[1]

Protocol buffer `ParseFromString` in Java for parsing text format?

懵懂的女人 提交于 2019-11-30 03:01:54
问题 Is ParseFromString available in Java for protocol buffers? The C++ version has it: here 回答1: Here is the implementation of ParseFromString (note that TextFormat::ParseFromString simply calls TextFormat::Parser::ParseFromString on a new Parser object): bool TextFormat::Parser::Parse(io::ZeroCopyInputStream* input, Message* output) { output->Clear(); return Merge(input, output); } bool TextFormat::Parser::ParseFromString(const string& input, Message* output) { io::ArrayInputStream input_stream