aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/message.h
diff options
context:
space:
mode:
authorGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2009-12-18 02:11:36 +0000
committerGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2009-12-18 02:11:36 +0000
commitfccb146e3fe437b0df1e9c50d4b8e1080ddb4bd9 (patch)
tree9f2d9fe0267d96a54e541377ffeada3d0bff0d1d /src/google/protobuf/message.h
parentd5cf7b55a6a1f959d1646785f63ca2b62da78079 (diff)
Massive roll-up of changes. See CHANGES.txt.
Diffstat (limited to 'src/google/protobuf/message.h')
-rw-r--r--src/google/protobuf/message.h28
1 files changed, 23 insertions, 5 deletions
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 ------------------------------------------------------