Porotobuf 折腾

#pragma comment(lib,"libprotobuf.lib")

#include <iostream>

#include "task_plan.pb.h"

using namespace std;

int main()
{
	name_space::sdb::__TIME_PLAN__ time_plan;

	time_rec_plan.set_repoolid("10");

	string msg;
	time_rec_plan.SerializeToString(&msg);

	name_space::sdb::__TIME_PLAN__ new_one;
	new_one.ParseFromString(msg);

	return 0;
}


【编译protobuf库】和【使用protobuf库】这两个工程的编译器必须一致(在这里整整耗了一天的时间)


list,也就是repeat,要添加元素,需要使用指针,像这样:


__MapFieldEntry__ *map_field;
__TIME_RECORD_PLAN__ time_rec_plan;

map_field = time_rec_plan.add_map_field();

map_field->set_key(77);









猜你喜欢

转载自blog.csdn.net/zhangatm/article/details/79616437