zoukankan      html  css  js  c++  java
  • protobuffer语法汇总-c++

    拿一个pb为样例

    syntax = "proto2";
    
    package tutorial;
    
    message Person {
      required string name = 1;
      required int32 id = 2;
      optional string email = 3;
    
      enum PhoneType {
        MOBILE = 0;
        HOME = 1;
        WORK = 2;
      }
    
      message PhoneNumber {
        required string number = 1;
        optional PhoneType type = 2 [default = HOME];
      }
    
      repeated PhoneNumber phones = 4;
    }
    
    message AddressBook {
      repeated Person people = 1;
    }

    API

     // required name
      inline bool has_name() const;
      inline void clear_name();
      inline const ::std::string& name() const;
      inline void set_name(const ::std::string& value);
      inline void set_name(const char* value);
      inline ::std::string* mutable_name();
    
      // required id
      inline bool has_id() const;
      inline void clear_id();
      inline int32_t id() const;
      inline void set_id(int32_t value);
    
      // optional email
      inline bool has_email() const;
      inline void clear_email();
      inline const ::std::string& email() const;
      inline void set_email(const ::std::string& value);
      inline void set_email(const char* value);
      inline ::std::string* mutable_email();
    
      // repeated phones
      inline int phones_size() const;
      inline void clear_phones();
      inline const ::google::protobuf::RepeatedPtrField< ::tutorial::Person_PhoneNumber >& phones() const;
      inline ::google::protobuf::RepeatedPtrField< ::tutorial::Person_PhoneNumber >* mutable_phones();
      inline const ::tutorial::Person_PhoneNumber& phones(int index) const;
      inline ::tutorial::Person_PhoneNumber* mutable_phones(int index);
      inline ::tutorial::Person_PhoneNumber* add_phones();

    参考文章:

    https://www.jianshu.com/p/d2bed3614259

  • 相关阅读:
    Linux命令笔记
    拆功放板笔记
    从输入 URL 到页面加载完的过程中都发生了什么---优化
    python学习笔记(三)
    python学习笔记(二)
    python学习笔记(一)
    公交wifi运营平台分析
    testNG小试牛刀
    maven小项目注册服务(三)--web模块
    用maven进行测试
  • 原文地址:https://www.cnblogs.com/lance-/p/14606216.html
Copyright © 2011-2022 走看看