~ubuntu-branches/ubuntu/oneiric/protobuf/oneiric

« back to all changes in this revision

Viewing changes to src/google/protobuf/descriptor.proto

  • Committer: Bazaar Package Importer
  • Author(s): Iustin Pop
  • Date: 2008-08-03 11:01:44 UTC
  • Revision ID: james.westby@ubuntu.com-20080803110144-uyiw41bf1m2oe17t
Tags: upstream-2.0.0~b
ImportĀ upstreamĀ versionĀ 2.0.0~b

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Protocol Buffers - Google's data interchange format
 
2
// Copyright 2008 Google Inc.
 
3
// http://code.google.com/p/protobuf/
 
4
//
 
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
 
8
//
 
9
//      http://www.apache.org/licenses/LICENSE-2.0
 
10
//
 
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.
 
16
 
 
17
// Author: kenton@google.com (Kenton Varda)
 
18
//  Based on original Protocol Buffers design by
 
19
//  Sanjay Ghemawat, Jeff Dean, and others.
 
20
//
 
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).
 
24
 
 
25
 
 
26
 
 
27
package google.protobuf;
 
28
option java_package = "com.google.protobuf";
 
29
option java_outer_classname = "DescriptorProtos";
 
30
 
 
31
// descriptor.proto must be optimized for speed because reflection-based
 
32
// algorithms don't work during bootstrapping.
 
33
option optimize_for = SPEED;
 
34
 
 
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.
 
39
 
 
40
  // Names of files imported by this file.
 
41
  repeated string dependency = 3;
 
42
 
 
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;
 
48
 
 
49
  optional FileOptions options = 8;
 
50
}
 
51
 
 
52
// Describes a message type.
 
53
message DescriptorProto {
 
54
  optional string name = 1;
 
55
 
 
56
  repeated FieldDescriptorProto field = 2;
 
57
  repeated FieldDescriptorProto extension = 6;
 
58
 
 
59
  repeated DescriptorProto nested_type = 3;
 
60
  repeated EnumDescriptorProto enum_type = 4;
 
61
 
 
62
  message ExtensionRange {
 
63
    optional int32 start = 1;
 
64
    optional int32 end = 2;
 
65
  }
 
66
  repeated ExtensionRange extension_range = 5;
 
67
 
 
68
  optional MessageOptions options = 7;
 
69
}
 
70
 
 
71
// Describes a field within a message.
 
72
message FieldDescriptorProto {
 
73
  enum Type {
 
74
    // 0 is reserved for errors.
 
75
    // Order is weird for historical reasons.
 
76
    TYPE_DOUBLE         = 1;
 
77
    TYPE_FLOAT          = 2;
 
78
    TYPE_INT64          = 3;   // Not ZigZag encoded.  Negative numbers
 
79
                               // take 10 bytes.  Use TYPE_SINT64 if negative
 
80
                               // values are likely.
 
81
    TYPE_UINT64         = 4;
 
82
    TYPE_INT32          = 5;   // Not ZigZag encoded.  Negative numbers
 
83
                               // take 10 bytes.  Use TYPE_SINT32 if negative
 
84
                               // values are likely.
 
85
    TYPE_FIXED64        = 6;
 
86
    TYPE_FIXED32        = 7;
 
87
    TYPE_BOOL           = 8;
 
88
    TYPE_STRING         = 9;
 
89
    TYPE_GROUP          = 10;  // Tag-delimited aggregate.
 
90
    TYPE_MESSAGE        = 11;  // Length-delimited aggregate.
 
91
 
 
92
    // New in version 2.
 
93
    TYPE_BYTES          = 12;
 
94
    TYPE_UINT32         = 13;
 
95
    TYPE_ENUM           = 14;
 
96
    TYPE_SFIXED32       = 15;
 
97
    TYPE_SFIXED64       = 16;
 
98
    TYPE_SINT32         = 17;  // Uses ZigZag encoding.
 
99
    TYPE_SINT64         = 18;  // Uses ZigZag encoding.
 
100
  };
 
101
 
 
102
  enum Label {
 
103
    // 0 is reserved for errors
 
104
    LABEL_OPTIONAL      = 1;
 
105
    LABEL_REQUIRED      = 2;
 
106
    LABEL_REPEATED      = 3;
 
107
    // TODO(sanjay): Should we add LABEL_MAP?
 
108
  };
 
109
 
 
110
  optional string name = 1;
 
111
  optional int32 number = 3;
 
112
  optional Label label = 4;
 
113
 
 
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;
 
117
 
 
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
 
122
  // namespace).
 
123
  optional string type_name = 6;
 
124
 
 
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;
 
128
 
 
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;
 
135
 
 
136
  optional FieldOptions options = 8;
 
137
}
 
