~ubuntu-branches/debian/sid/protobuf/sid

« back to all changes in this revision

Viewing changes to src/google/protobuf/generated_message_reflection.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
30
44
#include <google/protobuf/unknown_field_set.h>
31
45
 
32
46
 
33
 
// Generated code needs this to have been forward-declared.  Easier to do it
34
 
// here than to print it inside every .pb.h file.
35
47
namespace google {
36
 
namespace protobuf { class EnumDescriptor; }
 
48
namespace protobuf {
 
49
  class DescriptorPool;
 
50
  // Generated code needs these to have been forward-declared.  Easier to do it
 
51
  // here than to print them inside every .pb.h file.
 
52
  class FileDescriptor;
 
53
  class EnumDescriptor;
 
54
}
37
55
 
38
56
namespace protobuf {
39
57
namespace internal {
48
66
// by generated code.  This class is just a big hack that reduces code
49
67
// size.
50
68
//
51
 
// A GeneratedMessageReflection is an implementation of Message::Reflection
 
69
// A GeneratedMessageReflection is an implementation of Reflection
52
70
// which expects all fields to be backed by simple variables located in
53
71
// memory.  The locations are given using a base pointer and a set of
54
72
// offsets.
68
86
//    of whatever type the individual field would be.  Strings and
69
87
//    Messages use RepeatedPtrFields while everything else uses
70
88
//    RepeatedFields.
71
 
class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Message::Reflection {
 
89
class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
72
90
 public:
73
91
  // Constructs a GeneratedMessageReflection.
74
92
  // Parameters:
75
93
  //   descriptor:    The descriptor for the message type being implemented.
76
 
  //   base:          Pointer to the location where the message object is
77
 
  //                  stored.
78
 
  //   default_base:  Pointer to the location where the message's default
79
 
  //                  instance is stored.  This is only used to obtain
80
 
  //                  pointers to default instances of embedded messages,
81
 
  //                  which GetMessage() will return if the particular sub-
82
 
  //                  message has not been initialized yet.  (Thus, all
 
94
  //   default_instance:  The default instance of the message.  This is only
 
95
  //                  used to obtain pointers to default instances of embedded
 
96
  //                  messages, which GetMessage() will return if the particular
 
97
  //                  sub-message has not been initialized yet.  (Thus, all
83
98
  //                  embedded message fields *must* have non-NULL pointers
84
99
  //                  in the default instance.)
85
 
  //   offsets:       An array of bits giving the byte offsets, relative to
86
 
  //                  "base" and "default_base", of each field.  These can
 
100
  //   offsets:       An array of ints giving the byte offsets, relative to
 
101
  //                  the start of the message object, of each field.  These can
87
102
  //                  be computed at compile time using the
88
103
  //                  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro, defined
89
104
  //                  below.
90
 
  //   has_bits:      An array of uint32s of size descriptor->field_count()/32,
91
 
  //                  rounded up.  This is a bitfield where each bit indicates
92
 
  //                  whether or not the corresponding field of the message
93
 
  //                  has been initialized.  The bit for field index i is
94
 
  //                  obtained by the expression:
 
105
  //   has_bits_offset:  Offset in the message of an array of uint32s of size
 
106
  //                  descriptor->field_count()/32, rounded up.  This is a
 
107
  //                  bitfield where each bit indicates whether or not the
 
108
  //                  corresponding field of the message has been initialized.
 
109
  //                  The bit for field index i is obtained by the expression:
95
110
  //                    has_bits[i / 32] & (1 << (i % 32))
96
 
  //   extensions:    The ExtensionSet for this message, or NULL if the
97
 
  //                  message type has no extension ranges.
 
111
  //   unknown_fields_offset:  Offset in the message of the UnknownFieldSet for
 
112
  //                  the message.
 
113
  //   extensions_offset:  Offset in the message of the ExtensionSet for the
 
114
  //                  message, or -1 if the message type has no extension
 
115
  //                  ranges.
 
116
  //   pool:          DescriptorPool to search for extension definitions.  Only
 
117
  //                  used by FindKnownExtensionByName() and
 
118
  //                  FindKnownExtensionByNumber().
 
119
  //   object_size:   The size of a message object of this type, as measured
 
120
  //                  by sizeof().
98
121
  GeneratedMessageReflection(const Descriptor* descriptor,
99
 
                             void* base, const void* default_base,
100
 
                             const int offsets[], uint32 has_bits[],
101
 
                             ExtensionSet* extensions);
 
122
                             const Message* default_instance,
 
123
                             const int offsets[],
 
124
                             int has_bits_offset,
 
125
                             int unknown_fields_offset,
 
126
                             int extensions_offset,
 
127
                             const DescriptorPool* pool,
 
128
                             int object_size);
102
129
  ~GeneratedMessageReflection();
103
130
 
104
 
