protocol-buffers

error with serialization with protobuf

跟風遠走 提交于 2019-11-29 05:34:11
I'm trying to serialize a structure with protobuf. after many hours trying to figure out what I'm doing wrong I decided to test the google's example and it didn't worked as well I have the following protocol from google ( https://developers.google.com/protocol-buffers/docs/javatutorial ): package tutorial; option java_package = "com.example.tutorial"; option java_outer_classname = "AddressBookProtos"; message Person { required string name = 1; required int32 id = 2; optional string email = 3; repeated PhoneNumber phone = 4; enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2; } message PhoneNumber

AttributeError: Assignment not allowed to composite field “task” in protocol message object

你离开我真会死。 提交于 2019-11-29 05:27:00
I'm using protocol-buffers python lib to send data,but it's have some problems, so Traceback (most recent call last): File "test_message.py", line 17, in <module> ptask.task = task File "build\bdist.win32\egg\google\protobuf\internal\python_message.py", line 513, in setter AttributeError: Assignment not allowed to composite field "_task" in protocol message object. the src as follows: proto file: message task { required int32 id = 1; required string msg = 2; } message task_info { required task task = 1; } python code: task = yacc.task() task.id = 1000 task.msg = u"test" ptask = yacc.task_info(

Can't compile example from google protocol buffers

十年热恋 提交于 2019-11-29 03:51:04
I grep for other topics, but they dont help me =(. On my working server, i have no sudo privilegies, so i install PB with ./configure --prefix=/home/username/local Then i create source files with "person" example and succesfully compile it with protoc. I have no pkg-info =(. I try to compile it with g++ -I /home/username/local/include -L /home/username/local/lib -lprotobuf -lpthread main.cpp person.pb.cc and then have a billion simular errors i.e. person.pb.cc:(.text+0x4cf): undefined reference to `google::protobuf::internal::kEmptyString' I think, that it is a problem with linking, but how to

How to link google protobuf libraries via cmake on linux?

[亡魂溺海] 提交于 2019-11-29 03:07:49
I'm trying to make it same way I made it for boost : find_package(Boost COMPONENTS system filesystem REQUIRED) find_package(ProtocolBuffers) ## Compiler flags if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "-O2") set(CMAKE_EXE_LINKER_FLAGS "-lsqlite3 -lrt -lpthread") endif() target_link_libraries(complex ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${PROTOBUF_LIBRARY} ) (googled it somewhere) but got bad output: CMake Warning at complex/CMakeLists.txt:18 (find_package): Could not find module FindProtocolBuffers.cmake or a configuration file for package ProtocolBuffers. Adjust CMAKE

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

会有一股神秘感。 提交于 2019-11-29 02:31:46
问题 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) {

how do has_field() methods relate to default values in protobuf?

时间秒杀一切 提交于 2019-11-29 01:09:42
I'm trying to determine the relationship between default values and the has_foo() methods that are declared in various programmatic interfaces. In particular, I'm trying to determine under what circumstances (if any) you can "tell the difference" between a field explicitly set to the default value, and an unset value. If I explicitly set a field (e.g. "Bar.foo") to its default value (e.g., zero), then is Bar::has_foo() guaranteed return true for that data structure? (This appears to be true for the C++ generated code, from a quick inspection, but that doesn't mean it's guaranteed.) If this is

Protobuf: Will set_allocated_* delete the allocated object?

回眸只為那壹抹淺笑 提交于 2019-11-29 01:07:04
I have this small protobuf code (simplified, only the necessary is contained): message ParamsMessage { required int32 temperature = 1; } message MasterMessage { enum Type { GETPARAMS = 1; SENDPARAMS = 2;} required Type type = 1; optional ParamsMessage paramsMessage = 2; } I now create a MasterMessage in the following way: ParamsMessage * params = new ParamsMessage(); params->set_temperature(22); MasterMessage master; master.set_type(MasterMessage::SENDPARAMS); master.set_allocated_paramsmessage(params); The question is: Do I have to (after dealing with the message) delete the params Message,

Using Protocol Buffers with Objective-C

試著忘記壹切 提交于 2019-11-29 00:28:20
问题 Has anyone used Google's Protocol Buffers when developing applications in Objective-C? Are there any current projects for compiling .proto files into Objective-C, all the Google docs simply refer to Java, C++ or Python. 回答1: I've been working on an fork of Cyrus' project. It's based on protobuf 2.3 and works as a protoc plugin ( protoc-gen-objc ) instead of requiring a modified protobuf distribution. You can find it as the protobuf-obj project on GitHub. 回答2: The Third Party page lists this

protobuf-net serializing object graph

心已入冬 提交于 2019-11-28 23:18:48
If I have object A and B both contain some field serialized field F, and both point to the same serializable object C. Does protobuf-net serialize by reference or serialize by value? When the object graph is deserialized, does protobuf-net generate 2 separate objects for A.F and B.F? I'm asking because I want to know if serialization preserves reference equality. The raw "protobuf" spec, a defined by Google, is a tree serializer (like XmlSerializer). So by default you would get C serialized twice, and two different objects when deserialized. However, this is such a common question that in "v2"

Compile protobuf with xCode 5

人走茶凉 提交于 2019-11-28 22:05:00
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. 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 static library that is universal. It will also produce the protoc compiler for use on OS X. You can add