我收到的消息是
Package letters;
message A
{
message Aa
{
// fields
}
message Aaa
{
// fields
}
repeated Aa AaMessage = 1;
repeated Aaa AaaMessage = 2;
}
message B
{
message Bb
{
// fields
}
message Bbb
{
// fields
}
repeated Bb BbMessage = 1;
repeated Bbb BbbMessage = 2;
}
message alphabet
{
repeated A MessageA = 1;
repeated B MessageB = 2;
}
我使用CPP_OUT编译了原型文件。编译和序列化消息没问题。我使用SerializeToString()作为..
序列化了消息letters::alphabet letterMessage;
letters::A* aMessageFields = letterMessage->add_messagea();
letters::Aa* aaMessageFields = aMessageFields->add_aamessage();
// set some default values for all fields in message
std::string SerializedMessage;
letterMessage.SerializeToString(&SerializedMessage);
我在另一个std :: wstring中也有JSON序列化消息。我需要将这两个消息作为单个值传递,这意味着单个消息。所以我尝试连接字符串类型protobuffer序列化值和std :: wstring JSON序列化值,并将结果字符串存储在std :: string中。我尝试了很多方法。什么都行不通:(
std::string SerializedMessage;
std::wstring JSONserializedMessage;
std::string completeMessage;
completeMessage = SerializedMessage + JSONserializedMessage;
//may be this is stupid but i want something really work like this
如果我在这里弄错了,请纠正我。
先谢谢..