  inline const UnknownFieldSet& unknown_fields() const {
105
 
    return unknown_fields_;
106
 
  }
107
 
  inline UnknownFieldSet* mutable_unknown_fields() {
108
 
    return &unknown_fields_;
109
 
  }
110
 
 
111
 
  // implements Message::Reflection ----------------------------------
112
 
 
113
 
  const UnknownFieldSet& GetUnknownFields() const;
114
 
  UnknownFieldSet* MutableUnknownFields();
115
 
 
116
 
  bool HasField(const FieldDescriptor* field) const;
117
 
  int FieldSize(const FieldDescriptor* field) const;
118
 
  void ClearField(const FieldDescriptor* field);
119
 
  void ListFields(vector<const FieldDescriptor*>* output) const;
120
 
 
121
 
  int32  GetInt32 (const FieldDescriptor* field) const;
122
 
  int64  GetInt64 (const FieldDescriptor* field) const;
123
 
  uint32 GetUInt32(const FieldDescriptor* field) const;
124
 
  uint64 GetUInt64(const FieldDescriptor* field) const;
125
 
  float  GetFloat (const FieldDescriptor* field) const;
126
 
  double GetDouble(const FieldDescriptor* field) const;
127
 
  bool   GetBool  (const FieldDescriptor* field) const;
128
 
  string GetString(const FieldDescriptor* field) const;
129
 
