github.com/matm/etcd@v0.3.1-0.20140328024009-5b4a473f1453/third_party/code.google.com/p/goprotobuf/proto/testdata/test.proto (about)

     1  // Go support for Protocol Buffers - Google's data interchange format
     2  //
     3  // Copyright 2010 The Go Authors.  All rights reserved.
     4  // http://code.google.com/p/goprotobuf/
     5  //
     6  // Redistribution and use in source and binary forms, with or without
     7  // modification, are permitted provided that the following conditions are
     8  // met:
     9  //
    10  //     * Redistributions of source code must retain the above copyright
    11  // notice, this list of conditions and the following disclaimer.
    12  //     * Redistributions in binary form must reproduce the above
    13  // copyright notice, this list of conditions and the following disclaimer
    14  // in the documentation and/or other materials provided with the
    15  // distribution.
    16  //     * Neither the name of Google Inc. nor the names of its
    17  // contributors may be used to endorse or promote products derived from
    18  // this software without specific prior written permission.
    19  //
    20  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    21  // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    22  // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    23  // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    24  // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    25  // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    26  // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    27  // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    28  // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    29  // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    30  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31  
    32  // A feature-rich test file for the protocol compiler and libraries.
    33  
    34  syntax = "proto2";
    35  
    36  package testdata;
    37  
    38  enum FOO { FOO1 = 1; };
    39  
    40  message GoEnum {
    41    required FOO foo = 1;
    42  }
    43  
    44  message GoTestField {
    45    required string Label = 1;
    46    required string Type = 2;
    47  }
    48  
    49  message GoTest {
    50    // An enum, for completeness.
    51    enum KIND {
    52      VOID = 0;
    53  
    54      // Basic types
    55      BOOL = 1;
    56      BYTES = 2;
    57      FINGERPRINT = 3;
    58      FLOAT = 4;
    59      INT = 5;
    60      STRING = 6;
    61      TIME = 7;
    62  
    63      // Groupings
    64      TUPLE = 8;
    65      ARRAY = 9;
    66      MAP = 10;
    67  
    68      // Table types
    69      TABLE = 11;
    70  
    71      // Functions
    72      FUNCTION = 12;  // last tag
    73    };
    74  
    75    // Some typical parameters
    76    required KIND Kind = 1;
    77    optional string Table = 2;
    78    optional int32 Param = 3;
    79  
    80    // Required, repeated and optional foreign fields.
    81    required GoTestField RequiredField = 4;
    82    repeated GoTestField RepeatedField = 5;
    83    optional GoTestField OptionalField = 6;
    84  
    85    // Required fields of all basic types
    86    required bool F_Bool_required = 10;
    87    required int32 F_Int32_required = 11;
    88    required int64 F_Int64_required = 12;
    89    required fixed32 F_Fixed32_required = 13;
    90    required fixed64 F_Fixed64_required = 14;
    91    required uint32 F_Uint32_required = 15;
    92    required uint64 F_Uint64_required = 16;
    93    required float F_Float_required = 17;
    94    required double F_Double_required = 18;
    95    required string F_String_required = 19;
    96    required bytes F_Bytes_required = 101;
    97    required sint32 F_Sint32_required = 102;
    98    required sint64 F_Sint64_required = 103;
    99  
   100    // Repeated fields of all basic types
   101    repeated bool F_Bool_repeated = 20;
   102    repeated int32 F_Int32_repeated = 21;
   103    repeated int64 F_Int64_repeated = 22;
   104    repeated fixed32 F_Fixed32_repeated = 23;
   105    repeated fixed64 F_Fixed64_repeated = 24;
   106    repeated uint32 F_Uint32_repeated = 25;
   107    repeated uint64 F_Uint64_repeated = 26;
   108    repeated float F_Float_repeated = 27;
   109    repeated double F_Double_repeated = 28;
   110    repeated string F_String_repeated = 29;
   111    repeated bytes F_Bytes_repeated = 201;
   112    repeated sint32 F_Sint32_repeated = 202;
   113    repeated sint64 F_Sint64_repeated = 203;
   114  
   115    // Optional fields of all basic types
   116    optional bool F_Bool_optional = 30;
   117    optional int32 F_Int32_optional = 31;
   118    optional int64 F_Int64_optional = 32;
   119    optional fixed32 F_Fixed32_optional = 33;
   120    optional fixed64 F_Fixed64_optional = 34;
   121    optional uint32 F_Uint32_optional = 35;
   122    optional uint64 F_Uint64_optional = 36;
   123    optional float F_Float_optional = 37;
   124    optional double F_Double_optional = 38;
   125    optional string F_String_optional = 39;
   126    optional bytes F_Bytes_optional = 301;
   127    optional sint32 F_Sint32_optional = 302;
   128    optional sint64 F_Sint64_optional = 303;
   129  
   130    // Default-valued fields of all basic types
   131    optional bool F_Bool_defaulted = 40 [default=true];
   132    optional int32 F_Int32_defaulted = 41 [default=32];
   133    optional int64 F_Int64_defaulted = 42 [default=64];
   134    optional fixed32 F_Fixed32_defaulted = 43 [default=320];
   135    optional fixed64 F_Fixed64_defaulted = 44 [default=640];
   136    optional uint32 F_Uint32_defaulted = 45 [default=3200];
   137    optional uint64 F_Uint64_defaulted = 46 [default=6400];
   138    optional float F_Float_defaulted = 47 [default=314159.];
   139    optional double F_Double_defaulted = 48 [default=271828.];
   140    optional string F_String_defaulted = 49 [default="hello, \"world!\"\n"];
   141    optional bytes F_Bytes_defaulted = 401 [default="Bignose"];
   142    optional sint32 F_Sint32_defaulted = 402 [default = -32];
   143    optional sint64 F_Sint64_defaulted = 403 [default = -64];
   144  
   145    // Packed repeated fields (no string or bytes).
   146    repeated bool F_Bool_repeated_packed = 50 [packed=true];
   147    repeated int32 F_Int32_repeated_packed = 51 [packed=true];
   148    repeated int64 F_Int64_repeated_packed = 52 [packed=true];
   149    repeated fixed32 F_Fixed32_repeated_packed = 53 [packed=true];
   150    repeated fixed64 F_Fixed64_repeated_packed = 54 [packed=true];
   151    repeated uint32 F_Uint32_repeated_packed = 55 [packed=true];
   152    repeated uint64 F_Uint64_repeated_packed = 56 [packed=true];
   153    repeated float F_Float_repeated_packed = 57 [packed=true];
   154    repeated double F_Double_repeated_packed = 58 [packed=true];
   155    repeated sint32 F_Sint32_repeated_packed = 502 [packed=true];
   156    repeated sint64 F_Sint64_repeated_packed = 503 [packed=true];
   157  
   158    // Required, repeated, and optional groups.
   159    required group RequiredGroup = 70 {
   160      required string RequiredField = 71;
   161    };
   162  
   163    repeated group RepeatedGroup = 80 {
   164      required string RequiredField = 81;
   165    };
   166  
   167    optional group OptionalGroup = 90 {
   168      required string RequiredField = 91;
   169    };
   170  }
   171  
   172  // For testing skipping of unrecognized fields.
   173  // Numbers are all big, larger than tag numbers in GoTestField,
   174  // the message used in the corresponding test.
   175  message GoSkipTest {
   176    required int32 skip_int32 = 11;
   177    required fixed32 skip_fixed32 = 12;
   178    required fixed64 skip_fixed64 = 13;
   179    required string skip_string = 14;
   180    required group SkipGroup = 15 {
   181      required int32 group_int32 = 16;
   182      required string group_string = 17;
   183    }
   184  }
   185  
   186  // For testing packed/non-packed decoder switching.
   187  // A serialized instance of one should be deserializable as the other.
   188  message NonPackedTest {
   189    repeated int32 a = 1;
   190  }
   191  
   192  message PackedTest {
   193    repeated int32 b = 1 [packed=true];
   194  }
   195  
   196  message MaxTag {
   197    // Maximum possible tag number.
   198    optional string last_field = 536870911;
   199  }
   200  
   201  message OldMessage {
   202    message Nested {
   203      optional string name = 1;
   204    }
   205    optional Nested nested = 1;
   206  }
   207  
   208  // NewMessage is wire compatible with OldMessage;
   209  // imagine it as a future version.
   210  message NewMessage {
   211    message Nested {
   212      optional string name = 1;
   213      optional string food_group = 2;
   214    }
   215    optional Nested nested = 1;
   216  }
   217  
   218  // Smaller tests for ASCII formatting.
   219  
   220  message InnerMessage {
   221    required string host = 1;
   222    optional int32 port = 2 [default=4000];
   223    optional bool connected = 3;
   224  }
   225  
   226  message OtherMessage {
   227    optional int64 key = 1;
   228    optional bytes value = 2;
   229    optional float weight = 3;
   230    optional InnerMessage inner = 4;
   231  }
   232  
   233  message MyMessage {
   234    required int32 count = 1;
   235    optional string name = 2;
   236    optional string quote = 3;
   237    repeated string pet = 4;
   238    optional InnerMessage inner = 5;
   239    repeated OtherMessage others = 6;
   240    repeated InnerMessage rep_inner = 12;
   241  
   242    enum Color {
   243      RED = 0;
   244      GREEN = 1;
   245      BLUE = 2;
   246    };
   247    optional Color bikeshed = 7;
   248  
   249    optional group SomeGroup = 8 {
   250      optional int32 group_field = 9;
   251    }
   252  
   253    // This field becomes [][]byte in the generated code.
   254    repeated bytes rep_bytes = 10;
   255  
   256    optional double bigfloat = 11;
   257  
   258    extensions 100 to max;
   259  }
   260  
   261  message Ext {
   262    extend MyMessage {
   263      optional Ext more = 103;
   264      optional string text = 104;
   265      optional int32 number = 105;
   266    }
   267  
   268    optional string data = 1;
   269  }
   270  
   271  extend MyMessage {
   272    repeated string greeting = 106;
   273  }
   274  
   275  message MyMessageSet {
   276    option message_set_wire_format = true;
   277    extensions 100 to max;
   278  }
   279  
   280  message Empty {
   281  }
   282  
   283  extend MyMessageSet {
   284      optional Empty x201 = 201;
   285      optional Empty x202 = 202;
   286      optional Empty x203 = 203;
   287      optional Empty x204 = 204;
   288      optional Empty x205 = 205;
   289      optional Empty x206 = 206;
   290      optional Empty x207 = 207;
   291      optional Empty x208 = 208;
   292      optional Empty x209 = 209;
   293      optional Empty x210 = 210;
   294      optional Empty x211 = 211;
   295      optional Empty x212 = 212;
   296      optional Empty x213 = 213;
   297      optional Empty x214 = 214;
   298      optional Empty x215 = 215;
   299      optional Empty x216 = 216;
   300      optional Empty x217 = 217;
   301      optional Empty x218 = 218;
   302      optional Empty x219 = 219;
   303      optional Empty x220 = 220;
   304      optional Empty x221 = 221;
   305      optional Empty x222 = 222;
   306      optional Empty x223 = 223;
   307      optional Empty x224 = 224;
   308      optional Empty x225 = 225;
   309      optional Empty x226 = 226;
   310      optional Empty x227 = 227;
   311      optional Empty x228 = 228;
   312      optional Empty x229 = 229;
   313      optional Empty x230 = 230;
   314      optional Empty x231 = 231;
   315      optional Empty x232 = 232;
   316      optional Empty x233 = 233;
   317      optional Empty x234 = 234;
   318      optional Empty x235 = 235;
   319      optional Empty x236 = 236;
   320      optional Empty x237 = 237;
   321      optional Empty x238 = 238;
   322      optional Empty x239 = 239;
   323      optional Empty x240 = 240;
   324      optional Empty x241 = 241;
   325      optional Empty x242 = 242;
   326      optional Empty x243 = 243;
   327      optional Empty x244 = 244;
   328      optional Empty x245 = 245;
   329      optional Empty x246 = 246;
   330      optional Empty x247 = 247;
   331      optional Empty x248 = 248;
   332      optional Empty x249 = 249;
   333      optional Empty x250 = 250;
   334  }
   335  
   336  message MessageList {
   337    repeated group Message = 1 {
   338      required string name = 2;
   339      required int32 count = 3;
   340    }
   341  }
   342  
   343  message Strings {
   344    optional string string_field = 1;
   345    optional bytes bytes_field = 2;
   346  }
   347  
   348  message Defaults {
   349    enum Color {
   350      RED = 0;
   351      GREEN = 1;
   352      BLUE = 2;
   353    }
   354  
   355    // Default-valued fields of all basic types.
   356    // Same as GoTest, but copied here to make testing easier.
   357    optional bool F_Bool = 1 [default=true];
   358    optional int32 F_Int32 = 2 [default=32];
   359    optional int64 F_Int64 = 3 [default=64];
   360    optional fixed32 F_Fixed32 = 4 [default=320];
   361    optional fixed64 F_Fixed64 = 5 [default=640];
   362    optional uint32 F_Uint32 = 6 [default=3200];
   363    optional uint64 F_Uint64 = 7 [default=6400];
   364    optional float F_Float = 8 [default=314159.];
   365    optional double F_Double = 9 [default=271828.];
   366    optional string F_String = 10 [default="hello, \"world!\"\n"];
   367    optional bytes F_Bytes = 11 [default="Bignose"];
   368    optional sint32 F_Sint32 = 12 [default=-32];
   369    optional sint64 F_Sint64 = 13 [default=-64];
   370    optional Color F_Enum = 14 [default=GREEN];
   371  
   372    // More fields with crazy defaults.
   373    optional float F_Pinf = 15 [default=inf];
   374    optional float F_Ninf = 16 [default=-inf];
   375    optional float F_Nan = 17 [default=nan];
   376  
   377    // Sub-message.
   378    optional SubDefaults sub = 18;
   379  }
   380  
   381  message SubDefaults {
   382    optional int64 n = 1 [default=7];
   383  }
   384  
   385  message RepeatedEnum {
   386    enum Color {
   387      RED = 1;
   388    }
   389    repeated Color color = 1;
   390  }
   391  
   392  message MoreRepeated {
   393    repeated bool bools = 1;
   394    repeated bool bools_packed = 2 [packed=true];
   395    repeated int32 ints = 3;
   396    repeated int32 ints_packed = 4 [packed=true];
   397    repeated int64 int64s_packed = 7 [packed=true];
   398    repeated string strings = 5;
   399    repeated fixed32 fixeds = 6;
   400  }
   401  
   402  // GroupOld and GroupNew have the same wire format.
   403  // GroupNew has a new field inside a group.
   404  
   405  message GroupOld {
   406    optional group G = 101 {
   407      optional int32 x = 2;
   408    }
   409  }
   410  
   411  message GroupNew {
   412    optional group G = 101 {
   413      optional int32 x = 2;
   414      optional int32 y = 3;
   415    }
   416  }
   417  
   418  message FloatingPoint {
   419    required double f = 1;
   420  }