From fccb146e3fe437b0df1e9c50d4b8e1080ddb4bd9 Mon Sep 17 00:00:00 2001 From: "kenton@google.com" Date: Fri, 18 Dec 2009 02:11:36 +0000 Subject: Massive roll-up of changes. See CHANGES.txt. --- src/google/protobuf/message.h | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/google/protobuf/message.h') diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index 54b596d5..c0062f98 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -148,6 +148,7 @@ namespace protobuf { // Defined in this file. class Message; class Reflection; +class MessageFactory; // Defined in other files. class Descriptor; // descriptor.h @@ -238,13 +239,15 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite { // Reflection object's SpaceUsed() method. virtual int SpaceUsed() const; - // Debugging ------------------------------------------------------- + // Debugging & Testing---------------------------------------------- // Generates a human readable form of this message, useful for debugging // and other purposes. string DebugString() const; // Like DebugString(), but with less whitespace. string ShortDebugString() const; + // Like DebugString(), but do not escape UTF-8 byte sequences. + string Utf8DebugString() const; // Convenience function useful in GDB. Prints DebugString() to stdout. void PrintDebugString() const; @@ -327,6 +330,7 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite { // GetReflection() wrappers. virtual Metadata GetMetadata() const = 0; + private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Message); }; @@ -453,8 +457,10 @@ class LIBPROTOBUF_EXPORT Reflection { const FieldDescriptor* field) const = 0; virtual const EnumValueDescriptor* GetEnum( const Message& message, const FieldDescriptor* field) const = 0; + // See MutableMessage() for the meaning of the "factory" parameter. virtual const Message& GetMessage(const Message& message, - const FieldDescriptor* field) const = 0; + const FieldDescriptor* field, + MessageFactory* factory = NULL) const = 0; // Get a string value without copying, if possible. // @@ -499,9 +505,19 @@ class LIBPROTOBUF_EXPORT Reflection { virtual void SetEnum (Message* message, const FieldDescriptor* field, const EnumValueDescriptor* value) const = 0; - // Get a mutable pointer to a field with a message type. + // Get a mutable pointer to a field with a message type. If a MessageFactory + // is provided, it will be used to construct instances of the sub-message; + // otherwise, the default factory is used. If the field is an extension that + // does not live in the same pool as the containing message's descriptor (e.g. + // it lives in an overlay pool), then a MessageFactory must be provided. + // If you have no idea what that meant, then you probably don't need to worry + // about it (don't provide a MessageFactory). WARNING: If the + // FieldDescriptor is for a compiled-in extension, then + // factory->GetPrototype(field->message_type() MUST return an instance of the + // compiled-in class for this type, NOT DynamicMessage. virtual Message* MutableMessage(Message* message, - const FieldDescriptor* field) const = 0; + const FieldDescriptor* field, + MessageFactory* factory = NULL) const = 0; // Repeated field getters ------------------------------------------ @@ -603,8 +619,10 @@ class LIBPROTOBUF_EXPORT Reflection { virtual void AddEnum (Message* message, const FieldDescriptor* field, const EnumValueDescriptor* value) const = 0; + // See MutableMessage() for comments on the "factory" parameter. virtual Message* AddMessage(Message* message, - const FieldDescriptor* field) const = 0; + const FieldDescriptor* field, + MessageFactory* factory = NULL) const = 0; // Extensions ------------------------------------------------------ -- cgit v1.2.3