Hi,all
    I hava a simple .proto file like this:
########test.proto###########
syntax = "proto3";
package test;
message RowInfo {
    string key = 1;
    map<string, string> fields = 2;
}
########test.proto###########
But I have to assign RowInfo  with mutable_fields() method which return 
 ::google::protobuf::Map< ::std::string, ::std::string >*.

#include "prototest/test.pb.h"
#include <stdio.h>
int main()
{
    using namespace test;
    RowInfo row;
    row.set_key("mykey");
    ::google::protobuf::Map< ::std::string, ::std::string >* pmap = 
row.mutable_fields();
    (*pmap)["name"]="jimmy";
    (*pmap)["age"]="21";
    std::string str;
    row.SerializeToString(&str); // 将对象序列化到字符串
    printf("%s\n",str.c_str());
}

Is there a way to SerializeToString more convenient?

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to