138
 
 
139
// Describes an enum type.
 
140
message EnumDescriptorProto {
 
141
  optional string name = 1;
 
142
 
 
143
  repeated EnumValueDescriptorProto value = 2;
 
144
 
 
145
  optional EnumOptions options = 3;
 
146
}
 
147
 
 
148
// Describes a value within an enum.
 
149
message EnumValueDescriptorProto {
 
150
  optional string name = 1;
 
151
  optional int32 number = 2;
 
152
 
 
153
  optional EnumValueOptions options = 3;
 
154
}
 
155
 
 
156
// Describes a service.
 
157
message ServiceDescriptorProto {
 
158
  optional string name = 1;
 
159
  repeated MethodDescriptorProto method = 2;
 
160
 
 
161
  optional ServiceOptions options = 3;
 
162
}
 
163
 
 
164
// Describes a method of a service.
 
165
message MethodDescriptorProto {
 
166
  optional string name = 1;
 
167
 
 
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;
 
172
 
 
173
  optional MethodOptions options = 4;
 
174
}
 
175
 
 
176
// ===================================================================
 
177
// Options
 
178
 
 
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.
 
182
 
 
183
// TODO(kenton):  Allow extensions to options.
 
184
 
 
185
message FileOptions {
 
186
 
 
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
 
190
  // domain names.
 
191
  optional string java_package = 1;
 
192
 
 
193
 
 
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;
 
200
 
 
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];
 
208
 
 
209
  // Generated classes can be optimized for speed or code size.
 
210
  enum OptimizeMode {
 
211
    SPEED = 1;      // Generate complete code for parsing, serialization, etc.
 
212
    CODE_SIZE = 2;  // Use ReflectionOps to implement these methods.
 
213
  }
 
214
  optional OptimizeMode optimize_for = 9 [default=CODE_SIZE];
 
215
}
 
216
 
 
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.
 
222
  //
 
223
  // The message must be defined exactly as follows:
 
224
  //   message Foo {
 
225
  //     option message_set_wire_format = true;
 
226
  //     extensions 4 to max;
 
227
  //   }
 
228
  // Note that the message cannot have any defined fields; MessageSets only
 
229
  // have extensions.
 
230
  //
 
231
  // All extensions of your type must be singular messages; e.g. they cannot
 
232
  // be int32s, enums, or repeated messages.
 
233
  //
 
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];
 
237
}
 
238
 
 
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;
 
245
  enum CType {
 
246
    CORD = 1;
 
247
 
 
248
    STRING_PIECE = 2;
 
249
  }
 
250
 
 
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:
 
254
  //   message Item {
 
255
  //     required string name = 1;
 
256
  //     required string value = 2;
 
257
  //   }
 
258
  //   message Config {
 
259
  //     repeated Item items = 1 [experimental_map_key="name"];
 
260
  //   }
 
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;
 
264
}
 
265
 
 
266
message EnumOptions {
 
267
}
 
268
 
 
269
message EnumValueOptions {
 
270
}
 
271
 
 
272
message ServiceOptions {
 
273
 
 
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
 
277
  //   Buffers.
 
278
}
 
279
 
 
280
message MethodOptions {
 
281
 
 
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
 
285
  //   Buffers.
 
286
}