1// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc.  All rights reserved.
3// https://developers.google.com/protocol-buffers/
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9//     * Redistributions of source code must retain the above copyright
10// notice, this list of conditions and the following disclaimer.
11//     * Redistributions in binary form must reproduce the above
12// copyright notice, this list of conditions and the following disclaimer
13// in the documentation and/or other materials provided with the
14// distribution.
15//     * Neither the name of Google Inc. nor the names of its
16// contributors may be used to endorse or promote products derived from
17// this software without specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31// Author: kenton@google.com (Kenton Varda)
32//  Based on original Protocol Buffers design by
33//  Sanjay Ghemawat, Jeff Dean, and others.
34//
35// The messages in this file describe the definitions found in .proto files.
36// A valid .proto file can be translated directly to a FileDescriptorProto
37// without any other information (e.g. without reading its imports).
38
39syntax = "proto2";
40
41// A message representing a option the parser does not recognize. This only
42// appears in options protos created by the compiler::Parser class.
43// DescriptorPool resolves these when building Descriptor objects. Therefore,
44// options protos in descriptor objects (e.g. returned by Descriptor::options(),
45// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
46// in them.
47message UninterpretedOption {
48  // The name of the uninterpreted option.  Each string represents a segment in
49  // a dot-separated name.  is_extension is true iff a segment represents an
50  // extension (denoted with parentheses in options specs in .proto files).
51  // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
52  // "foo.(bar.baz).qux".
53  message NamePart {
54    required string name_part = 1;
55
56    required bool is_extension = 2;
57  }
58
59  optional bytes string_value = 7;
60
61  optional uint64 positive_int_value = 4;
62
63  optional int64 negative_int_value = 5;
64
65  repeated NamePart name = 2;
66
67  // The value of the uninterpreted option, in whatever type the tokenizer
68  // identified it as during parsing. Exactly one of these should be set.
69  optional string identifier_value = 3;
70
71  optional double double_value = 6;
72
73  optional string aggregate_value = 8;
74}
75
76// ===================================================================
77// Optional source code info
78
79// Encapsulates information about the original source file from which a
80// FileDescriptorProto was generated.
81message SourceCodeInfo {
82  message Location {
83    optional string trailing_comments = 4;
84
85    // Always has exactly three or four elements: start line, start column,
86    // end line (optional, otherwise assumed same as start line), end column.
87    // These are packed into a single field for efficiency.  Note that line
88    // and column numbers are zero-based -- typically you will want to add
89    // 1 to each before displaying to a user.
90    repeated int32 span = 2 [packed = true];
91
92    // Identifies which part of the FileDescriptorProto was defined at this
93    // location.
94    //
95    // Each element is a field number or an index.  They form a path from
96    // the root FileDescriptorProto to the place where the definition.  For
97    // example, this path:
98    //   [ 4, 3, 2, 7, 1 ]
99    // refers to:
100    //   file.message_type(3)  // 4, 3
101    //       .field(7)         // 2, 7
102    //       .name()           // 1
103    // This is because FileDescriptorProto.message_type has field number 4:
104    //   repeated DescriptorProto message_type = 4;
105    // and DescriptorProto.field has field number 2:
106    //   repeated FieldDescriptorProto field = 2;
107    // and FieldDescriptorProto.name has field number 1:
108    //   optional string name = 1;
109    //
110    // Thus, the above path gives the location of a field name.  If we removed
111    // the last element:
112    //   [ 4, 3, 2, 7 ]
113    // this path refers to the whole field declaration (from the beginning
114    // of the label to the terminating semicolon).
115    repeated int32 path = 1 [packed = true];
116
117    repeated string leading_detached_comments = 6;
118
119    // If this SourceCodeInfo represents a complete declaration, these are any
120    // comments appearing before and after the declaration which appear to be
121    // attached to the declaration.
122    //
123    // A series of line comments appearing on consecutive lines, with no other
124    // tokens appearing on those lines, will be treated as a single comment.
125    //
126    // leading_detached_comments will keep paragraphs of comments that appear
127    // before (but not connected to) the current element. Each paragraph,
128    // separated by empty lines, will be one comment element in the repeated
129    // field.
130    //
131    // Only the comment content is provided; comment markers (e.g. //) are
132    // stripped out.  For block comments, leading whitespace and an asterisk
133    // will be stripped from the beginning of each line other than the first.
134    // Newlines are included in the output.
135    //
136    // Examples:
137    //
138    //   optional int32 foo = 1;  // Comment attached to foo.
139    //   // Comment attached to bar.
140    //   optional int32 bar = 2;
141    //
142    //   optional string baz = 3;
143    //   // Comment attached to baz.
144    //   // Another line attached to baz.
145    //
146    //   // Comment attached to qux.
147    //   //
148    //   // Another line attached to qux.
149    //   optional double qux = 4;
150    //
151    //   // Detached comment for corge. This is not leading or trailing comments
152    //   // to qux or corge because there are blank lines separating it from
153    //   // both.
154    //
155    //   // Detached comment for corge paragraph 2.
156    //
157    //   optional string corge = 5;
158    //   /* Block comment attached
159    //    * to corge.  Leading asterisks
160    //    * will be removed. */
161    //   /* Block comment attached to
162    //    * grault. */
163    //   optional int32 grault = 6;
164    //
165    //   // ignored detached comments.
166    optional string leading_comments = 3;
167  }
168
169  // A Location identifies a piece of source code in a .proto file which
170  // corresponds to a particular definition.  This information is intended
171  // to be useful to IDEs, code indexers, documentation generators, and similar
172  // tools.
173  //
174  // For example, say we have a file like:
175  //   message Foo {
176  //     optional string foo = 1;
177  //   }
178  // Let's look at just the field definition:
179  //   optional string foo = 1;
180  //   ^       ^^     ^^  ^  ^^^
181  //   a       bc     de  f  ghi
182  // We have the following locations:
183  //   span   path               represents
184  //   [a,i)  [ 4, 0, 2, 0 ]     The whole field definition.
185  //   [a,b)  [ 4, 0, 2, 0, 4 ]  The label (optional).
186  //   [c,d)  [ 4, 0, 2, 0, 5 ]  The type (string).
187  //   [e,f)  [ 4, 0, 2, 0, 1 ]  The name (foo).
188  //   [g,h)  [ 4, 0, 2, 0, 3 ]  The number (1).
189  //
190  // Notes:
191  // - A location may refer to a repeated field itself (i.e. not to any
192  //   particular index within it).  This is used whenever a set of elements are
193  //   logically enclosed in a single code segment.  For example, an entire
194  //   extend block (possibly containing multiple extension definitions) will
195  //   have an outer location whose path refers to the "extensions" repeated
196  //   field without an index.
197  // - Multiple locations may have the same path.  This happens when a single
198  //   logical declaration is spread out across multiple places.  The most
199  //   obvious example is the "extend" block again -- there may be multiple
200  //   extend blocks in the same scope, each of which will have the same path.
201  // - A location's span is not always a subset of its parent's span.  For
202  //   example, the "extendee" of an extension declaration appears at the
203  //   beginning of the "extend" block and is shared by all extensions within
204  //   the block.
205  // - Just because a location's span is a subset of some other location's span
206  //   does not mean that it is a descendant.  For example, a "group" defines
207  //   both a type and a field in a single declaration.  Thus, the locations
208  //   corresponding to the type and field and their components will overlap.
209  // - Code which tries to interpret locations should probably be designed to
210  //   ignore those that it doesn't understand, as more types of locations could
211  //   be recorded in the future.
212  repeated Location location = 1;
213}
214
215message ServiceOptions {
216  extensions 1000 to max;
217
218  // The parser stores options it doesn't recognize here. See above.
219  repeated UninterpretedOption uninterpreted_option = 999;
220
221  // Note:  Field numbers 1 through 32 are reserved for Google's internal RPC
222  //   framework.  We apologize for hoarding these numbers to ourselves, but
223  //   we were already using them long before we decided to release Protocol
224  //   Buffers.
225
226  // Is this service deprecated?
227  // Depending on the target platform, this can emit Deprecated annotations
228  // for the service, or it will be completely ignored; in the very least,
229  // this is a formalization for deprecating services.
230  optional bool deprecated = 33 [default = false];
231}
232
233// Describes a service.
234message ServiceDescriptorProto {
235  optional ServiceOptions options = 3;
236
237  optional string name = 1;
238
239  repeated MethodDescriptorProto method = 2;
240}
241
242message OneofOptions {
243  extensions 1000 to max;
244
245  // The parser stores options it doesn't recognize here. See above.
246  repeated UninterpretedOption uninterpreted_option = 999;
247}
248
249// Describes a oneof.
250message OneofDescriptorProto {
251  optional OneofOptions options = 2;
252
253  optional string name = 1;
254}
255
256message MethodOptions {
257  extensions 1000 to max;
258
259  // Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
260  // or neither? HTTP based RPC implementation may choose GET verb for safe
261  // methods, and PUT verb for idempotent methods instead of the default POST.
262  enum IdempotencyLevel {
263    NO_SIDE_EFFECTS = 1; // implies idempotent
264
265    IDEMPOTENT = 2; // idempotent, but may have side effects
266
267    IDEMPOTENCY_UNKNOWN = 0;
268  }
269
270  // The parser stores options it doesn't recognize here. See above.
271  repeated UninterpretedOption uninterpreted_option = 999;
272
273  optional IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
274
275  // Note:  Field numbers 1 through 32 are reserved for Google's internal RPC
276  //   framework.  We apologize for hoarding these numbers to ourselves, but
277  //   we were already using them long before we decided to release Protocol
278  //   Buffers.
279
280  // Is this method deprecated?
281  // Depending on the target platform, this can emit Deprecated annotations
282  // for the method, or it will be completely ignored; in the very least,
283  // this is a formalization for deprecating methods.
284  optional bool deprecated = 33 [default = false];
285}
286
287// Describes a method of a service.
288message MethodDescriptorProto {
289  // Identifies if server streams multiple server messages
290  optional bool server_streaming = 6 [default = false];
291
292  optional string output_type = 3;
293
294  optional MethodOptions options = 4;
295
296  optional string name = 1;
297
298  // Input and output type names.  These are resolved in the same way as
299  // FieldDescriptorProto.type_name, but must refer to a message type.
300  optional string input_type = 2;
301
302  // Identifies if client streams multiple client messages
303  optional bool client_streaming = 5 [default = false];
304}
305
306message MessageOptions {
307  reserved 9, 8;
308
309  extensions 1000 to max;
310
311  // The parser stores options it doesn't recognize here. See above.
312  repeated UninterpretedOption uninterpreted_option = 999;
313
314  // Disables the generation of the standard "descriptor()" accessor, which can
315  // conflict with a field of the same name.  This is meant to make migration
316  // from proto1 easier; new code should avoid fields named "descriptor".
317  optional bool no_standard_descriptor_accessor = 2 [default = false];
318
319  // Set true to use the old proto1 MessageSet wire format for extensions.
320  // This is provided for backwards-compatibility with the MessageSet wire
321  // format.  You should not use this for any other reason:  It's less
322  // efficient, has fewer features, and is more complicated.
323  //
324  // The message must be defined exactly as follows:
325  //   message Foo {
326  //     option message_set_wire_format = true;
327  //     extensions 4 to max;
328  //   }
329  // Note that the message cannot have any defined fields; MessageSets only
330  // have extensions.
331  //
332  // All extensions of your type must be singular messages; e.g. they cannot
333  // be int32s, enums, or repeated messages.
334  //
335  // Because this is an option, the above two restrictions are not enforced by
336  // the protocol compiler.
337  optional bool message_set_wire_format = 1 [default = false];
338
339  // Whether the message is an automatically generated map entry type for the
340  // maps field.
341  //
342  // For maps fields:
343  //     map<KeyType, ValueType> map_field = 1;
344  // The parsed descriptor looks like:
345  //     message MapFieldEntry {
346  //         option map_entry = true;
347  //         optional KeyType key = 1;
348  //         optional ValueType value = 2;
349  //     }
350  //     repeated MapFieldEntry map_field = 1;
351  //
352  // Implementations may choose not to generate the map_entry=true message, but
353  // use a native map in the target language to hold the keys and values.
354  // The reflection APIs in such implementations still need to work as
355  // if the field is a repeated message field.
356  //
357  // NOTE: Do not set the option in .proto files. Always use the maps syntax
358  // instead. The option should only be implicitly set by the proto compiler
359  // parser.
360  optional bool map_entry = 7;
361
362  // Is this message deprecated?
363  // Depending on the target platform, this can emit Deprecated annotations
364  // for the message, or it will be completely ignored; in the very least,
365  // this is a formalization for deprecating messages.
366  optional bool deprecated = 3 [default = false];
367}
368
369// Describes the relationship between generated code and its original source
370// file. A GeneratedCodeInfo message is associated with only one generated
371// source file, but may contain references to different source .proto files.
372message GeneratedCodeInfo {
373  message Annotation {
374    // Identifies the filesystem path to the original source .proto.
375    optional string source_file = 2;
376
377    // Identifies the element in the original source .proto file. This field
378    // is formatted the same as SourceCodeInfo.Location.path.
379    repeated int32 path = 1 [packed = true];
380
381    // Identifies the ending offset in bytes in the generated code that
382    // relates to the identified offset. The end offset should be one past
383    // the last relevant byte (so the length of the text = end - begin).
384    optional int32 end = 4;
385
386    // Identifies the starting offset in bytes in the generated code
387    // that relates to the identified object.
388    optional int32 begin = 3;
389  }
390
391  // An Annotation connects some span of text in generated code to an element
392  // of its generating .proto file.
393  repeated Annotation annotation = 1;
394}
395
396// ===================================================================
397// Options
398
399// Each of the definitions above may have "options" attached.  These are
400// just annotations which may cause code to be generated slightly differently
401// or may contain hints for code that manipulates protocol messages.
402//
403// Clients may define custom options as extensions of the *Options messages.
404// These extensions may not yet be known at parsing time, so the parser cannot
405// store the values in them.  Instead it stores them in a field in the *Options
406// message called uninterpreted_option. This field must have the same name
407// across all *Options messages. We then use this field to populate the
408// extensions when we build a descriptor, at which point all protos have been
409// parsed and so all extensions are known.
410//
411// Extension numbers for custom options may be chosen as follows:
412// * For options which will only be used within a single application or
413//   organization, or for experimental options, use field numbers 50000
414//   through 99999.  It is up to you to ensure that you do not use the
415//   same number for multiple options.
416// * For options which will be published and used publicly by multiple
417//   independent entities, e-mail protobuf-global-extension-registry@google.com
418//   to reserve extension numbers. Simply provide your project name (e.g.
419//   Objective-C plugin) and your project website (if available) -- there's no
420//   need to explain how you intend to use them. Usually you only need one
421//   extension number. You can declare multiple options with only one extension
422//   number by putting them in a sub-message. See the Custom Options section of
423//   the docs for examples:
424//   https://developers.google.com/protocol-buffers/docs/proto#options
425//   If this turns out to be popular, a web service will be set up
426//   to automatically assign option numbers.
427
428message FileOptions {
429  reserved 38;
430
431  extensions 1000 to max;
432
433  // Generated classes can be optimized for speed or code size.
434  enum OptimizeMode {
435    SPEED = 1; // Generate complete code for parsing, serialization,
436
437    LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
438
439    // etc.
440    CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
441  }
442
443  // The parser stores options it doesn't recognize here.
444  // See the documentation for the "Options" section above.
445  repeated UninterpretedOption uninterpreted_option = 999;
446
447  // By default Swift generators will take the proto package and CamelCase it
448  // replacing '.' with underscore and use that to prefix the types/symbols
449  // defined. When this options is provided, they will use this value instead
450  // to prefix the types/symbols defined.
451  optional string swift_prefix = 39;
452
453  // Use this option to change the package of ruby generated classes. Default
454  // is empty. When this option is not set, the package name will be used for
455  // determining the ruby package.
456  optional string ruby_package = 45;
457
458  optional bool py_generic_services = 18 [default = false];
459
460  // Use this option to change the namespace of php generated classes. Default
461  // is empty. When this option is empty, the package name will be used for
462  // determining the namespace.
463  optional string php_namespace = 41;
464
465  // Use this option to change the namespace of php generated metadata classes.
466  // Default is empty. When this option is empty, the proto file name will be
467  // used for determining the namespace.
468  optional string php_metadata_namespace = 44;
469
470  optional bool php_generic_services = 42 [default = false];
471
472  // Sets the php class prefix which is prepended to all php generated classes
473  // from this .proto. Default is empty.
474  optional string php_class_prefix = 40;
475
476  optional OptimizeMode optimize_for = 9 [default = SPEED];
477
478  // Sets the objective c class prefix which is prepended to all objective c
479  // generated classes from this .proto. There is no default.
480  optional string objc_class_prefix = 36;
481
482  // If set true, then the Java2 code generator will generate code that
483  // throws an exception whenever an attempt is made to assign a non-UTF-8
484  // byte sequence to a string field.
485  // Message reflection will do the same.
486  // However, an extension field still accepts non-UTF-8 byte sequences.
487  // This option has no effect on when used with the lite runtime.
488  optional bool java_string_check_utf8 = 27 [default = false];
489
490  // Sets the Java package where classes generated from this .proto will be
491  // placed.  By default, the proto package is used, but this is often
492  // inappropriate because proto packages do not normally start with backwards
493  // domain names.
494  optional string java_package = 1;
495
496  // If set, all the classes from the .proto file are wrapped in a single
497  // outer class with the given name.  This applies to both Proto1
498  // (equivalent to the old "--one_java_file" option) and Proto2 (where
499  // a .proto always translates to a single class, but you may want to
500  // explicitly choose the class name).
501  optional string java_outer_classname = 8;
502
503  // If set true, then the Java code generator will generate a separate .java
504  // file for each top-level message, enum, and service defined in the .proto
505  // file.  Thus, these types will *not* be nested inside the outer class
506  // named by java_outer_classname.  However, the outer class will still be
507  // generated to contain the file's getDescriptor() method as well as any
508  // top-level extensions defined in the file.
509  optional bool java_multiple_files = 10 [default = false];
510
511  optional bool java_generic_services = 17 [default = false];
512
513  // This option does nothing.
514  optional bool java_generate_equals_and_hash = 20 [deprecated = true];
515
516  // Sets the Go package where structs generated from this .proto will be
517  // placed. If omitted, the Go package will be derived from the following:
518  //   - The basename of the package import path, if provided.
519  //   - Otherwise, the package statement in the .proto file, if present.
520  //   - Otherwise, the basename of the .proto file, without extension.
521  optional string go_package = 11;
522
523  // Is this file deprecated?
524  // Depending on the target platform, this can emit Deprecated annotations
525  // for everything in the file, or it will be completely ignored; in the very
526  // least, this is a formalization for deprecating files.
527  optional bool deprecated = 23 [default = false];
528
529  // Namespace for generated classes; defaults to the package.
530  optional string csharp_namespace = 37;
531
532  // Should generic services be generated in each language?  "Generic" services
533  // are not specific to any particular RPC system.  They are generated by the
534  // main code generators in each language (without additional plugins).
535  // Generic services were the only kind of service generation supported by
536  // early versions of google.protobuf.
537  //
538  // Generic services are now considered deprecated in favor of using plugins
539  // that generate code specific to your particular RPC system.  Therefore,
540  // these default to false.  Old code which depends on generic services should
541  // explicitly set them to true.
542  optional bool cc_generic_services = 16 [default = false];
543
544  // Enables the use of arenas for the proto messages in this file. This applies
545  // only to generated classes for C++.
546  optional bool cc_enable_arenas = 31 [default = true];
547}
548
549// The protocol compiler can output a FileDescriptorSet containing the .proto
550// files it parses.
551message FileDescriptorSet {
552  repeated FileDescriptorProto file = 1;
553}
554
555// Describes a complete .proto file.
556message FileDescriptorProto {
557  // Indexes of the weak imported files in the dependency list.
558  // For Google-internal migration only. Do not use.
559  repeated int32 weak_dependency = 11;
560
561  // The syntax of the proto file.
562  // The supported values are "proto2" and "proto3".
563  optional string syntax = 12;
564
565  // This field contains optional information about the original source code.
566  // You may safely remove this entire field without harming runtime
567  // functionality of the descriptors -- the information is needed only by
568  // development tools.
569  optional SourceCodeInfo source_code_info = 9;
570
571  repeated ServiceDescriptorProto service = 6;
572
573  // Indexes of the public imported files in the dependency list above.
574  repeated int32 public_dependency = 10;
575
576  optional string package = 2; // e.g. "foo", "foo.bar", etc.
577
578  optional FileOptions options = 8;
579
580  optional string name = 1; // file name, relative to root of source tree
581
582  // All top-level definitions in this file.
583  repeated DescriptorProto message_type = 4;
584
585  repeated FieldDescriptorProto extension = 7;
586
587  repeated EnumDescriptorProto enum_type = 5;
588
589  // Names of files imported by this file.
590  repeated string dependency = 3;
591}
592
593message FieldOptions {
594  reserved 4;
595
596  extensions 1000 to max;
597
598  enum JSType {
599    // Use JavaScript strings.
600    JS_STRING = 1;
601
602    // Use JavaScript numbers.
603    JS_NUMBER = 2;
604
605    // Use the default type.
606    JS_NORMAL = 0;
607  }
608
609  enum CType {
610    STRING_PIECE = 2;
611
612    // Default mode.
613    STRING = 0;
614
615    CORD = 1;
616  }
617
618  // For Google-internal migration only. Do not use.
619  optional bool weak = 10 [default = false];
620
621  // The parser stores options it doesn't recognize here. See above.
622  repeated UninterpretedOption uninterpreted_option = 999;
623
624  // The packed option can be enabled for repeated primitive fields to enable
625  // a more efficient representation on the wire. Rather than repeatedly
626  // writing the tag and type for each element, the entire array is encoded as
627  // a single length-delimited blob. In proto3, only explicit setting it to
628  // false will avoid using packed encoding.
629  optional bool packed = 2;
630
631  // Should this field be parsed lazily?  Lazy applies only to message-type
632  // fields.  It means that when the outer message is initially parsed, the
633  // inner message's contents will not be parsed but instead stored in encoded
634  // form.  The inner message will actually be parsed when it is first accessed.
635  //
636  // This is only a hint.  Implementations are free to choose whether to use
637  // eager or lazy parsing regardless of the value of this option.  However,
638  // setting this option true suggests that the protocol author believes that
639  // using lazy parsing on this field is worth the additional bookkeeping
640  // overhead typically needed to implement it.
641  //
642  // This option does not affect the public interface of any generated code;
643  // all method signatures remain the same.  Furthermore, thread-safety of the
644  // interface is not affected by this option; const methods remain safe to
645  // call from multiple threads concurrently, while non-const methods continue
646  // to require exclusive access.
647  //
648  //
649  // Note that implementations may choose not to check required fields within
650  // a lazy sub-message.  That is, calling IsInitialized() on the outer message
651  // may return true even if the inner message has missing required fields.
652  // This is necessary because otherwise the inner message would have to be
653  // parsed in order to perform the check, defeating the purpose of lazy
654  // parsing.  An implementation which chooses not to check required fields
655  // must be consistent about it.  That is, for any particular sub-message, the
656  // implementation must either *always* check its required fields, or *never*
657  // check its required fields, regardless of whether or not the message has
658  // been parsed.
659  optional bool lazy = 5 [default = false];
660
661  // The jstype option determines the JavaScript type used for values of the
662  // field.  The option is permitted only for 64 bit integral and fixed types
663  // (int64, uint64, sint64, fixed64, sfixed64).  A field with jstype JS_STRING
664  // is represented as JavaScript string, which avoids loss of precision that
665  // can happen when a large value is converted to a floating point JavaScript.
666  // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to
667  // use the JavaScript "number" type.  The behavior of the default option
668  // JS_NORMAL is implementation dependent.
669  //
670  // This option is an enum to permit additional types to be added, e.g.
671  // goog.math.Integer.
672  optional JSType jstype = 6 [default = JS_NORMAL];
673
674  // Is this field deprecated?
675  // Depending on the target platform, this can emit Deprecated annotations
676  // for accessors, or it will be completely ignored; in the very least, this
677  // is a formalization for deprecating fields.
678  optional bool deprecated = 3 [default = false];
679
680  // The ctype option instructs the C++ code generator to use a different
681  // representation of the field than it normally would.  See the specific
682  // options below.  This option is not yet implemented in the open source
683  // release -- sorry, we'll try to include it in a future version!
684  optional CType ctype = 1 [default = STRING];
685}
686
687// Describes a field within a message.
688message FieldDescriptorProto {
689  enum Type {
690    TYPE_UINT64 = 4;
691
692    TYPE_UINT32 = 13;
693
694    TYPE_STRING = 9;
695
696    TYPE_SINT64 = 18; // Uses ZigZag encoding.
697
698    TYPE_SINT32 = 17; // Uses ZigZag encoding.
699
700    TYPE_SFIXED64 = 16;
701
702    TYPE_SFIXED32 = 15;
703
704    TYPE_MESSAGE = 11; // Length-delimited aggregate.
705
706    // Not ZigZag encoded.  Negative numbers take 10 bytes.  Use TYPE_SINT64 if
707    // negative values are likely.
708    TYPE_INT64 = 3;
709
710    // Not ZigZag encoded.  Negative numbers take 10 bytes.  Use TYPE_SINT32 if
711    // negative values are likely.
712    TYPE_INT32 = 5;
713
714    // Tag-delimited aggregate.
715    // Group type is deprecated and not supported in proto3. However, Proto3
716    // implementations should still be able to parse the group wire format and
717    // treat group fields as unknown fields.
718    TYPE_GROUP = 10;
719
720    TYPE_FLOAT = 2;
721
722    TYPE_FIXED64 = 6;
723
724    TYPE_FIXED32 = 7;
725
726    TYPE_ENUM = 14;
727
728    // 0 is reserved for errors.
729    // Order is weird for historical reasons.
730    TYPE_DOUBLE = 1;
731
732    // New in version 2.
733    TYPE_BYTES = 12;
734
735    TYPE_BOOL = 8;
736  }
737
738  enum Label {
739    LABEL_REQUIRED = 2;
740
741    LABEL_REPEATED = 3;
742
743    // 0 is reserved for errors
744    LABEL_OPTIONAL = 1;
745  }
746
747  // For message and enum types, this is the name of the type.  If the name
748  // starts with a '.', it is fully-qualified.  Otherwise, C++-like scoping
749  // rules are used to find the type (i.e. first the nested types within this
750  // message are searched, then within the parent, on up to the root
751  // namespace).
752  optional string type_name = 6;
753
754  // If type_name is set, this need not be set.  If both this and type_name
755  // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
756  optional Type type = 5;
757
758  // If true, this is a proto3 "optional". When a proto3 field is optional, it
759  // tracks presence regardless of field type.
760  //
761  // When proto3_optional is true, this field must be belong to a oneof to
762  // signal to old proto3 clients that presence is tracked for this field. This
763  // oneof is known as a "synthetic" oneof, and this field must be its sole
764  // member (each proto3 optional field gets its own synthetic oneof). Synthetic
765  // oneofs exist in the descriptor only, and do not generate any API. Synthetic
766  // oneofs must be ordered after all "real" oneofs.
767  //
768  // For message fields, proto3_optional doesn't create any semantic change,
769  // since non-repeated message fields always track presence. However it still
770  // indicates the semantic detail of whether the user wrote "optional" or not.
771  // This can be useful for round-tripping the .proto file. For consistency we
772  // give message fields a synthetic oneof also, even though it is not required
773  // to track presence. This is especially important because the parser can't
774  // tell if a field is a message or an enum, so it must always create a
775  // synthetic oneof.
776  //
777  // Proto2 optional fields do not set this flag, because they already indicate
778  // optional with `LABEL_OPTIONAL`.
779  optional bool proto3_optional = 17;
780
781  optional FieldOptions options = 8;
782
783  // If set, gives the index of a oneof in the containing type's oneof_decl
784  // list.  This field is a member of that oneof.
785  optional int32 oneof_index = 9;
786
787  optional int32 number = 3;
788
789  optional string name = 1;
790
791  optional Label label = 4;
792
793  // JSON name of this field. The value is set by protocol compiler. If the
794  // user has set a "json_name" option on this field, that option's value
795  // will be used. Otherwise, it's deduced from the field's name by converting
796  // it to camelCase.
797  optional string json_name = 10;
798
799  // For extensions, this is the name of the type being extended.  It is
800  // resolved in the same manner as type_name.
801  optional string extendee = 2;
802
803  // For numeric types, contains the original text representation of the value.
804  // For booleans, "true" or "false".
805  // For strings, contains the default text contents (not escaped in any way).
806  // For bytes, contains the C escaped value.  All bytes >= 128 are escaped.
807  // TODO(kenton):  Base-64 encode?
808  optional string default_value = 7;
809}
810
811message ExtensionRangeOptions {
812  extensions 1000 to max;
813
814  // The parser stores options it doesn't recognize here. See above.
815  repeated UninterpretedOption uninterpreted_option = 999;
816}
817
818message EnumValueOptions {
819  extensions 1000 to max;
820
821  // The parser stores options it doesn't recognize here. See above.
822  repeated UninterpretedOption uninterpreted_option = 999;
823
824  // Is this enum value deprecated?
825  // Depending on the target platform, this can emit Deprecated annotations
826  // for the enum value, or it will be completely ignored; in the very least,
827  // this is a formalization for deprecating enum values.
828  optional bool deprecated = 1 [default = false];
829}
830
831// Describes a value within an enum.
832message EnumValueDescriptorProto {
833  optional EnumValueOptions options = 3;
834
835  optional int32 number = 2;
836
837  optional string name = 1;
838}
839
840message EnumOptions {
841  reserved 5;
842
843  extensions 1000 to max;
844
845  // The parser stores options it doesn't recognize here. See above.
846  repeated UninterpretedOption uninterpreted_option = 999;
847
848  // Is this enum deprecated?
849  // Depending on the target platform, this can emit Deprecated annotations
850  // for the enum, or it will be completely ignored; in the very least, this
851  // is a formalization for deprecating enums.
852  optional bool deprecated = 3 [default = false];
853
854  // Set this option to true to allow mapping different tag names to the same
855  // value.
856  optional bool allow_alias = 2;
857}
858
859// Describes an enum type.
860message EnumDescriptorProto {
861  // Range of reserved numeric values. Reserved values may not be used by
862  // entries in the same enum. Reserved ranges may not overlap.
863  //
864  // Note that this is distinct from DescriptorProto.ReservedRange in that it
865  // is inclusive such that it can appropriately represent the entire int32
866  // domain.
867  message EnumReservedRange {
868    optional int32 start = 1; // Inclusive.
869
870    optional int32 end = 2; // Inclusive.
871  }
872
873  repeated EnumValueDescriptorProto value = 2;
874
875  // Range of reserved numeric values. Reserved numeric values may not be used
876  // by enum values in the same enum declaration. Reserved ranges may not
877  // overlap.
878  repeated EnumReservedRange reserved_range = 4;
879
880  // Reserved enum value names, which may not be reused. A given name may only
881  // be reserved once.
882  repeated string reserved_name = 5;
883
884  optional EnumOptions options = 3;
885
886  optional string name = 1;
887}
888
889// Describes a message type.
890message DescriptorProto {
891  // Range of reserved tag numbers. Reserved tag numbers may not be used by
892  // fields or extension ranges in the same message. Reserved ranges may
893  // not overlap.
894  message ReservedRange {
895    optional int32 start = 1; // Inclusive.
896
897    optional int32 end = 2; // Exclusive.
898  }
899
900  message ExtensionRange {
901    optional int32 start = 1; // Inclusive.
902
903    optional ExtensionRangeOptions options = 3;
904
905    optional int32 end = 2; // Exclusive.
906  }
907
908  repeated ReservedRange reserved_range = 9;
909
910  // Reserved field names, which may not be used by fields in the same message.
911  // A given name may only be reserved once.
912  repeated string reserved_name = 10;
913
914  optional MessageOptions options = 7;
915
916  repeated OneofDescriptorProto oneof_decl = 8;
917
918  repeated DescriptorProto nested_type = 3;
919
920  optional string name = 1;
921
922  repeated FieldDescriptorProto field = 2;
923
924  repeated ExtensionRange extension_range = 5;
925
926  repeated FieldDescriptorProto extension = 6;
927
928  repeated EnumDescriptorProto enum_type = 4;
929}
930
931// descriptor.proto must be optimized for speed because reflection-based
932// algorithms don't work during bootstrapping.
933option optimize_for = SPEED;
934
935option objc_class_prefix = "GPB";
936
937option java_package = "com.google.protobuf";
938
939option java_outer_classname = "DescriptorProtos";
940
941option go_package = "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor";
942
943option csharp_namespace = "Google.Protobuf.Reflection";
944
945option cc_enable_arenas = true;
946
947package google.protobuf;
948