From 885b612f74f133678bf82808c589331e4c59dad9 Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Sat, 28 Feb 2015 14:51:22 -0800 Subject: Down integrate from Google internal branch for C++ and Java. - Maps for C++ lite - C++ Arena optimizations. - Java Lite runtime code size optimization. Change-Id: I7537a4357c1cb385d23f9e8aa7ffdfeefe079f13 --- src/google/protobuf/message.h | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/google/protobuf/message.h') diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index a200bc92..6e1929e5 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -208,7 +208,7 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite { // This is much, much slower than IsInitialized() as it is implemented // purely via reflection. Generally, you should not call this unless you // have already determined that an error exists by calling IsInitialized(). - void FindInitializationErrors(vector* errors) const; + void FindInitializationErrors(std::vector* errors) const; // Like FindInitializationErrors, but joins all the strings, delimited by // commas, and returns them. @@ -456,7 +456,7 @@ class LIBPROTOBUF_EXPORT Reflection { // Swap fields listed in fields vector of two messages. virtual void SwapFields(Message* message1, Message* message2, - const vector& fields) + const std::vector& fields) const = 0; // Swap two elements of a repeated field. @@ -470,8 +470,9 @@ class LIBPROTOBUF_EXPORT Reflection { // return true and repeated fields will only be listed if FieldSize(field) // would return non-zero. Fields (both normal fields and extension fields) // will be listed ordered by field number. - virtual void ListFields(const Message& message, - vector* output) const = 0; + virtual void ListFields( + const Message& message, + std::vector* output) const = 0; // Singular field getters ------------------------------------------ // These get the value of a non-repeated field. They return the default @@ -523,7 +524,7 @@ class LIBPROTOBUF_EXPORT Reflection { // regardless of the field's underlying representation. When initializing // a newly-constructed string, though, it's just as fast and more readable // to use code like: - // string str = reflection->GetString(field); + // string str = reflection->GetString(message, field); virtual const string& GetStringReference(const Message& message, const FieldDescriptor* field, string* scratch) const = 0; @@ -842,6 +843,19 @@ class LIBPROTOBUF_EXPORT Reflection { // } virtual bool SupportsUnknownEnumValues() const { return false; } + // Returns the MessageFactory associated with this message. This can be + // useful for determining if a message is a generated message or not, for + // example: + // + // if (message->GetReflection()->GetMessageFactory() == + // google::protobuf::MessageFactory::generated_factory()) { + // // This is a generated message. + // } + // + // It can also be used to create more messages of this type, though + // Message::New() is an easier way to accomplish this. + virtual MessageFactory* GetMessageFactory() const; + // --------------------------------------------------------------------------- protected: @@ -854,8 +868,6 @@ class LIBPROTOBUF_EXPORT Reflection { Message* message, const FieldDescriptor* field, FieldDescriptor::CppType, int ctype, const Descriptor* message_type) const = 0; - virtual MessageFactory* GetMessageFactory() const; - // The following methods are used to implement (Mutable)RepeatedFieldRef. // A Ref object will store a raw pointer to the repeated field data (obtained // from RepeatedFieldData()) and a pointer to a Accessor (obtained from -- cgit v1.2.3