在类google::protobuf::Message中有protobuf通讯的函数,将信息序列化和反序列化,在由proto文件生成的.cc和.h文件中,消息体生成由命名空间匡制,继承google::protobuf::Message的类。
在生成的test.pb.h中
/* @@protoc_insertion_point(class_definition:zxtest.prototest.TestSend) */
class TestSend : public ::google::protobuf::Message {
public:
TestSend();
virtual ~TestSend();
TestSend(const TestSend& from);
...
}
序列化和反序列化
序列化函数组
//序列化到编码流
bool SerializeToCodedStream(io::CodedOutputStream* output) const;
//序列化到字符串
bool SerializeToString(string* output) const;
//序列化为字符串
string SerializeAsString() const;
//序列化到数组
bool SerializeToArray(void* data, int size) const;
反序列化数组