~ubuntu-branches/debian/squeeze/protobuf/squeeze

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Julien Cristau
  • Date: 2009-06-02 16:19:00 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090602161900-vm176i3ryt35yk91
Tags: 2.0.3-2.2
* Non-maintainer upload.
* Fix FTBFS from -2.1: don't fail when we can't clean up the java build,
  such as when openjdk isn't installed.
* Disable parallel builds, because libtool is made of fail (if binary-arch
  and build-indep run concurrently, we relink a library while it's being
  used; that doesn't work so well).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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/
4
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.
 
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.
16
30
 
17
31
// Author: kenton@google.com (Kenton Varda)
18
32
//  Based on original Protocol Buffers design by
73
87
class ServiceOptions;
74
88
class MethodOptions;
75
89
class FileOptions;
 
90
class UninterpretedOption;
76
91
 
77
92
// Defined in message.h
78
93
class Message;
80
95
// Defined in descriptor.cc
81
96
class DescriptorBuilder;
82
97
 
 
98
// Defined in unknown_field_set.h.
 
99
class UnknownField;
 
100
 
83
101
// Describes a type of protocol message, or a particular group within a
84
102
// message.  To obtain the Descriptor for a given message object, call
85
103
// Message::GetDescriptor().  Generated message classes also have a
108
126
  // in which it is nested.  Otherwise, returns NULL.
109
127
  const Descriptor* containing_type() const;
110
128
 
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
 
133
  // message.
115
134
  const MessageOptions& options() const;
116
135
 
117
136
  // Write the contents of this Descriptor into the given DescriptorProto.
128
147
  // The number of fields in this message type.
129
148
  int field_count() const;
130
149
  // Gets a field by index, where 0 <= index < field_count().
 
150
  // These are returned in the order they were defined in the .proto file.
131
151
  const FieldDescriptor* field(int index) const;
132
152
 
133
153
  // Looks up a field by declared tag number.  Returns NULL if no such field
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;
145
166
 
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;
156
178
 
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;
178
201
 
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;
187
211
 
188
212
  // Looks up a named extension (which extends some *other* message type)
190
214
  const FieldDescriptor* FindExtensionByName(const string& name) const;
191
215
 
192
216
 private:
 
217
  typedef MessageOptions OptionsType;
 
218
 
193
219
  // Internal version of DebugString; controls the level of indenting for
194
220
  // correct depth
195
221
  void DebugString(int depth, string *contents) const;
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 {
235
261
 public:
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
 
413
  // message.
387
414
  const FieldOptions& options() const;
388
415
 
389
416
  // See Descriptor::CopyTo().
392
419
  // See Descriptor::DebugString().
393
420
  string DebugString() const;
394
421
 private:
 
422
  typedef FieldOptions OptionsType;
 
423
 
395
424
  // See Descriptor::DebugString().
396
425
  void DebugString(int depth, string *contents) const;
397
426
 
463
492
  // than zero.
464
493
  int value_count() const;
465
494
  // Gets a value by index, where 0 <= index < value_count().
 
495
  // These are returned in the order they were defined in the .proto file.
466
496
  const EnumValueDescriptor* value(int index) const;
467
497
 
468
498
  // Looks up a value by name.  Returns NULL if no such value exists.
475
505
  // Otherwise, NULL.
476
506
  const Descriptor* containing_type() const;
477
507
 
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;
483
513
 
484
514
  // See Descriptor::CopyTo().
488
518
  string DebugString() const;
489
519
 
490
520
 private:
 
521
  typedef EnumOptions OptionsType;
 
522
 
491
523
  // See Descriptor::DebugString().
492
524
  void DebugString(int depth, string *contents) const;
493
525
 
529
561
  // The type of this value.  Never NULL.
530
562
  const EnumDescriptor* type() const;
531
563
 
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
 
568
  // message.
536
569
  const EnumValueOptions& options() const;
537
570
 
538
571
  // See Descriptor::CopyTo().
542
575
  string DebugString() const;
543
576
 
544
577
 private:
 
578
  typedef EnumValueOptions OptionsType;
 
579
 
545
580
  // See Descriptor::DebugString().
546
581
  void DebugString(int depth, string *contents) const;
547
582
 
574
609
  // The .proto file in which this service was defined.  Never NULL.
575
610
  const FileDescriptor* file() const;
576
611
 
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
 
616
  // message.
581
617
  const ServiceOptions& options() const;
582
618
 
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;
587
624
 
588
625
  // Look up a MethodDescriptor by name.
595
632
  string DebugString() const;
596
633
 
597
634
 private:
 
635
  typedef ServiceOptions OptionsType;
 
636
 
598
637
  // See Descriptor::DebugString().
599
638
  void DebugString(string *contents) const;
600
639
 
634
673
  // Gets the type of protocol message which this message produces as output.
635
674
  const Descriptor* output_type() const;
636
675
 
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
 
680
  // message.
641
681
  const MethodOptions& options() const;
642
682
 
643
683
  // See Descriptor::CopyTo().
647
687
  string DebugString() const;
648
688
 
649
689
 private:
 
690
  typedef MethodOptions OptionsType;
 
691
 
650
692
  // See Descriptor::DebugString().
651
693
  void DebugString(int depth, string *contents) const;
652
694
 
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;
687
730
 
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;
693
737
 
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;
699
744
 
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;
704
750
 
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;
710
757
 
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
 
762
  // message.
715
763
  const FileOptions& options() const;
716
764
 
717
765
  // Find a top-level message type by name.  Returns NULL if not found.
733
781
  string DebugString() const;
734
782
 
735
783
 private:
 
784
  typedef FileOptions OptionsType;
 
785
 
736
786
  const string* name_;
737
787
  const string* package_;
738
788
  const DescriptorPool* pool_;
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
872
924
    };
873
925
 
924
976
  // underlay for a new DescriptorPool in which you add only the new file.
925
977
  explicit DescriptorPool(const DescriptorPool* underlay);
926
978
 
927
 
  // Called by generated classes at init time.  Do NOT call this in your
928
 
  // own code!
 
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);
931
985
 
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