Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: third_party/protobuf/src/google/protobuf/message.h

Issue 1322483002: Revert https://codereview.chromium.org/1291903002 (protobuf roll). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // http://code.google.com/p/protobuf/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above 11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer 12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the 13 // in the documentation and/or other materials provided with the
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // FindFieldByName("numbers"); 91 // FindFieldByName("numbers");
92 // assert(numbers_field != NULL); 92 // assert(numbers_field != NULL);
93 // assert(numbers_field->type() == FieldDescriptor::TYPE_INT32); 93 // assert(numbers_field->type() == FieldDescriptor::TYPE_INT32);
94 // assert(numbers_field->label() == FieldDescriptor::LABEL_REPEATED); 94 // assert(numbers_field->label() == FieldDescriptor::LABEL_REPEATED);
95 // 95 //
96 // // Parse the message. 96 // // Parse the message.
97 // foo->ParseFromString(data); 97 // foo->ParseFromString(data);
98 // 98 //
99 // // Use the reflection interface to examine the contents. 99 // // Use the reflection interface to examine the contents.
100 // const Reflection* reflection = foo->GetReflection(); 100 // const Reflection* reflection = foo->GetReflection();
101 // assert(reflection->GetString(*foo, text_field) == "Hello World!"); 101 // assert(reflection->GetString(foo, text_field) == "Hello World!");
102 // assert(reflection->FieldSize(*foo, numbers_field) == 3); 102 // assert(reflection->FieldSize(foo, numbers_field) == 3);
103 // assert(reflection->GetRepeatedInt32(*foo, numbers_field, 0) == 1); 103 // assert(reflection->GetRepeatedInt32(foo, numbers_field, 0) == 1);
104 // assert(reflection->GetRepeatedInt32(*foo, numbers_field, 1) == 5); 104 // assert(reflection->GetRepeatedInt32(foo, numbers_field, 1) == 5);
105 // assert(reflection->GetRepeatedInt32(*foo, numbers_field, 2) == 42); 105 // assert(reflection->GetRepeatedInt32(foo, numbers_field, 2) == 42);
106 // 106 //
107 // delete foo; 107 // delete foo;
108 // } 108 // }
109 109
110 #ifndef GOOGLE_PROTOBUF_MESSAGE_H__ 110 #ifndef GOOGLE_PROTOBUF_MESSAGE_H__
111 #define GOOGLE_PROTOBUF_MESSAGE_H__ 111 #define GOOGLE_PROTOBUF_MESSAGE_H__
112 112
113 #include <vector>
114 #include <string>
115
116 #ifdef __DECCXX
117 // HP C++'s iosfwd doesn't work.
118 #include <iostream>
119 #else
113 #include <iosfwd> 120 #include <iosfwd>
114 #include <string> 121 #endif
115 #include <google/protobuf/stubs/type_traits.h>
116 #include <vector>
117 122
118 #include <google/protobuf/arena.h>
119 #include <google/protobuf/message_lite.h> 123 #include <google/protobuf/message_lite.h>
120 124
121 #include <google/protobuf/stubs/common.h> 125 #include <google/protobuf/stubs/common.h>
122 #include <google/protobuf/descriptor.h> 126 #include <google/protobuf/descriptor.h>
123 127
124 128
125 #define GOOGLE_PROTOBUF_HAS_ONEOF
126 #define GOOGLE_PROTOBUF_HAS_ARENAS
127
128 namespace google { 129 namespace google {
129 namespace protobuf { 130 namespace protobuf {
130 131
131 // Defined in this file. 132 // Defined in this file.
132 class Message; 133 class Message;
133 class Reflection; 134 class Reflection;
134 class MessageFactory; 135 class MessageFactory;
135 136
136 // Defined in other files. 137 // Defined in other files.
137 class UnknownFieldSet; // unknown_field_set.h 138 class UnknownFieldSet; // unknown_field_set.h
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 inline Message() {} 171 inline Message() {}
171 virtual ~Message(); 172 virtual ~Message();
172 173
173 // Basic Operations ------------------------------------------------ 174 // Basic Operations ------------------------------------------------
174 175
175 // Construct a new instance of the same type. Ownership is passed to the 176 // Construct a new instance of the same type. Ownership is passed to the
176 // caller. (This is also defined in MessageLite, but is defined again here 177 // caller. (This is also defined in MessageLite, but is defined again here
177 // for return-type covariance.) 178 // for return-type covariance.)
178 virtual Message* New() const = 0; 179 virtual Message* New() const = 0;
179 180
180 // Construct a new instance on the arena. Ownership is passed to the caller
181 // if arena is a NULL. Default implementation allows for API compatibility
182 // during the Arena transition.
183 virtual Message* New(::google::protobuf::Arena* arena) const {
184 Message* message = New();
185 if (arena != NULL) {
186 arena->Own(message);
187 }
188 return message;
189 }
190
191 // Make this message into a copy of the given message. The given message 181 // Make this message into a copy of the given message. The given message
192 // must have the same descriptor, but need not necessarily be the same class. 182 // must have the same descriptor, but need not necessarily be the same class.
193 // By default this is just implemented as "Clear(); MergeFrom(from);". 183 // By default this is just implemented as "Clear(); MergeFrom(from);".
194 virtual void CopyFrom(const Message& from); 184 virtual void CopyFrom(const Message& from);
195 185
196 // Merge the fields from the given message into this message. Singular 186 // Merge the fields from the given message into this message. Singular
197 // fields will be overwritten, if specified in from, except for embedded 187 // fields will be overwritten, except for embedded messages which will
198 // messages which will be merged. Repeated fields will be concatenated. 188 // be merged. Repeated fields will be concatenated. The given message
199 // The given message must be of the same type as this message (i.e. the 189 // must be of the same type as this message (i.e. the exact same class).
200 // exact same class).
201 virtual void MergeFrom(const Message& from); 190 virtual void MergeFrom(const Message& from);
202 191
203 // Verifies that IsInitialized() returns true. GOOGLE_CHECK-fails otherwise, with 192 // Verifies that IsInitialized() returns true. GOOGLE_CHECK-fails otherwise, with
204 // a nice error message. 193 // a nice error message.
205 void CheckInitialized() const; 194 void CheckInitialized() const;
206 195
207 // Slowly build a list of all required fields that are not set. 196 // Slowly build a list of all required fields that are not set.
208 // This is much, much slower than IsInitialized() as it is implemented 197 // This is much, much slower than IsInitialized() as it is implemented
209 // purely via reflection. Generally, you should not call this unless you 198 // purely via reflection. Generally, you should not call this unless you
210 // have already determined that an error exists by calling IsInitialized(). 199 // have already determined that an error exists by calling IsInitialized().
211 void FindInitializationErrors(std::vector<string>* errors) const; 200 void FindInitializationErrors(vector<string>* errors) const;
212 201
213 // Like FindInitializationErrors, but joins all the strings, delimited by 202 // Like FindInitializationErrors, but joins all the strings, delimited by
214 // commas, and returns them. 203 // commas, and returns them.
215 string InitializationErrorString() const; 204 string InitializationErrorString() const;
216 205
217 // Clears all unknown fields from this message and all embedded messages. 206 // Clears all unknown fields from this message and all embedded messages.
218 // Normally, if unknown tag numbers are encountered when parsing a message, 207 // Normally, if unknown tag numbers are encountered when parsing a message,
219 // the tag and value are stored in the message's UnknownFieldSet and 208 // the tag and value are stored in the message's UnknownFieldSet and
220 // then written back out when the message is serialized. This allows servers 209 // then written back out when the message is serialized. This allows servers
221 // which simply route messages to other servers to pass through messages 210 // which simply route messages to other servers to pass through messages
222 // that have new field definitions which they don't yet know about. However, 211 // that have new field definitions which they don't yet know about. However,
223 // this behavior can have security implications. To avoid it, call this 212 // this behavior can have security implications. To avoid it, call this
224 // method after parsing. 213 // method after parsing.
225 // 214 //
226 // See Reflection::GetUnknownFields() for more on unknown fields. 215 // See Reflection::GetUnknownFields() for more on unknown fields.
227 virtual void DiscardUnknownFields(); 216 virtual void DiscardUnknownFields();
228 217
229 // Computes (an estimate of) the total number of bytes currently used for 218 // Computes (an estimate of) the total number of bytes currently used for
230 // storing the message in memory. The default implementation calls the 219 // storing the message in memory. The default implementation calls the
231 // Reflection object's SpaceUsed() method. 220 // Reflection object's SpaceUsed() method.
232 //
233 // SpaceUsed() is noticeably slower than ByteSize(), as it is implemented
234 // using reflection (rather than the generated code implementation for
235 // ByteSize()). Like ByteSize(), its CPU time is linear in the number of
236 // fields defined for the proto.
237 virtual int SpaceUsed() const; 221 virtual int SpaceUsed() const;
238 222
239 // Debugging & Testing---------------------------------------------- 223 // Debugging & Testing----------------------------------------------
240 224
241 // Generates a human readable form of this message, useful for debugging 225 // Generates a human readable form of this message, useful for debugging
242 // and other purposes. 226 // and other purposes.
243 string DebugString() const; 227 string DebugString() const;
244 // Like DebugString(), but with less whitespace. 228 // Like DebugString(), but with less whitespace.
245 string ShortDebugString() const; 229 string ShortDebugString() const;
246 // Like DebugString(), but do not escape UTF-8 byte sequences. 230 // Like DebugString(), but do not escape UTF-8 byte sequences.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // Get a struct containing the metadata for the Message. Most subclasses only 309 // Get a struct containing the metadata for the Message. Most subclasses only
326 // need to implement this method, rather than the GetDescriptor() and 310 // need to implement this method, rather than the GetDescriptor() and
327 // GetReflection() wrappers. 311 // GetReflection() wrappers.
328 virtual Metadata GetMetadata() const = 0; 312 virtual Metadata GetMetadata() const = 0;
329 313
330 314
331 private: 315 private:
332 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Message); 316 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Message);
333 }; 317 };
334 318
335 namespace internal {
336 // Forward-declare interfaces used to implement RepeatedFieldRef.
337 // These are protobuf internals that users shouldn't care about.
338 class RepeatedFieldAccessor;
339 } // namespace internal
340
341 // Forward-declare RepeatedFieldRef templates. The second type parameter is
342 // used for SFINAE tricks. Users should ignore it.
343 template<typename T, typename Enable = void>
344 class RepeatedFieldRef;
345
346 template<typename T, typename Enable = void>
347 class MutableRepeatedFieldRef;
348
349 // This interface contains methods that can be used to dynamically access 319 // This interface contains methods that can be used to dynamically access
350 // and modify the fields of a protocol message. Their semantics are 320 // and modify the fields of a protocol message. Their semantics are
351 // similar to the accessors the protocol compiler generates. 321 // similar to the accessors the protocol compiler generates.
352 // 322 //
353 // To get the Reflection for a given Message, call Message::GetReflection(). 323 // To get the Reflection for a given Message, call Message::GetReflection().
354 // 324 //
355 // This interface is separate from Message only for efficiency reasons; 325 // This interface is separate from Message only for efficiency reasons;
356 // the vast majority of implementations of Message will share the same 326 // the vast majority of implementations of Message will share the same
357 // implementation of Reflection (GeneratedMessageReflection, 327 // implementation of Reflection (GeneratedMessageReflection,
358 // defined in generated_message.h), and all Messages of a particular class 328 // defined in generated_message.h), and all Messages of a particular class
(...skipping 28 matching lines...) Expand all
387 // 357 //
388 // TODO(kenton): Create a utility class which callers can use to read and 358 // TODO(kenton): Create a utility class which callers can use to read and
389 // write fields from a Reflection without paying attention to the type. 359 // write fields from a Reflection without paying attention to the type.
390 class LIBPROTOBUF_EXPORT Reflection { 360 class LIBPROTOBUF_EXPORT Reflection {
391 public: 361 public:
392 inline Reflection() {} 362 inline Reflection() {}
393 virtual ~Reflection(); 363 virtual ~Reflection();
394 364
395 // Get the UnknownFieldSet for the message. This contains fields which 365 // Get the UnknownFieldSet for the message. This contains fields which
396 // were seen when the Message was parsed but were not recognized according 366 // were seen when the Message was parsed but were not recognized according
397 // to the Message's definition. For proto3 protos, this method will always 367 // to the Message's definition.
398 // return an empty UnknownFieldSet.
399 virtual const UnknownFieldSet& GetUnknownFields( 368 virtual const UnknownFieldSet& GetUnknownFields(
400 const Message& message) const = 0; 369 const Message& message) const = 0;
401 // Get a mutable pointer to the UnknownFieldSet for the message. This 370 // Get a mutable pointer to the UnknownFieldSet for the message. This
402 // contains fields which were seen when the Message was parsed but were not 371 // contains fields which were seen when the Message was parsed but were not
403 // recognized according to the Message's definition. For proto3 protos, this 372 // recognized according to the Message's definition.
404 // method will return a valid mutable UnknownFieldSet pointer but modifying
405 // it won't affect the serialized bytes of the message.
406 virtual UnknownFieldSet* MutableUnknownFields(Message* message) const = 0; 373 virtual UnknownFieldSet* MutableUnknownFields(Message* message) const = 0;
407 374
408 // Estimate the amount of memory used by the message object. 375 // Estimate the amount of memory used by the message object.
409 virtual int SpaceUsed(const Message& message) const = 0; 376 virtual int SpaceUsed(const Message& message) const = 0;
410 377
411 // Check if the given non-repeated field is set. 378 // Check if the given non-repeated field is set.
412 virtual bool HasField(const Message& message, 379 virtual bool HasField(const Message& message,
413 const FieldDescriptor* field) const = 0; 380 const FieldDescriptor* field) const = 0;
414 381
415 // Get the number of elements of a repeated field. 382 // Get the number of elements of a repeated field.
416 virtual int FieldSize(const Message& message, 383 virtual int FieldSize(const Message& message,
417 const FieldDescriptor* field) const = 0; 384 const FieldDescriptor* field) const = 0;
418 385
419 // Clear the value of a field, so that HasField() returns false or 386 // Clear the value of a field, so that HasField() returns false or
420 // FieldSize() returns zero. 387 // FieldSize() returns zero.
421 virtual void ClearField(Message* message, 388 virtual void ClearField(Message* message,
422 const FieldDescriptor* field) const = 0; 389 const FieldDescriptor* field) const = 0;
423 390
424 // Check if the oneof is set. Returns true if any field in oneof
425 // is set, false otherwise.
426 // TODO(jieluo) - make it pure virtual after updating all
427 // the subclasses.
428 virtual bool HasOneof(const Message& /*message*/,
429 const OneofDescriptor* /*oneof_descriptor*/) const {
430 return false;
431 }
432
433 virtual void ClearOneof(Message* /*message*/,
434 const OneofDescriptor* /*oneof_descriptor*/) const {}
435
436 // Returns the field descriptor if the oneof is set. NULL otherwise.
437 // TODO(jieluo) - make it pure virtual.
438 virtual const FieldDescriptor* GetOneofFieldDescriptor(
439 const Message& /*message*/,
440 const OneofDescriptor* /*oneof_descriptor*/) const {
441 return NULL;
442 }
443
444 // Removes the last element of a repeated field. 391 // Removes the last element of a repeated field.
445 // We don't provide a way to remove any element other than the last 392 // We don't provide a way to remove any element other than the last
446 // because it invites inefficient use, such as O(n^2) filtering loops 393 // because it invites inefficient use, such as O(n^2) filtering loops
447 // that should have been O(n). If you want to remove an element other 394 // that should have been O(n). If you want to remove an element other
448 // than the last, the best way to do it is to re-arrange the elements 395 // than the last, the best way to do it is to re-arrange the elements
449 // (using Swap()) so that the one you want removed is at the end, then 396 // (using Swap()) so that the one you want removed is at the end, then
450 // call RemoveLast(). 397 // call RemoveLast().
451 virtual void RemoveLast(Message* message, 398 virtual void RemoveLast(Message* message,
452 const FieldDescriptor* field) const = 0; 399 const FieldDescriptor* field) const = 0;
453 // Removes the last element of a repeated message field, and returns the 400 // Removes the last element of a repeated message field, and returns the
454 // pointer to the caller. Caller takes ownership of the returned pointer. 401 // pointer to the caller. Caller takes ownership of the returned pointer.
455 virtual Message* ReleaseLast(Message* message, 402 virtual Message* ReleaseLast(Message* message,
456 const FieldDescriptor* field) const = 0; 403 const FieldDescriptor* field) const = 0;
457 404
458 // Swap the complete contents of two messages. 405 // Swap the complete contents of two messages.
459 virtual void Swap(Message* message1, Message* message2) const = 0; 406 virtual void Swap(Message* message1, Message* message2) const = 0;
460 407
461 // Swap fields listed in fields vector of two messages.
462 virtual void SwapFields(Message* message1,
463 Message* message2,
464 const std::vector<const FieldDescriptor*>& fields)
465 const = 0;
466
467 // Swap two elements of a repeated field. 408 // Swap two elements of a repeated field.
468 virtual void SwapElements(Message* message, 409 virtual void SwapElements(Message* message,
469 const FieldDescriptor* field, 410 const FieldDescriptor* field,
470 int index1, 411 int index1,
471 int index2) const = 0; 412 int index2) const = 0;
472 413
473 // List all fields of the message which are currently set. This includes 414 // List all fields of the message which are currently set. This includes
474 // extensions. Singular fields will only be listed if HasField(field) would 415 // extensions. Singular fields will only be listed if HasField(field) would
475 // return true and repeated fields will only be listed if FieldSize(field) 416 // return true and repeated fields will only be listed if FieldSize(field)
476 // would return non-zero. Fields (both normal fields and extension fields) 417 // would return non-zero. Fields (both normal fields and extension fields)
477 // will be listed ordered by field number. 418 // will be listed ordered by field number.
478 virtual void ListFields( 419 virtual void ListFields(const Message& message,
479 const Message& message, 420 vector<const FieldDescriptor*>* output) const = 0;
480 std::vector<const FieldDescriptor*>* output) const = 0;
481 421
482 // Singular field getters ------------------------------------------ 422 // Singular field getters ------------------------------------------
483 // These get the value of a non-repeated field. They return the default 423 // These get the value of a non-repeated field. They return the default
484 // value for fields that aren't set. 424 // value for fields that aren't set.
485 425
486 virtual int32 GetInt32 (const Message& message, 426 virtual int32 GetInt32 (const Message& message,
487 const FieldDescriptor* field) const = 0; 427 const FieldDescriptor* field) const = 0;
488 virtual int64 GetInt64 (const Message& message, 428 virtual int64 GetInt64 (const Message& message,
489 const FieldDescriptor* field) const = 0; 429 const FieldDescriptor* field) const = 0;
490 virtual uint32 GetUInt32(const Message& message, 430 virtual uint32 GetUInt32(const Message& message,
491 const FieldDescriptor* field) const = 0; 431 const FieldDescriptor* field) const = 0;
492 virtual uint64 GetUInt64(const Message& message, 432 virtual uint64 GetUInt64(const Message& message,
493 const FieldDescriptor* field) const = 0; 433 const FieldDescriptor* field) const = 0;
494 virtual float GetFloat (const Message& message, 434 virtual float GetFloat (const Message& message,
495 const FieldDescriptor* field) const = 0; 435 const FieldDescriptor* field) const = 0;
496 virtual double GetDouble(const Message& message, 436 virtual double GetDouble(const Message& message,
497 const FieldDescriptor* field) const = 0; 437 const FieldDescriptor* field) const = 0;
498 virtual bool GetBool (const Message& message, 438 virtual bool GetBool (const Message& message,
499 const FieldDescriptor* field) const = 0; 439 const FieldDescriptor* field) const = 0;
500 virtual string GetString(const Message& message, 440 virtual string GetString(const Message& message,
501 const FieldDescriptor* field) const = 0; 441 const FieldDescriptor* field) const = 0;
502 virtual const EnumValueDescriptor* GetEnum( 442 virtual const EnumValueDescriptor* GetEnum(
503 const Message& message, const FieldDescriptor* field) const = 0; 443 const Message& message, const FieldDescriptor* field) const = 0;
504
505 // GetEnumValue() returns an enum field's value as an integer rather than
506 // an EnumValueDescriptor*. If the integer value does not correspond to a
507 // known value descriptor, a new value descriptor is created. (Such a value
508 // will only be present when the new unknown-enum-value semantics are enabled
509 // for a message.)
510 virtual int GetEnumValue(
511 const Message& message, const FieldDescriptor* field) const;
512
513 // See MutableMessage() for the meaning of the "factory" parameter. 444 // See MutableMessage() for the meaning of the "factory" parameter.
514 virtual const Message& GetMessage(const Message& message, 445 virtual const Message& GetMessage(const Message& message,
515 const FieldDescriptor* field, 446 const FieldDescriptor* field,
516 MessageFactory* factory = NULL) const = 0; 447 MessageFactory* factory = NULL) const = 0;
517 448
518 // Get a string value without copying, if possible. 449 // Get a string value without copying, if possible.
519 // 450 //
520 // GetString() necessarily returns a copy of the string. This can be 451 // GetString() necessarily returns a copy of the string. This can be
521 // inefficient when the string is already stored in a string object in the 452 // inefficient when the string is already stored in a string object in the
522 // underlying message. GetStringReference() will return a reference to the 453 // underlying message. GetStringReference() will return a reference to the
523 // underlying string in this case. Otherwise, it will copy the string into 454 // underlying string in this case. Otherwise, it will copy the string into
524 // *scratch and return that. 455 // *scratch and return that.
525 // 456 //
526 // Note: It is perfectly reasonable and useful to write code like: 457 // Note: It is perfectly reasonable and useful to write code like:
527 // str = reflection->GetStringReference(field, &str); 458 // str = reflection->GetStringReference(field, &str);
528 // This line would ensure that only one copy of the string is made 459 // This line would ensure that only one copy of the string is made
529 // regardless of the field's underlying representation. When initializing 460 // regardless of the field's underlying representation. When initializing
530 // a newly-constructed string, though, it's just as fast and more readable 461 // a newly-constructed string, though, it's just as fast and more readable
531 // to use code like: 462 // to use code like:
532 // string str = reflection->GetString(message, field); 463 // string str = reflection->GetString(field);
533 virtual const string& GetStringReference(const Message& message, 464 virtual const string& GetStringReference(const Message& message,
534 const FieldDescriptor* field, 465 const FieldDescriptor* field,
535 string* scratch) const = 0; 466 string* scratch) const = 0;
536 467
537 468
538 // Singular field mutators ----------------------------------------- 469 // Singular field mutators -----------------------------------------
539 // These mutate the value of a non-repeated field. 470 // These mutate the value of a non-repeated field.
540 471
541 virtual void SetInt32 (Message* message, 472 virtual void SetInt32 (Message* message,
542 const FieldDescriptor* field, int32 value) const = 0; 473 const FieldDescriptor* field, int32 value) const = 0;
543 virtual void SetInt64 (Message* message, 474 virtual void SetInt64 (Message* message,
544 const FieldDescriptor* field, int64 value) const = 0; 475 const FieldDescriptor* field, int64 value) const = 0;
545 virtual void SetUInt32(Message* message, 476 virtual void SetUInt32(Message* message,
546 const FieldDescriptor* field, uint32 value) const = 0; 477 const FieldDescriptor* field, uint32 value) const = 0;
547 virtual void SetUInt64(Message* message, 478 virtual void SetUInt64(Message* message,
548 const FieldDescriptor* field, uint64 value) const = 0; 479 const FieldDescriptor* field, uint64 value) const = 0;
549 virtual void SetFloat (Message* message, 480 virtual void SetFloat (Message* message,
550 const FieldDescriptor* field, float value) const = 0; 481 const FieldDescriptor* field, float value) const = 0;
551 virtual void SetDouble(Message* message, 482 virtual void SetDouble(Message* message,
552 const FieldDescriptor* field, double value) const = 0; 483 const FieldDescriptor* field, double value) const = 0;
553 virtual void SetBool (Message* message, 484 virtual void SetBool (Message* message,
554 const FieldDescriptor* field, bool value) const = 0; 485 const FieldDescriptor* field, bool value) const = 0;
555 virtual void SetString(Message* message, 486 virtual void SetString(Message* message,
556 const FieldDescriptor* field, 487 const FieldDescriptor* field,
557 const string& value) const = 0; 488 const string& value) const = 0;
558 virtual void SetEnum (Message* message, 489 virtual void SetEnum (Message* message,
559 const FieldDescriptor* field, 490 const FieldDescriptor* field,
560 const EnumValueDescriptor* value) const = 0; 491 const EnumValueDescriptor* value) const = 0;
561 // Set an enum field's value with an integer rather than EnumValueDescriptor.
562 // If the value does not correspond to a known enum value, either behavior is
563 // undefined (for proto2 messages), or the value is accepted silently for
564 // messages with new unknown-enum-value semantics.
565 virtual void SetEnumValue(Message* message,
566 const FieldDescriptor* field,
567 int value) const;
568
569 // Get a mutable pointer to a field with a message type. If a MessageFactory 492 // Get a mutable pointer to a field with a message type. If a MessageFactory
570 // is provided, it will be used to construct instances of the sub-message; 493 // is provided, it will be used to construct instances of the sub-message;
571 // otherwise, the default factory is used. If the field is an extension that 494 // otherwise, the default factory is used. If the field is an extension that
572 // does not live in the same pool as the containing message's descriptor (e.g. 495 // does not live in the same pool as the containing message's descriptor (e.g.
573 // it lives in an overlay pool), then a MessageFactory must be provided. 496 // it lives in an overlay pool), then a MessageFactory must be provided.
574 // If you have no idea what that meant, then you probably don't need to worry 497 // If you have no idea what that meant, then you probably don't need to worry
575 // about it (don't provide a MessageFactory). WARNING: If the 498 // about it (don't provide a MessageFactory). WARNING: If the
576 // FieldDescriptor is for a compiled-in extension, then 499 // FieldDescriptor is for a compiled-in extension, then
577 // factory->GetPrototype(field->message_type() MUST return an instance of the 500 // factory->GetPrototype(field->message_type() MUST return an instance of the
578 // compiled-in class for this type, NOT DynamicMessage. 501 // compiled-in class for this type, NOT DynamicMessage.
579 virtual Message* MutableMessage(Message* message, 502 virtual Message* MutableMessage(Message* message,
580 const FieldDescriptor* field, 503 const FieldDescriptor* field,
581 MessageFactory* factory = NULL) const = 0; 504 MessageFactory* factory = NULL) const = 0;
582 // Replaces the message specified by 'field' with the already-allocated object
583 // sub_message, passing ownership to the message. If the field contained a
584 // message, that message is deleted. If sub_message is NULL, the field is
585 // cleared.
586 virtual void SetAllocatedMessage(Message* message,
587 Message* sub_message,
588 const FieldDescriptor* field) const = 0;
589 // Releases the message specified by 'field' and returns the pointer, 505 // Releases the message specified by 'field' and returns the pointer,
590 // ReleaseMessage() will return the message the message object if it exists. 506 // ReleaseMessage() will return the message the message object if it exists.
591 // Otherwise, it may or may not return NULL. In any case, if the return value 507 // Otherwise, it may or may not return NULL. In any case, if the return value
592 // is non-NULL, the caller takes ownership of the pointer. 508 // is non-NULL, the caller takes ownership of the pointer.
593 // If the field existed (HasField() is true), then the returned pointer will 509 // If the field existed (HasField() is true), then the returned pointer will
594 // be the same as the pointer returned by MutableMessage(). 510 // be the same as the pointer returned by MutableMessage().
595 // This function has the same effect as ClearField(). 511 // This function has the same effect as ClearField().
596 virtual Message* ReleaseMessage(Message* message, 512 virtual Message* ReleaseMessage(Message* message,
597 const FieldDescriptor* field, 513 const FieldDescriptor* field,
598 MessageFactory* factory = NULL) const = 0; 514 MessageFactory* factory = NULL) const = 0;
(...skipping 22 matching lines...) Expand all
621 int index) const = 0; 537 int index) const = 0;
622 virtual bool GetRepeatedBool (const Message& message, 538 virtual bool GetRepeatedBool (const Message& message,
623 const FieldDescriptor* field, 539 const FieldDescriptor* field,
624 int index) const = 0; 540 int index) const = 0;
625 virtual string GetRepeatedString(const Message& message, 541 virtual string GetRepeatedString(const Message& message,
626 const FieldDescriptor* field, 542 const FieldDescriptor* field,
627 int index) const = 0; 543 int index) const = 0;
628 virtual const EnumValueDescriptor* GetRepeatedEnum( 544 virtual const EnumValueDescriptor* GetRepeatedEnum(
629 const Message& message, 545 const Message& message,
630 const FieldDescriptor* field, int index) const = 0; 546 const FieldDescriptor* field, int index) const = 0;
631 // GetRepeatedEnumValue() returns an enum field's value as an integer rather
632 // than an EnumValueDescriptor*. If the integer value does not correspond to a
633 // known value descriptor, a new value descriptor is created. (Such a value
634 // will only be present when the new unknown-enum-value semantics are enabled
635 // for a message.)
636 virtual int GetRepeatedEnumValue(
637 const Message& message,
638 const FieldDescriptor* field, int index) const;
639 virtual const Message& GetRepeatedMessage( 547 virtual const Message& GetRepeatedMessage(
640 const Message& message, 548 const Message& message,
641 const FieldDescriptor* field, int index) const = 0; 549 const FieldDescriptor* field, int index) const = 0;
642 550
643 // See GetStringReference(), above. 551 // See GetStringReference(), above.
644 virtual const string& GetRepeatedStringReference( 552 virtual const string& GetRepeatedStringReference(
645 const Message& message, const FieldDescriptor* field, 553 const Message& message, const FieldDescriptor* field,
646 int index, string* scratch) const = 0; 554 int index, string* scratch) const = 0;
647 555
648 556
(...skipping 20 matching lines...) Expand all
669 int index, double value) const = 0; 577 int index, double value) const = 0;
670 virtual void SetRepeatedBool (Message* message, 578 virtual void SetRepeatedBool (Message* message,
671 const FieldDescriptor* field, 579 const FieldDescriptor* field,
672 int index, bool value) const = 0; 580 int index, bool value) const = 0;
673 virtual void SetRepeatedString(Message* message, 581 virtual void SetRepeatedString(Message* message,
674 const FieldDescriptor* field, 582 const FieldDescriptor* field,
675 int index, const string& value) const = 0; 583 int index, const string& value) const = 0;
676 virtual void SetRepeatedEnum(Message* message, 584 virtual void SetRepeatedEnum(Message* message,
677 const FieldDescriptor* field, int index, 585 const FieldDescriptor* field, int index,
678 const EnumValueDescriptor* value) const = 0; 586 const EnumValueDescriptor* value) const = 0;
679 // Set an enum field's value with an integer rather than EnumValueDescriptor.
680 // If the value does not correspond to a known enum value, either behavior is
681 // undefined (for proto2 messages), or the value is accepted silently for
682 // messages with new unknown-enum-value semantics.
683 virtual void SetRepeatedEnumValue(Message* message,
684 const FieldDescriptor* field, int index,
685 int value) const;
686 // Get a mutable pointer to an element of a repeated field with a message 587 // Get a mutable pointer to an element of a repeated field with a message
687 // type. 588 // type.
688 virtual Message* MutableRepeatedMessage( 589 virtual Message* MutableRepeatedMessage(
689 Message* message, const FieldDescriptor* field, int index) const = 0; 590 Message* message, const FieldDescriptor* field, int index) const = 0;
690 591
691 592
692 // Repeated field adders ------------------------------------------- 593 // Repeated field adders -------------------------------------------
693 // These add an element to a repeated field. 594 // These add an element to a repeated field.
694 595
695 virtual void AddInt32 (Message* message, 596 virtual void AddInt32 (Message* message,
696 const FieldDescriptor* field, int32 value) const = 0; 597 const FieldDescriptor* field, int32 value) const = 0;
697 virtual void AddInt64 (Message* message, 598 virtual void AddInt64 (Message* message,
698 const FieldDescriptor* field, int64 value) const = 0; 599 const FieldDescriptor* field, int64 value) const = 0;
699 virtual void AddUInt32(Message* message, 600 virtual void AddUInt32(Message* message,
700 const FieldDescriptor* field, uint32 value) const = 0; 601 const FieldDescriptor* field, uint32 value) const = 0;
701 virtual void AddUInt64(Message* message, 602 virtual void AddUInt64(Message* message,
702 const FieldDescriptor* field, uint64 value) const = 0; 603 const FieldDescriptor* field, uint64 value) const = 0;
703 virtual void AddFloat (Message* message, 604 virtual void AddFloat (Message* message,
704 const FieldDescriptor* field, float value) const = 0; 605 const FieldDescriptor* field, float value) const = 0;
705 virtual void AddDouble(Message* message, 606 virtual void AddDouble(Message* message,
706 const FieldDescriptor* field, double value) const = 0; 607 const FieldDescriptor* field, double value) const = 0;
707 virtual void AddBool (Message* message, 608 virtual void AddBool (Message* message,
708 const FieldDescriptor* field, bool value) const = 0; 609 const FieldDescriptor* field, bool value) const = 0;
709 virtual void AddString(Message* message, 610 virtual void AddString(Message* message,
710 const FieldDescriptor* field, 611 const FieldDescriptor* field,
711 const string& value) const = 0; 612 const string& value) const = 0;
712 virtual void AddEnum (Message* message, 613 virtual void AddEnum (Message* message,
713 const FieldDescriptor* field, 614 const FieldDescriptor* field,
714 const EnumValueDescriptor* value) const = 0; 615 const EnumValueDescriptor* value) const = 0;
715 // Set an enum field's value with an integer rather than EnumValueDescriptor.
716 // If the value does not correspond to a known enum value, either behavior is
717 // undefined (for proto2 messages), or the value is accepted silently for
718 // messages with new unknown-enum-value semantics.
719 virtual void AddEnumValue(Message* message,
720 const FieldDescriptor* field,
721 int value) const;
722 // See MutableMessage() for comments on the "factory" parameter. 616 // See MutableMessage() for comments on the "factory" parameter.
723 virtual Message* AddMessage(Message* message, 617 virtual Message* AddMessage(Message* message,
724 const FieldDescriptor* field, 618 const FieldDescriptor* field,
725 MessageFactory* factory = NULL) const = 0; 619 MessageFactory* factory = NULL) const = 0;
726 620
727 621
728 // Get a RepeatedFieldRef object that can be used to read the underlying
729 // repeated field. The type parameter T must be set according to the
730 // field's cpp type. The following table shows the mapping from cpp type
731 // to acceptable T.
732 //
733 // field->cpp_type() T
734 // CPPTYPE_INT32 int32
735 // CPPTYPE_UINT32 uint32
736 // CPPTYPE_INT64 int64
737 // CPPTYPE_UINT64 uint64
738 // CPPTYPE_DOUBLE double
739 // CPPTYPE_FLOAT float
740 // CPPTYPE_BOOL bool
741 // CPPTYPE_ENUM generated enum type or int32
742 // CPPTYPE_STRING string
743 // CPPTYPE_MESSAGE generated message type or google::protobuf::Message
744 //
745 // A RepeatedFieldRef object can be copied and the resulted object will point
746 // to the same repeated field in the same message. The object can be used as
747 // long as the message is not destroyed.
748 //
749 // Note that to use this method users need to include the header file
750 // "google/protobuf/reflection.h" (which defines the RepeatedFieldRef
751 // class templates).
752 template<typename T>
753 RepeatedFieldRef<T> GetRepeatedFieldRef(
754 const Message& message, const FieldDescriptor* field) const;
755
756 // Like GetRepeatedFieldRef() but return an object that can also be used
757 // manipulate the underlying repeated field.
758 template<typename T>
759 MutableRepeatedFieldRef<T> GetMutableRepeatedFieldRef(
760 Message* message, const FieldDescriptor* field) const;
761
762 // DEPRECATED. Please use Get(Mutable)RepeatedFieldRef() for repeated field
763 // access. The following repeated field accesors will be removed in the
764 // future.
765 //
766 // Repeated field accessors ------------------------------------------------- 622 // Repeated field accessors -------------------------------------------------
767 // The methods above, e.g. GetRepeatedInt32(msg, fd, index), provide singular 623 // The methods above, e.g. GetRepeatedInt32(msg, fd, index), provide singular
768 // access to the data in a RepeatedField. The methods below provide aggregate 624 // access to the data in a RepeatedField. The methods below provide aggregate
769 // access by exposing the RepeatedField object itself with the Message. 625 // access by exposing the RepeatedField object itself with the Message.
770 // Applying these templates to inappropriate types will lead to an undefined 626 // Applying these templates to inappropriate types will lead to an undefined
771 // reference at link time (e.g. GetRepeatedField<***double>), or possibly a 627 // reference at link time (e.g. GetRepeatedField<***double>), or possibly a
772 // template matching error at compile time (e.g. GetRepeatedPtrField<File>). 628 // template matching error at compile time (e.g. GetRepeatedPtrField<File>).
773 // 629 //
774 // Usage example: my_doubs = refl->GetRepeatedField<double>(msg, fd); 630 // Usage example: my_doubs = refl->GetRepeatedField<double>(msg, fd);
775 631
776 // DEPRECATED. Please use GetRepeatedFieldRef().
777 //
778 // for T = Cord and all protobuf scalar types except enums. 632 // for T = Cord and all protobuf scalar types except enums.
779 template<typename T> 633 template<typename T>
780 const RepeatedField<T>& GetRepeatedField( 634 const RepeatedField<T>& GetRepeatedField(
781 const Message&, const FieldDescriptor*) const; 635 const Message&, const FieldDescriptor*) const;
782 636
783 // DEPRECATED. Please use GetMutableRepeatedFieldRef().
784 //
785 // for T = Cord and all protobuf scalar types except enums. 637 // for T = Cord and all protobuf scalar types except enums.
786 template<typename T> 638 template<typename T>
787 RepeatedField<T>* MutableRepeatedField( 639 RepeatedField<T>* MutableRepeatedField(
788 Message*, const FieldDescriptor*) const; 640 Message*, const FieldDescriptor*) const;
789 641
790 // DEPRECATED. Please use GetRepeatedFieldRef().
791 //
792 // for T = string, google::protobuf::internal::StringPieceField 642 // for T = string, google::protobuf::internal::StringPieceField
793 // google::protobuf::Message & descendants. 643 // google::protobuf::Message & descendants.
794 template<typename T> 644 template<typename T>
795 const RepeatedPtrField<T>& GetRepeatedPtrField( 645 const RepeatedPtrField<T>& GetRepeatedPtrField(
796 const Message&, const FieldDescriptor*) const; 646 const Message&, const FieldDescriptor*) const;
797 647
798 // DEPRECATED. Please use GetMutableRepeatedFieldRef().
799 //
800 // for T = string, google::protobuf::internal::StringPieceField 648 // for T = string, google::protobuf::internal::StringPieceField
801 // google::protobuf::Message & descendants. 649 // google::protobuf::Message & descendants.
802 template<typename T> 650 template<typename T>
803 RepeatedPtrField<T>* MutableRepeatedPtrField( 651 RepeatedPtrField<T>* MutableRepeatedPtrField(
804 Message*, const FieldDescriptor*) const; 652 Message*, const FieldDescriptor*) const;
805 653
806 // Extensions ---------------------------------------------------------------- 654 // Extensions ----------------------------------------------------------------
807 655
808 // Try to find an extension of this message type by fully-qualified field 656 // Try to find an extension of this message type by fully-qualified field
809 // name. Returns NULL if no extension is known for this name or number. 657 // name. Returns NULL if no extension is known for this name or number.
810 virtual const FieldDescriptor* FindKnownExtensionByName( 658 virtual const FieldDescriptor* FindKnownExtensionByName(
811 const string& name) const = 0; 659 const string& name) const = 0;
812 660
813 // Try to find an extension of this message type by field number. 661 // Try to find an extension of this message type by field number.
814 // Returns NULL if no extension is known for this name or number. 662 // Returns NULL if no extension is known for this name or number.
815 virtual const FieldDescriptor* FindKnownExtensionByNumber( 663 virtual const FieldDescriptor* FindKnownExtensionByNumber(
816 int number) const = 0; 664 int number) const = 0;
817 665
818 // Feature Flags -------------------------------------------------------------
819
820 // Does this message support storing arbitrary integer values in enum fields?
821 // If |true|, GetEnumValue/SetEnumValue and associated repeated-field versions
822 // take arbitrary integer values, and the legacy GetEnum() getter will
823 // dynamically create an EnumValueDescriptor for any integer value without
824 // one. If |false|, setting an unknown enum value via the integer-based
825 // setters results in undefined behavior (in practice, GOOGLE_DCHECK-fails).
826 //
827 // Generic code that uses reflection to handle messages with enum fields
828 // should check this flag before using the integer-based setter, and either
829 // downgrade to a compatible value or use the UnknownFieldSet if not. For
830 // example:
831 //
832 // int new_value = GetValueFromApplicationLogic();
833 // if (reflection->SupportsUnknownEnumValues()) {
834 // reflection->SetEnumValue(message, field, new_value);
835 // } else {
836 // if (field_descriptor->enum_type()->
837 // FindValueByNumver(new_value) != NULL) {
838 // reflection->SetEnumValue(message, field, new_value);
839 // } else if (emit_unknown_enum_values) {
840 // reflection->MutableUnknownFields(message)->AddVarint(
841 // field->number(),
842 // new_value);
843 // } else {
844 // // convert value to a compatible/default value.
845 // new_value = CompatibleDowngrade(new_value);
846 // reflection->SetEnumValue(message, field, new_value);
847 // }
848 // }
849 virtual bool SupportsUnknownEnumValues() const { return false; }
850
851 // Returns the MessageFactory associated with this message. This can be
852 // useful for determining if a message is a generated message or not, for
853 // example:
854 //
855 // if (message->GetReflection()->GetMessageFactory() ==
856 // google::protobuf::MessageFactory::generated_factory()) {
857 // // This is a generated message.
858 // }
859 //
860 // It can also be used to create more messages of this type, though
861 // Message::New() is an easier way to accomplish this.
862 virtual MessageFactory* GetMessageFactory() const;
863
864 // --------------------------------------------------------------------------- 666 // ---------------------------------------------------------------------------
865 667
866 protected: 668 protected:
867 // Obtain a pointer to a Repeated Field Structure and do some type checking: 669 // Obtain a pointer to a Repeated Field Structure and do some type checking:
868 // on field->cpp_type(), 670 // on field->cpp_type(),
869 // on field->field_option().ctype() (if ctype >= 0) 671 // on field->field_option().ctype() (if ctype >= 0)
870 // of field->message_type() (if message_type != NULL). 672 // of field->message_type() (if message_type != NULL).
871 // We use 1 routine rather than 4 (const vs mutable) x (scalar vs pointer). 673 // We use 1 routine rather than 4 (const vs mutable) x (scalar vs pointer).
872 virtual void* MutableRawRepeatedField( 674 virtual void* MutableRawRepeatedField(
873 Message* message, const FieldDescriptor* field, FieldDescriptor::CppType, 675 Message* message, const FieldDescriptor* field, FieldDescriptor::CppType,
874 int ctype, const Descriptor* message_type) const = 0; 676 int ctype, const Descriptor* message_type) const = 0;
875 677
876 // The following methods are used to implement (Mutable)RepeatedFieldRef.
877 // A Ref object will store a raw pointer to the repeated field data (obtained
878 // from RepeatedFieldData()) and a pointer to a Accessor (obtained from
879 // RepeatedFieldAccessor) which will be used to access the raw data.
880 //
881 // TODO(xiaofeng): Make these methods pure-virtual.
882
883 // Returns a raw pointer to the repeated field
884 //
885 // "cpp_type" and "message_type" are decuded from the type parameter T passed
886 // to Get(Mutable)RepeatedFieldRef. If T is a generated message type,
887 // "message_type" should be set to its descriptor. Otherwise "message_type"
888 // should be set to NULL. Implementations of this method should check whether
889 // "cpp_type"/"message_type" is consistent with the actual type of the field.
890 virtual void* RepeatedFieldData(
891 Message* message, const FieldDescriptor* field,
892 FieldDescriptor::CppType cpp_type,
893 const Descriptor* message_type) const;
894
895 // The returned pointer should point to a singleton instance which implements
896 // the RepeatedFieldAccessor interface.
897 virtual const internal::RepeatedFieldAccessor* RepeatedFieldAccessor(
898 const FieldDescriptor* field) const;
899
900 private: 678 private:
901 template<typename T, typename Enable>
902 friend class RepeatedFieldRef;
903 template<typename T, typename Enable>
904 friend class MutableRepeatedFieldRef;
905
906 // Special version for specialized implementations of string. We can't call 679 // Special version for specialized implementations of string. We can't call
907 // MutableRawRepeatedField directly here because we don't have access to 680 // MutableRawRepeatedField directly here because we don't have access to
908 // FieldOptions::* which are defined in descriptor.pb.h. Including that 681 // FieldOptions::* which are defined in descriptor.pb.h. Including that
909 // file here is not possible because it would cause a circular include cycle. 682 // file here is not possible because it would cause a circular include cycle.
910 void* MutableRawRepeatedString( 683 void* MutableRawRepeatedString(
911 Message* message, const FieldDescriptor* field, bool is_string) const; 684 Message* message, const FieldDescriptor* field, bool is_string) const;
912 685
913 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reflection); 686 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reflection);
914 }; 687 };
915 688
916 // Abstract interface for a factory for message objects. 689 // Abstract interface for a factory for message objects.
917 class LIBPROTOBUF_EXPORT MessageFactory { 690 class LIBPROTOBUF_EXPORT MessageFactory {
918 public: 691 public:
919 inline MessageFactory() {} 692 inline MessageFactory() {}
920 virtual ~MessageFactory(); 693 virtual ~MessageFactory();
921 694
922 // Given a Descriptor, gets or constructs the default (prototype) Message 695 // Given a Descriptor, gets or constructs the default (prototype) Message
923 // of that type. You can then call that message's New() method to construct 696 // of that type. You can then call that message's New() method to construct
924 // a mutable message of that type. 697 // a mutable message of that type.
925 // 698 //
926 // Calling this method twice with the same Descriptor returns the same 699 // Calling this method twice with the same Descriptor returns the same
927 // object. The returned object remains property of the factory. Also, any 700 // object. The returned object remains property of the factory. Also, any
928 // objects created by calling the prototype's New() method share some data 701 // objects created by calling the prototype's New() method share some data
929 // with the prototype, so these must be destroyed before the MessageFactory 702 // with the prototype, so these must be destoyed before the MessageFactory
930 // is destroyed. 703 // is destroyed.
931 // 704 //
932 // The given descriptor must outlive the returned message, and hence must 705 // The given descriptor must outlive the returned message, and hence must
933 // outlive the MessageFactory. 706 // outlive the MessageFactory.
934 // 707 //
935 // Some implementations do not support all types. GetPrototype() will 708 // Some implementations do not support all types. GetPrototype() will
936 // return NULL if the descriptor passed in is not supported. 709 // return NULL if the descriptor passed in is not supported.
937 // 710 //
938 // This method may or may not be thread-safe depending on the implementation. 711 // This method may or may not be thread-safe depending on the implementation.
939 // Each implementation should document its own degree thread-safety. 712 // Each implementation should document its own degree thread-safety.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 } 823 }
1051 824
1052 template<typename PB> 825 template<typename PB>
1053 inline RepeatedPtrField<PB>* Reflection::MutableRepeatedPtrField( 826 inline RepeatedPtrField<PB>* Reflection::MutableRepeatedPtrField(
1054 Message* message, const FieldDescriptor* field) const { 827 Message* message, const FieldDescriptor* field) const {
1055 return static_cast<RepeatedPtrField<PB>* >( 828 return static_cast<RepeatedPtrField<PB>* >(
1056 MutableRawRepeatedField(message, field, 829 MutableRawRepeatedField(message, field,
1057 FieldDescriptor::CPPTYPE_MESSAGE, -1, 830 FieldDescriptor::CPPTYPE_MESSAGE, -1,
1058 PB::default_instance().GetDescriptor())); 831 PB::default_instance().GetDescriptor()));
1059 } 832 }
833
1060 } // namespace protobuf 834 } // namespace protobuf
1061 835
1062 } // namespace google 836 } // namespace google
1063 #endif // GOOGLE_PROTOBUF_MESSAGE_H__ 837 #endif // GOOGLE_PROTOBUF_MESSAGE_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698