1
1
// Protocol Buffers - Google's data interchange format
2
// Copyright 2008 Google Inc.
2
// Copyright 2008 Google Inc. All rights reserved.
3
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.
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are
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
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.
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.
17
31
// Author: kenton@google.com (Kenton Varda)
18
32
// Based on original Protocol Buffers design by
108
126
// in which it is nested. Otherwise, returns NULL.
109
127
const Descriptor* containing_type() const;
111
// Get options for this message type. These are specified in the .proto
112
// file by placing lines like "option foo = 1234;" in the message definition.
113
// The exact set of known options is defined by MessageOptions in
114
// google/protobuf/descriptor.proto.
129
// Get options for this message type. These are specified in the .proto file
130
// by placing lines like "option foo = 1234;" in the message definition.
131
// Allowed options are defined by MessageOptions in
132
// google/protobuf/descriptor.proto, and any available extensions of that
115
134
const MessageOptions& options() const;
117
136
// Write the contents of this Descriptor into the given DescriptorProto.
141
161
// The number of nested types in this message type.
142
162
int nested_type_count() const;
143
163
// Gets a nested type by index, where 0 <= index < nested_type_count().
164
// These are returned in the order they were defined in the .proto file.
144
165
const Descriptor* nested_type(int index) const;
146
167
// Looks up a nested type by name. Returns NULL if no such nested type
152
173
// The number of enum types in this message type.
153
174
int enum_type_count() const;
154
175
// Gets an enum type by index, where 0 <= index < enum_type_count().
176
// These are returned in the order they were defined in the .proto file.
155
177
const EnumDescriptor* enum_type(int index) const;
157
179
// Looks up an enum type by name. Returns NULL if no such enum type exists.
173
195
// The number of extension ranges in this message type.
174
196
int extension_range_count() const;
175
197
// Gets an extension range by index, where 0 <= index <
176
// extension_range_count().
198
// extension_range_count(). These are returned in the order they were defined
199
// in the .proto file.
177
200
const ExtensionRange* extension_range(int index) const;
179
202
// Returns true if the number is in one of the extension ranges.
183
206
// defined nested within this message type's scope.
184
207
int extension_count() const;
185
208
// Get an extension by index, where 0 <= index < extension_count().
209
// These are returned in the order they were defined in the .proto file.
186
210
const FieldDescriptor* extension(int index) const;
188
212
// Looks up a named extension (which extends some *other* message type)
227
253
// call Descriptor::FindExtensionByName() or
228
254
// FileDescriptor::FindExtensionByName().
229
255
// - Given a DescriptorPool, call DescriptorPool::FindExtensionByNumber().
230
// - Given a Message::Reflection for a message object, call
231
// Message::Reflection::FindKnownExtensionByName() or
232
// Message::Reflection::FindKnownExtensionByNumber().
256
// - Given a Reflection for a message object, call
257
// Reflection::FindKnownExtensionByName() or
258
// Reflection::FindKnownExtensionByNumber().
233
259
// Use DescriptorPool to construct your own descriptors.
234
260
class LIBPROTOBUF_EXPORT FieldDescriptor {
382
408
// Get the FieldOptions for this field. This includes things listed in
383
409
// square brackets after the field definition. E.g., the field:
384
410
// optional string text = 1 [ctype=CORD];
385
// has the "ctype" option set. FieldOptions is actually a protocol message,
386
// which makes it easier to extend.
411
// has the "ctype" option set. Allowed options are defined by FieldOptions
412
// in google/protobuf/descriptor.proto, and any available extensions of that
387
414
const FieldOptions& options() const;
389
416
// See Descriptor::CopyTo().
475
505
// Otherwise, NULL.
476
506
const Descriptor* containing_type() const;
478
// Get options for this enum type. These are specified in the .proto
479
// file by placing lines like "option foo = 1234;" in the enum definition.
480
// The exact set of known options is defined by EnumOptions in
481
// google/protobuf/descriptor.proto.
508
// Get options for this enum type. These are specified in the .proto file by
509
// placing lines like "option foo = 1234;" in the enum definition. Allowed
510
// options are defined by EnumOptions in google/protobuf/descriptor.proto,
511
// and any available extensions of that message.
482
512
const EnumOptions& options() const;
484
514
// See Descriptor::CopyTo().
529
561
// The type of this value. Never NULL.
530
562
const EnumDescriptor* type() const;
532
// Get options for this enum value. These are specified in the .proto
533
// file by adding text like "[foo = 1234]" after an enum value definition.
534
// The exact set of known options is defined by EnumValueOptions in
535
// google/protobuf/descriptor.proto.
564
// Get options for this enum value. These are specified in the .proto file
565
// by adding text like "[foo = 1234]" after an enum value definition.
566
// Allowed options are defined by EnumValueOptions in
567
// google/protobuf/descriptor.proto, and any available extensions of that
536
569
const EnumValueOptions& options() const;
538
571
// See Descriptor::CopyTo().
574
609
// The .proto file in which this service was defined. Never NULL.
575
610
const FileDescriptor* file() const;
577
// Get options for this service type. These are specified in the .proto
578
// file by placing lines like "option foo = 1234;" in the service definition.
579
// The exact set of known options is defined by ServiceOptions in
580
// google/protobuf/descriptor.proto.
612
// Get options for this service type. These are specified in the .proto file
613
// by placing lines like "option foo = 1234;" in the service definition.
614
// Allowed options are defined by ServiceOptions in
615
// google/protobuf/descriptor.proto, and any available extensions of that
581
617
const ServiceOptions& options() const;
583
619
// The number of methods this service defines.
584
620
int method_count() const;
585
621
// Gets a MethodDescriptor by index, where 0 <= index < method_count().
622
// These are returned in the order they were defined in the .proto file.
586
623
const MethodDescriptor* method(int index) const;
588
625
// Look up a MethodDescriptor by name.
634
673
// Gets the type of protocol message which this message produces as output.
635
674
const Descriptor* output_type() const;
637
// Get options for this method. These are specified in the .proto
638
// file by placing lines like "option foo = 1234;" in curly-braces after
639
// a method declaration. The exact set of known options is defined by
640
// MethodOptions in google/protobuf/descriptor.proto.
676
// Get options for this method. These are specified in the .proto file by
677
// placing lines like "option foo = 1234;" in curly-braces after a method
678
// declaration. Allowed options are defined by MethodOptions in
679
// google/protobuf/descriptor.proto, and any available extensions of that
641
681
const MethodOptions& options() const;
643
683
// See Descriptor::CopyTo().
683
725
// The number of files imported by this one.
684
726
int dependency_count() const;
685
727
// Gets an imported file by index, where 0 <= index < dependency_count().
728
// These are returned in the order they were defined in the .proto file.
686
729
const FileDescriptor* dependency(int index) const;
688
731
// Number of top-level message types defined in this file. (This does not
689
732
// include nested types.)
690
733
int message_type_count() const;
691
734
// Gets a top-level message type, where 0 <= index < message_type_count().
735
// These are returned in the order they were defined in the .proto file.
692
736
const Descriptor* message_type(int index) const;
694
738
// Number of top-level enum types defined in this file. (This does not
695
739
// include nested types.)
696
740
int enum_type_count() const;
697
741
// Gets a top-level enum type, where 0 <= index < enum_type_count().
742
// These are returned in the order they were defined in the .proto file.
698
743
const EnumDescriptor* enum_type(int index) const;
700
745
// Number of services defined in this file.
701
746
int service_count() const;
702
747
// Gets a service, where 0 <= index < service_count().
748
// These are returned in the order they were defined in the .proto file.
703
749
const ServiceDescriptor* service(int index) const;
705
751
// Number of extensions defined at file scope. (This does not include
706
752
// extensions nested within message types.)
707
753
int extension_count() const;
708
754
// Gets an extension's descriptor, where 0 <= index < extension_count().
755
// These are returned in the order they were defined in the .proto file.
709
756
const FieldDescriptor* extension(int index) const;
711
// Get options for this file. These are specified in the .proto
712
// file by placing lines like "option foo = 1234;" at the top level, outside
713
// of any other definitions. The exact set of known options is defined by
714
// FileOptions in google/protobuf/descriptor.proto.
758
// Get options for this file. These are specified in the .proto file by
759
// placing lines like "option foo = 1234;" at the top level, outside of any
760
// other definitions. Allowed options are defined by FileOptions in
761
// google/protobuf/descriptor.proto, and any available extensions of that
715
763
const FileOptions& options() const;
717
765
// Find a top-level message type by name. Returns NULL if not found.
868
918
DEFAULT_VALUE, // field default value
869
919
INPUT_TYPE, // method input type
870
920
OUTPUT_TYPE, // method output type
921
OPTION_NAME, // name in assignment
922
OPTION_VALUE, // value in option assignment
871
923
OTHER // some other problem
924
976
// underlay for a new DescriptorPool in which you add only the new file.
925
977
explicit DescriptorPool(const DescriptorPool* underlay);
927
// Called by generated classes at init time. Do NOT call this in your
979
// Called by generated classes at init time. Do NOT call this in your own
980
// code! descriptor_assigner, if not NULL, is used to assign global
981
// descriptor pointers at the appropriate point during building.
982
typedef void (*InternalDescriptorAssigner)(const FileDescriptor*);
929
983
const FileDescriptor* InternalBuildGeneratedFile(
930
const void* data, int size);
984
const void* data, int size, InternalDescriptorAssigner descriptor_assigner);
932
986
// For internal use only: Gets a non-const pointer to the generated pool.
933
987
// This is called at static-initialization time only, so thread-safety is