資源簡介
protobuf枚舉和包的使用,相關教程:http://blog.csdn.net/tennysonsky/article/details/73921295
代碼片段和文件信息
#include?“addressbook.pb.h“
#include?
#include?
using?namespace?std;
void?set_addressbook()
{
tutorial::AddressBook?obj;
tutorial::Person?*p1?=?obj.add_people();?//新增加一個Person
p1->set_name(“mike“);
p1->set_id(1);
p1->set_email(“mike@qq.com“);
tutorial::Person::PhoneNumber?*phone1?=?p1->add_phones();?//增加一個phone
phone1->set_number(“110“);
phone1->set_type(tutorial::Person::MOBILE);
tutorial::Person::PhoneNumber?*phone2?=?p1->add_phones();?//增加一個phone
phone2->set_number(“120“);
phone2->set_type(tutorial::Person::HOME);
fstream?output(“pb.xxx“ios::out|ios::trunc|ios::binary);
bool?flag?=??obj.SerializeToOstream(&output);//序列化
if(?!flag?)
{
??????cerr?<“Failed?to?write?file.“?<??????return;
????}
output.close();//關閉文件
}
void?get_addr
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-06-29?18:00??protobuf枚舉和包的使用\
?????目錄???????????0??2017-06-29?18:00??protobuf枚舉和包的使用\包(Package)的使用\
?????文件???????46034??2017-06-28?05:04??protobuf枚舉和包的使用\包(Package)的使用\addressbook.pb.cc
?????文件???????25491??2017-06-28?05:04??protobuf枚舉和包的使用\包(Package)的使用\addressbook.pb.h
?????文件?????????586??2017-06-28?05:04??protobuf枚舉和包的使用\包(Package)的使用\addressbook.proto
?????文件??????????39??2017-06-28?05:08??protobuf枚舉和包的使用\包(Package)的使用\pb.xxx
?????文件????????2166??2017-06-28?05:08??protobuf枚舉和包的使用\包(Package)的使用\test.cpp
?????目錄???????????0??2017-06-29?18:00??protobuf枚舉和包的使用\枚舉的使用\
?????文件???????44756??2017-06-28?04:55??protobuf枚舉和包的使用\枚舉的使用\addressbook.pb.cc
?????文件???????24647??2017-06-28?04:55??protobuf枚舉和包的使用\枚舉的使用\addressbook.pb.h
?????文件?????????548??2017-06-28?04:37??protobuf枚舉和包的使用\枚舉的使用\addressbook.proto
?????文件??????????39??2017-06-28?04:58??protobuf枚舉和包的使用\枚舉的使用\pb.xxx
?????文件????????2046??2017-06-28?04:58??protobuf枚舉和包的使用\枚舉的使用\test.cpp
評論
共有 條評論