1
// Protocol Buffers - Google's data interchange format
2
// Copyright 2008 Google Inc.
3
// http://code.google.com/p/protobuf/
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
9
// http://www.apache.org/licenses/LICENSE-2.0
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
17
// Author: kenton@google.com (Kenton Varda)
18
// Based on original Protocol Buffers design by
19
// Sanjay Ghemawat, Jeff Dean, and others.
21
// The messages in this file describe the definitions found in .proto files.
22
// A valid .proto file can be translated directly to a FileDescriptorProto
23
// without any other information (e.g. without reading its imports).
27
package google.protobuf;
28
option java_package = "com.google.protobuf";
29
option java_outer_classname = "DescriptorProtos";
31
// descriptor.proto must be optimized for speed because reflection-based
32
// algorithms don't work during bootstrapping.
33
option optimize_for = SPEED;
35
// Describes a complete .proto file.
36
message FileDescriptorProto {
37
optional string name = 1; // file name, relative to root of source tree
38
optional string package = 2; // e.g. "foo", "foo.bar", etc.
40
// Names of files imported by this file.
41
repeated string dependency = 3;
43
// All top-level definitions in this file.
44
repeated DescriptorProto message_type = 4;
45
repeated EnumDescriptorProto enum_type = 5;
46
repeated ServiceDescriptorProto service = 6;
47
repeated FieldDescriptorProto extension = 7;
49
optional FileOptions options = 8;
52
// Describes a message type.
53
message DescriptorProto {
54
optional string name = 1;
56
repeated FieldDescriptorProto field = 2;
57
repeated FieldDescriptorProto extension = 6;
59
repeated DescriptorProto nested_type = 3;
60
repeated EnumDescriptorProto enum_type = 4;
62
message ExtensionRange {
63
optional int32 start = 1;
64
optional int32 end = 2;
66
repeated ExtensionRange extension_range = 5;
68
optional MessageOptions options = 7;
71
// Describes a field within a message.
72
message FieldDescriptorProto {
74
// 0 is reserved for errors.
75
// Order is weird for historical reasons.
78
TYPE_INT64 = 3; // Not ZigZag encoded. Negative numbers
79
// take 10 bytes. Use TYPE_SINT64 if negative
82
TYPE_INT32 = 5; // Not ZigZag encoded. Negative numbers
83
// take 10 bytes. Use TYPE_SINT32 if negative
89
TYPE_GROUP = 10; // Tag-delimited aggregate.
90
TYPE_MESSAGE = 11; // Length-delimited aggregate.
98
TYPE_SINT32 = 17; // Uses ZigZag encoding.
99
TYPE_SINT64 = 18; // Uses ZigZag encoding.
103
// 0 is reserved for errors
107
// TODO(sanjay): Should we add LABEL_MAP?
110
optional string name = 1;
111
optional int32 number = 3;
112
optional Label label = 4;
114
// If type_name is set, this need not be set. If both this and type_name
115
// are set, this must be either TYPE_ENUM or TYPE_MESSAGE.
116
optional Type type = 5;
118
// For message and enum types, this is the name of the type. If the name
119
// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
120
// rules are used to find the type (i.e. first the nested types within this
121
// message are searched, then within the parent, on up to the root
123
optional string type_name = 6;
125
// For extensions, this is the name of the type being extended. It is
126
// resolved in the same manner as type_name.
127
optional string extendee = 2;
129
// For numeric types, contains the original text representation of the value.
130
// For booleans, "true" or "false".
131
// For strings, contains the default text contents (not escaped in any way).
132
// For bytes, contains the C escaped value. All bytes >= 128 are escaped.
133
// TODO(kenton): Base-64 encode?
134
optional string default_value = 7;
136
optional FieldOptions options = 8;
139
// Describes an enum type.
140
message EnumDescriptorProto {
141
optional string name = 1;
143
repeated EnumValueDescriptorProto value = 2;
145
optional EnumOptions options = 3;
148
// Describes a value within an enum.
149
message EnumValueDescriptorProto {
150
optional string name = 1;
151
optional int32 number = 2;
153
optional EnumValueOptions options = 3;
156
// Describes a service.
157
message ServiceDescriptorProto {
158
optional string name = 1;
159
repeated MethodDescriptorProto method = 2;
161
optional ServiceOptions options = 3;
164
// Describes a method of a service.
165
message MethodDescriptorProto {
166
optional string name = 1;
168
// Input and output type names. These are resolved in the same way as
169
// FieldDescriptorProto.type_name, but must refer to a message type.
170
optional string input_type = 2;
171
optional string output_type = 3;
173
optional MethodOptions options = 4;
176
// ===================================================================
179
// Each of the definitions above may have "options" attached. These are
180
// just annotations which may cause code to be generated slightly differently
181
// or may contain hints for code that manipulates protocol messages.
183
// TODO(kenton): Allow extensions to options.
185
message FileOptions {
187
// Sets the Java package where classes generated from this .proto will be
188
// placed. By default, the proto package is used, but this is often
189
// inappropriate because proto packages do not normally start with backwards
191
optional string java_package = 1;
194
// If set, all the classes from the .proto file are wrapped in a single
195
// outer class with the given name. This applies to both Proto1
196
// (equivalent to the old "--one_java_file" option) and Proto2 (where
197
// a .proto always translates to a single class, but you may want to
198
// explicitly choose the class name).
199
optional string java_outer_classname = 8;
201
// If set true, then the Java code generator will generate a separate .java
202
// file for each top-level message, enum, and service defined in the .proto
203
// file. Thus, these types will *not* be nested inside the outer class
204
// named by java_outer_classname. However, the outer class will still be
205
// generated to contain the file's getDescriptor() method as well as any
206
// top-level extensions defined in the file.
207
optional bool java_multiple_files = 10 [default=false];
209
// Generated classes can be optimized for speed or code size.
211
SPEED = 1; // Generate complete code for parsing, serialization, etc.
212
CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
214
optional OptimizeMode optimize_for = 9 [default=CODE_SIZE];
217
message MessageOptions {
218
// Set true to use the old proto1 MessageSet wire format for extensions.
219
// This is provided for backwards-compatibility with the MessageSet wire
220
// format. You should not use this for any other reason: It's less
221
// efficient, has fewer features, and is more complicated.
223
// The message must be defined exactly as follows:
225
// option message_set_wire_format = true;
226
// extensions 4 to max;
228
// Note that the message cannot have any defined fields; MessageSets only
231
// All extensions of your type must be singular messages; e.g. they cannot
232
// be int32s, enums, or repeated messages.
234
// Because this is an option, the above two restrictions are not enforced by
235
// the protocol compiler.
236
optional bool message_set_wire_format = 1 [default=false];
239
message FieldOptions {
240
// The ctype option instructs the C++ code generator to use a different
241
// representation of the field than it normally would. See the specific
242
// options below. This option is not yet implemented in the open source
243
// release -- sorry, we'll try to include it in a future version!
244
optional CType ctype = 1;
251
// EXPERIMENTAL. DO NOT USE.
252
// For "map" fields, the name of the field in the enclosed type that
253
// is the key for this map. For example, suppose we have:
255
// required string name = 1;
256
// required string value = 2;
259
// repeated Item items = 1 [experimental_map_key="name"];
261
// In this situation, the map key for Item will be set to "name".
262
// TODO: Fully-implement this, then remove the "experimental_" prefix.
263
optional string experimental_map_key = 9;
266
message EnumOptions {
269
message EnumValueOptions {
272
message ServiceOptions {
274
// Note: Field numbers 1 through 32 are reserved for Google's internal RPC
275
// framework. We apologize for hoarding these numbers to ourselves, but
276
// we were already using them long before we decided to release Protocol
280
message MethodOptions {
282
// Note: Field numbers 1 through 32 are reserved for Google's internal RPC
283
// framework. We apologize for hoarding these numbers to ourselves, but
284
// we were already using them long before we decided to release Protocol