Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- syntax = "proto3";
- package apple;
- message Message {
- repeated int32 id = 1;
- string name = 2;
- wife mywife = 3;
- enum phonetype
- {
- INVALID = 0;
- MOBILE = 1;
- HOME = 2;
- }
- phonetype type = 4;
- }
- message wife
- {
- string her_name = 1;
- int32 age = 2;
- enum sex
- {
- INVALID = 0;
- FEMALE =1;
- MALE=2;
- }
- sex orient = 3;
- }
- using namespace google::protobuf;
- using namespace std;
- int main(int argc, char const *argv[]) {
- apple::Message msg;
- msg.add_id(77);
- msg.set_name("xyz");
- auto w_msg = make_shared<apple::wife>();
- w_msg->set_her_name("abc");
- w_msg->set_age(88);
- w_msg->set_orient(apple::wife::MALE);
- msg.set_allocated_mywife(w_msg.get());
- cout << w_msg->her_name();
- return 0;
- }
Add Comment
Please, Sign In to add comment