  const string& GetStringReference(const FieldDescriptor* field,
 
131
  // implements Reflection -------------------------------------------
 
132
 
 
133
  const UnknownFieldSet& GetUnknownFields(const Message& message) const;
 
134
  UnknownFieldSet* MutableUnknownFields(Message* message) const;
 
135
 
 
136
  int SpaceUsed(const Message& message) const;
 
137
 
 
138
  bool HasField(const Message& message, const FieldDescriptor* field) const;
 
139
  int FieldSize(const Message& message, const FieldDescriptor* field) const;
 
140
  void ClearField(Message* message, const FieldDescriptor* field) const;
 
141
  void ListFields(const Message& message,
 
142
                  vector<const FieldDescriptor*>* output) const;
 
143
 
 
144
  int32  GetInt32 (const Message& message,
 
145
                   const FieldDescriptor* field) const;
 
146
  int64  GetInt64 (const Message& message,
 
147
                   const FieldDescriptor* field) const;
 
148
  uint32 GetUInt32(const Message& message,
 
149
                   const FieldDescriptor* field) const;
 
150
  uint64 GetUInt64(const Message& message,
 
151
                   const FieldDescriptor* field) const;
 
152
  float  GetFloat (const Message& message,
 
153
                   const FieldDescriptor* field) const;
 
154
  double GetDouble(const Message& message,
 
155
                   const FieldDescriptor* field) const;
 
156
  bool   GetBool  (const Message& message,
 
157
                   const FieldDescriptor* field) const;
 
158
  string GetString(const Message& message,
 
159
                   const FieldDescriptor* field) const;
 
160
  const string& GetStringReference(const Message& message,
 
161
                                   const FieldDescriptor* field,
130
162
                                   string* scratch) const;
131
 
  const EnumValueDescriptor* GetEnum(const FieldDescriptor* field) const;
132
 
  const Message& GetMessage(const FieldDescriptor* field) const;
133
 
 
134
 
  void SetInt32 (const FieldDescriptor* field, int32  value);
135
 
  void SetInt64 (const FieldDescriptor* field, int64  value);
136
 
  void SetUInt32(const FieldDescriptor* field, uint32 value);
137
 
  void SetUInt64(const FieldDescriptor* field, uint64 value);
138
 
  void SetFloat (const FieldDescriptor* field, float  value);
139
 
  void SetDouble(const FieldDescriptor* field, double value);
140
 
  void SetBool  (const FieldDescriptor* field, bool   value);
141
 
  void SetString(const FieldDescriptor* field,
142
 
                 const string& value);
143
 
  void SetEnum  (const FieldDescriptor* field,
144
 
                 const EnumValueDescriptor* value);
145
 
  Message* MutableMessage(const FieldDescriptor* field);
146
 
 
147
 
  int32  GetRepeatedInt32 (const FieldDescriptor* field, int index) const;
148
 
  int64  GetRepeatedInt64 (const FieldDescriptor* field, int index) const;
149
 
  uint32 GetRepeatedUInt32(const FieldDescriptor* field, int index) const;
150
 
  uint64 GetRepeatedUInt64(const FieldDescriptor* field, int index) const;
151
 
  float  GetRepeatedFloat (const FieldDescriptor* field, int index) const;
152
 
  double GetRepeatedDouble(const FieldDescriptor* field, int index) const;
153
 
  bool   GetRepeatedBool  (const FieldDescriptor* field, int index) const;
154
 
  string GetRepeatedString(const FieldDescriptor* field, int index) const;
155
 
  const string& GetRepeatedStringReference(const FieldDescriptor* field,
 
163
  const EnumValueDescriptor* GetEnum(const Message& message,
 
164
                                     const FieldDescriptor* field) const;
 
165
  const Message& GetMessage(const Message& message,
 
166
                            const FieldDescriptor* field) const;
 
167
 
 
168
  void SetInt32 (Message* message,
 
169
                 const FieldDescriptor* field, int32  value) const;
 
170
  void SetInt64 (Message* message,
 
171
                 const FieldDescriptor* field, int64  value) const;
 
172
  void SetUInt32(Message* message,
 
173
                 const FieldDescriptor* field, uint32 value) const;
 
174
  void SetUInt64(Message* message,
 
175
                 const FieldDescriptor* field, uint64 value) const;
 
176
  void SetFloat (Message* message,
 
177
                 const FieldDescriptor* field, float  value) const;
 
178
  void SetDouble(Message* message,
 
179
                 const FieldDescriptor* field, double value) const;
 
180
  void SetBool  (Message* message,
 
181
                 const FieldDescriptor* field, bool   value) const;
 
182
  void SetString(Message* message,
 
183
                 const FieldDescriptor* field,
 
184
                 const string& value) const;
 
185
  void SetEnum  (Message* message, const FieldDescriptor* field,
 
186
                 const EnumValueDescriptor* value) const;
 
187
  Message* MutableMessage(Message* message, const FieldDescriptor* field) const;
 
188
 
 
189
  int32  GetRepeatedInt32 (const Message& message,
 
190
                           const FieldDescriptor* field, int index) const;
 
191
  int64  GetRepeatedInt64 (const Message& message,
 
192
                           const FieldDescriptor* field, int index) const;
 
193
  uint32 GetRepeatedUInt32(const Message& message,
 
194
                           const FieldDescriptor* field, int index) const;
 
195
  uint64 GetRepeatedUInt64(const Message& message,
 
196
                           const FieldDescriptor* field, int index) const;
 
197
  float  GetRepeatedFloat (const Message& message,
 
198
                           const FieldDescriptor* field, int index) const;
 
199
  double GetRepeatedDouble(const Message& message,
 
200
                           const FieldDescriptor* field, int index) const;
 
201
  bool   GetRepeatedBool  (const Message& message,
 
202
                           const FieldDescriptor* field, int index) const;
 
203
  string GetRepeatedString(const Message& message,
 
204
                           const FieldDescriptor* field, int index) const;
 
205
  const string& GetRepeatedStringReference(const Message& message,
 
206
                                           const FieldDescriptor* field,
156
207
                                           int index, string* scratch) const;
157
 
  const EnumValueDescriptor* GetRepeatedEnum(const FieldDescriptor* field,
 
208
  const EnumValueDescriptor* GetRepeatedEnum(const Message& message,
 
209
                                             const FieldDescriptor* field,
158
210
                                             int index) const;
159
 
  const Message& GetRepeatedMessage(const FieldDescriptor* field,
 
211
  const Message& GetRepeatedMessage(const Message& message,
 
212
                                    const FieldDescriptor* field,
160
213
                                    int index) const;
161
214
 
162
215
  // Set the value of a field.
163
 
  void SetRepeatedInt32 (const FieldDescriptor* field, int index, int32  value);
164
 
  void SetRepeatedInt64 (const FieldDescriptor* field, int index, int64  value);
165
 
  void SetRepeatedUInt32(const FieldDescriptor* field, int index, uint32 value);
166
 
  void SetRepeatedUInt64(const FieldDescriptor* field, int index, uint64 value);
167
 
  void SetRepeatedFloat (const FieldDescriptor* field, int index, float  value);
168
 
  void SetRepeatedDouble(const FieldDescriptor* field, int index, double value);
169
 
  void SetRepeatedBool  (const FieldDescriptor* field, int index, bool   value);
170
 
  void SetRepeatedString(const FieldDescriptor* field, int index,
171
 
                         const string& value);
172
 
  void SetRepeatedEnum  (const FieldDescriptor* field, int index,
173
 
                         const EnumValueDescriptor* value);
 
216
  void SetRepeatedInt32 (Message* message,
 
217
                         const FieldDescriptor* field, int index, int32  value) const;
 
218
  void SetRepeatedInt64 (Message* message,
 
219
                         const FieldDescriptor* field, int index, int64  value) const;
 
220
  void SetRepeatedUInt32(Message* message,
 
221
                         const FieldDescriptor* field, int index, uint32 value) const;
 
222
  void SetRepeatedUInt64(Message* message,
 
223
                         const FieldDescriptor* field, int index, uint64 value) const;
 
224
  void SetRepeatedFloat (Message* message,
 
225
                         const FieldDescriptor* field, int index, float  value) const;
 
226
  void SetRepeatedDouble(Message* message,
 
227
                         const FieldDescriptor* field, int index, double value) const;
 
228
  void SetRepeatedBool  (Message* message,
 
229
                         const FieldDescriptor* field, int index, bool   value) const;
 
230
  void SetRepeatedString(Message* message,
 
231
                         const FieldDescriptor* field, int index,
 
232
                         const string& value) const;
 
233
  void SetRepeatedEnum(Message* message, const FieldDescriptor* field,
 
234
                       int index, const EnumValueDescriptor* value) const;
174
235
  // Get a mutable pointer to a field with a message type.
175
 
  Message* MutableRepeatedMessage(const FieldDescriptor* field, int index);
 
236
  Message* MutableRepeatedMessage(Message* message,
 
237
                                  const FieldDescriptor* field,
 
238
                                  int index) const;
176
239
 
177
 
  void AddInt32 (const FieldDescriptor* field, int32  value);
178
 
  void AddInt64 (const FieldDescriptor* field, int64  value);
179
 
  void AddUInt32(const FieldDescriptor* field, uint32 value);
180
 
  void AddUInt64(const FieldDescriptor* field, uint64 value);
181
 
  void AddFloat (const FieldDescriptor* field, float  value);
182
 
  void AddDouble(const FieldDescriptor* field, double value);
183
 
  void AddBool  (const FieldDescriptor* field, bool   value);
184
 
  void AddString(const FieldDescriptor* field, const string& value);
185
 
  void AddEnum(const FieldDescriptor* field, const EnumValueDescriptor* value);
186
 
  Message* AddMessage(const FieldDescriptor* field);
 
240
  void AddInt32 (Message* message,
 
241
                 const FieldDescriptor* field, int32  value) const;
 
242
  void AddInt64 (Message* message,
 
243
                 const FieldDescriptor* field, int64  value) const;
 
244
  void AddUInt32(Message* message,
 
245
                 const FieldDescriptor* field, uint32 value) const;
 
246
  void AddUInt64(Message* message,
 
247
                 const FieldDescriptor* field, uint64 value) const;
 
248
  void AddFloat (Message* message,
 
249
                 const FieldDescriptor* field, float  value) const;
 
250
  void AddDouble(Message* message,
 
251
                 const FieldDescriptor* field, double value) const;
 
252
  void AddBool  (Message* message,
 
253
                 const FieldDescriptor* field, bool   value) const;
 
254
  void AddString(Message* message,
 
255
                 const FieldDescriptor* field, const string& value) const;
 
256
  void AddEnum(Message* message,
 
257
               const FieldDescriptor* field,
 
258
               const EnumValueDescriptor* value) const;
 
259
  Message* AddMessage(Message* message, const FieldDescriptor* field) const;
187
260
 
188
261
  const FieldDescriptor* FindKnownExtensionByName(const string& name) const;
189
262
  const FieldDescriptor* FindKnownExtensionByNumber(int number) const;
192
265
  friend class GeneratedMessage;
193
266
 
194
267
  const Descriptor* descriptor_;
195
 
  void* base_;
196
 
  const void* default_base_;
 
268
  const Message* default_instance_;
197
269
  const int* offsets_;
198
270
 
199
 
  // TODO(kenton):  These two pointers just point back into the message object.
200
 
  //   We could save space by removing them and using offsets instead.
201
 
  uint32* has_bits_;
202
 
  ExtensionSet* extensions_;
203
 
 
204
 
  // We put this directly in the GeneratedMessageReflection because every
205
 
  // message class needs it, and if we don't find any unknown fields, it
206
 
  // takes up only one pointer of space.
207
 
  UnknownFieldSet unknown_fields_;
208
 
 
209
 
  template <typename Type>
210
 
  inline const Type& GetRaw(const FieldDescriptor* field) const;
211
 
  template <typename Type>
212
 
  inline Type* MutableRaw(const FieldDescriptor* field);
 
271
  int has_bits_offset_;
 
272
  int unknown_fields_offset_;
 
273
  int extensions_offset_;
 
274
  int object_size_;
 
275
 
 
276
  const DescriptorPool* descriptor_pool_;
 
277
 
 
278
  template <typename Type>
 
279
  inline const Type& GetRaw(const Message& message,
 
280
                            const FieldDescriptor* field) const;
 
281
  template <typename Type>
 
282
  inline Type* MutableRaw(Message* message,
 
283
                          const FieldDescriptor* field) const;
213
284
  template <typename Type>
214
285
  inline const Type& DefaultRaw(const FieldDescriptor* field) const;
215
286
  inline const Message* GetMessagePrototype(const FieldDescriptor* field) const;
216
287
 
217
 
  inline bool HasBit(const FieldDescriptor* field) const;
218
 
  inline void SetBit(const FieldDescriptor* field);
219
 
  inline void ClearBit(const FieldDescriptor* field);
220
 
 
221
 
  template <typename Type>
222
 
  inline const Type& GetField(const FieldDescriptor* field) const;
223
 
  template <typename Type>
224
 
  inline void SetField(const FieldDescriptor* field, const Type& value);
225
 
  template <typename Type>
226
 
  inline Type* MutableField(const FieldDescriptor* field);
227
 
  template <typename Type>
228
 
  inline const Type& GetRepeatedField(const FieldDescriptor* field,
 
288
  inline const uint32* GetHasBits(const Message& message) const;
 
289
  inline uint32* MutableHasBits(Message* message) const;
 
290
  inline const ExtensionSet& GetExtensionSet(const Message& message) const;
 
291
  inline ExtensionSet* MutableExtensionSet(Message* message) const;
 
292
 
 
293
  inline bool HasBit(const Message& message,
 
294
                     const FieldDescriptor* field) const;
 
295
  inline void SetBit(Message* message,
 
296
                     const FieldDescriptor* field) const;
 
297
  inline void ClearBit(Message* message,
 
298
                       const FieldDescriptor* field) const;
 
299
 
 
300
  template <typename Type>
 
301
  inline const Type& GetField(const Message& message,
 
302
                              const FieldDescriptor* field) const;
 
303
  template <typename Type>
 
304
  inline void SetField(Message* message,
 
305
                       const FieldDescriptor* field, const Type& value) const;
 
306
  template <typename Type>
 
307
  inline Type* MutableField(Message* message,
 
308
                            const FieldDescriptor* field) const;
 
309
  template <typename Type>
 
310
  inline const Type& GetRepeatedField(const Message& message,
 
311
                                      const FieldDescriptor* field,
229
312
                                      int index) const;
230
313
  template <typename Type>
231
 
  inline void SetRepeatedField(const FieldDescriptor* field, int index,
232
 
                               const Type& value);
233
 
  template <typename Type>
234
 
  inline Type* MutableRepeatedField(const FieldDescriptor* field, int index);
235
 
  template <typename Type>
236
 
  inline void AddField(const FieldDescriptor* field, const Type& value);
237
 
  template <typename Type>
238
 
  inline Type* AddField(const FieldDescriptor* field);
 
314
  inline void SetRepeatedField(Message* message,
 
315
                               const FieldDescriptor* field, int index,
 
316
                               const Type& value) const;
 
317
  template <typename Type>
 
318
  inline Type* MutableRepeatedField(Message* message,
 
319
                                    const FieldDescriptor* field,
 
320
                                    int index) const;
 
321
  template <typename Type>
 
322
  inline void AddField(Message* message,
 
323
                       const FieldDescriptor* field, const Type& value) const;
 
324
  template <typename Type>
 
325
  inline Type* AddField(Message* message,
 
326
                        const FieldDescriptor* field) const;
239
327
 
240
328
  int GetExtensionNumberOrDie(const Descriptor* type) const;
241
329
 
292
380
#endif
293
381
}
294
382
 
 
383
// Compute the space used by a string, not including sizeof(string) itself.
 
384
// This is slightly complicated because small strings store their data within
 
385
// the string object but large strings do not.
 
386
int StringSpaceUsedExcludingSelf(const string& str);
 
387
 
295
388
 
296
389
}  // namespace internal
297
390
}  // namespace protobuf