aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/message.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/message.h')
-rw-r--r--src/google/protobuf/message.h89
1 files changed, 46 insertions, 43 deletions
diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h
index 007dafa2..9f44132b 100644
--- a/src/google/protobuf/message.h
+++ b/src/google/protobuf/message.h
@@ -163,8 +163,13 @@ namespace expr {
class CelMapReflectionFriend; // field_backed_map_impl.cc
}
+namespace internal {
+class MapFieldPrinterHelper; // text_format.cc
+}
+
namespace internal {
+class ReflectionAccessor; // message.cc
class ReflectionOps; // reflection_ops.h
class MapKeySorter; // wire_format.cc
class WireFormat; // wire_format.h
@@ -193,7 +198,7 @@ struct Metadata {
// optimized for speed will want to override these with faster implementations,
// but classes optimized for code size may be happy with keeping them. See
// the optimize_for option in descriptor.proto.
-class LIBPROTOBUF_EXPORT Message : public MessageLite {
+class PROTOBUF_EXPORT Message : public MessageLite {
public:
inline Message() {}
virtual ~Message() {}
@@ -236,11 +241,11 @@ 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(std::vector<string>* errors) const;
+ void FindInitializationErrors(std::vector<std::string>* errors) const;
// Like FindInitializationErrors, but joins all the strings, delimited by
// commas, and returns them.
- string InitializationErrorString() const override;
+ std::string InitializationErrorString() const override;
// Clears all unknown fields from this message and all embedded messages.
// Normally, if unknown tag numbers are encountered when parsing a message,
@@ -264,18 +269,18 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite {
// fields defined for the proto.
virtual size_t SpaceUsedLong() const;
- GOOGLE_PROTOBUF_DEPRECATED_MSG("Please use SpaceUsedLong() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use SpaceUsedLong() instead")
int SpaceUsed() const { return internal::ToIntSize(SpaceUsedLong()); }
// Debugging & Testing----------------------------------------------
// Generates a human readable form of this message, useful for debugging
// and other purposes.
- string DebugString() const;
+ std::string DebugString() const;
// Like DebugString(), but with less whitespace.
- string ShortDebugString() const;
+ std::string ShortDebugString() const;
// Like DebugString(), but do not escape UTF-8 byte sequences.
- string Utf8DebugString() const;
+ std::string Utf8DebugString() const;
// Convenience function useful in GDB. Prints DebugString() to stdout.
void PrintDebugString() const;
@@ -312,7 +317,7 @@ class LIBPROTOBUF_EXPORT Message : public MessageLite {
// These methods are pure-virtual in MessageLite, but Message provides
// reflection-based default implementations.
- string GetTypeName() const override;
+ std::string GetTypeName() const override;
void Clear() override;
bool IsInitialized() const override;
void CheckTypeAndMergeFrom(const MessageLite& other) override;
@@ -424,7 +429,7 @@ class MutableRepeatedFieldRef;
// double the message's memory footprint, probably worse. Allocating the
// objects on-demand, on the other hand, would be expensive and prone to
// memory leaks. So, instead we ended up with this flat interface.
-class LIBPROTOBUF_EXPORT Reflection {
+class PROTOBUF_EXPORT Reflection {
public:
inline Reflection() {}
virtual ~Reflection();
@@ -445,7 +450,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// Estimate the amount of memory used by the message object.
virtual size_t SpaceUsedLong(const Message& message) const = 0;
- GOOGLE_PROTOBUF_DEPRECATED_MSG("Please use SpaceUsedLong() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use SpaceUsedLong() instead")
int SpaceUsed(const Message& message) const {
return internal::ToIntSize(SpaceUsedLong(message));
}
@@ -542,7 +547,7 @@ class LIBPROTOBUF_EXPORT Reflection {
const FieldDescriptor* field) const = 0;
virtual bool GetBool (const Message& message,
const FieldDescriptor* field) const = 0;
- virtual string GetString(const Message& message,
+ virtual std::string GetString(const Message& message,
const FieldDescriptor* field) const = 0;
virtual const EnumValueDescriptor* GetEnum(
const Message& message, const FieldDescriptor* field) const = 0;
@@ -575,9 +580,9 @@ class LIBPROTOBUF_EXPORT Reflection {
// a newly-constructed string, though, it's just as fast and more readable
// to use code like:
// string str = reflection->GetString(message, field);
- virtual const string& GetStringReference(const Message& message,
+ virtual const std::string& GetStringReference(const Message& message,
const FieldDescriptor* field,
- string* scratch) const = 0;
+ std::string* scratch) const = 0;
// Singular field mutators -----------------------------------------
@@ -599,7 +604,7 @@ class LIBPROTOBUF_EXPORT Reflection {
const FieldDescriptor* field, bool value) const = 0;
virtual void SetString(Message* message,
const FieldDescriptor* field,
- const string& value) const = 0;
+ const std::string& value) const = 0;
virtual void SetEnum (Message* message,
const FieldDescriptor* field,
const EnumValueDescriptor* value) const = 0;
@@ -670,7 +675,7 @@ class LIBPROTOBUF_EXPORT Reflection {
virtual bool GetRepeatedBool (const Message& message,
const FieldDescriptor* field,
int index) const = 0;
- virtual string GetRepeatedString(const Message& message,
+ virtual std::string GetRepeatedString(const Message& message,
const FieldDescriptor* field,
int index) const = 0;
virtual const EnumValueDescriptor* GetRepeatedEnum(
@@ -689,9 +694,9 @@ class LIBPROTOBUF_EXPORT Reflection {
const FieldDescriptor* field, int index) const = 0;
// See GetStringReference(), above.
- virtual const string& GetRepeatedStringReference(
+ virtual const std::string& GetRepeatedStringReference(
const Message& message, const FieldDescriptor* field,
- int index, string* scratch) const = 0;
+ int index, std::string* scratch) const = 0;
// Repeated field mutators -----------------------------------------
@@ -720,7 +725,7 @@ class LIBPROTOBUF_EXPORT Reflection {
int index, bool value) const = 0;
virtual void SetRepeatedString(Message* message,
const FieldDescriptor* field,
- int index, const string& value) const = 0;
+ int index, const std::string& value) const = 0;
virtual void SetRepeatedEnum(Message* message,
const FieldDescriptor* field, int index,
const EnumValueDescriptor* value) const = 0;
@@ -759,7 +764,7 @@ class LIBPROTOBUF_EXPORT Reflection {
const FieldDescriptor* field, bool value) const = 0;
virtual void AddString(Message* message,
const FieldDescriptor* field,
- const string& value) const = 0;
+ const std::string& value) const = 0;
virtual void AddEnum (Message* message,
const FieldDescriptor* field,
const EnumValueDescriptor* value) const = 0;
@@ -839,8 +844,7 @@ class LIBPROTOBUF_EXPORT Reflection {
//
// for T = Cord and all protobuf scalar types except enums.
template <typename T>
- GOOGLE_PROTOBUF_DEPRECATED_MSG(
- "Please use GetRepeatedFieldRef() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use GetRepeatedFieldRef() instead")
const RepeatedField<T>& GetRepeatedField(const Message&,
const FieldDescriptor*) const;
@@ -848,8 +852,7 @@ class LIBPROTOBUF_EXPORT Reflection {
//
// for T = Cord and all protobuf scalar types except enums.
template <typename T>
- GOOGLE_PROTOBUF_DEPRECATED_MSG(
- "Please use GetMutableRepeatedFieldRef() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use GetMutableRepeatedFieldRef() instead")
RepeatedField<T>* MutableRepeatedField(Message*,
const FieldDescriptor*) const;
@@ -858,8 +861,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// for T = string, google::protobuf::internal::StringPieceField
// google::protobuf::Message & descendants.
template <typename T>
- GOOGLE_PROTOBUF_DEPRECATED_MSG(
- "Please use GetRepeatedFieldRef() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use GetRepeatedFieldRef() instead")
const RepeatedPtrField<T>& GetRepeatedPtrField(const Message&,
const FieldDescriptor*) const;
@@ -868,8 +870,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// for T = string, google::protobuf::internal::StringPieceField
// google::protobuf::Message & descendants.
template <typename T>
- GOOGLE_PROTOBUF_DEPRECATED_MSG(
- "Please use GetMutableRepeatedFieldRef() instead")
+ PROTOBUF_DEPRECATED_MSG("Please use GetMutableRepeatedFieldRef() instead")
RepeatedPtrField<T>* MutableRepeatedPtrField(Message*,
const FieldDescriptor*) const;
@@ -878,7 +879,7 @@ class LIBPROTOBUF_EXPORT Reflection {
// Try to find an extension of this message type by fully-qualified field
// name. Returns NULL if no extension is known for this name or number.
virtual const FieldDescriptor* FindKnownExtensionByName(
- const string& name) const = 0;
+ const std::string& name) const = 0;
// Try to find an extension of this message type by field number.
// Returns NULL if no extension is known for this name or number.
@@ -987,6 +988,9 @@ class LIBPROTOBUF_EXPORT Reflection {
friend class internal::MapKeySorter;
friend class internal::WireFormat;
friend class internal::ReflectionOps;
+ // Needed for implementing text format for map.
+ friend class internal::MapFieldPrinterHelper;
+ friend class internal::ReflectionAccessor;
// Special version for specialized implementations of string. We can't call
// MutableRawRepeatedField directly here because we don't have access to
@@ -1057,7 +1061,7 @@ class LIBPROTOBUF_EXPORT Reflection {
};
// Abstract interface for a factory for message objects.
-class LIBPROTOBUF_EXPORT MessageFactory {
+class PROTOBUF_EXPORT MessageFactory {
public:
inline MessageFactory() {}
virtual ~MessageFactory();
@@ -1120,16 +1124,15 @@ class LIBPROTOBUF_EXPORT MessageFactory {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFactory);
};
-#define DECLARE_GET_REPEATED_FIELD(TYPE) \
-template<> \
-LIBPROTOBUF_EXPORT \
-const RepeatedField<TYPE>& Reflection::GetRepeatedField<TYPE>( \
- const Message& message, const FieldDescriptor* field) const; \
- \
-template<> \
-LIBPROTOBUF_EXPORT \
-RepeatedField<TYPE>* Reflection::MutableRepeatedField<TYPE>( \
- Message* message, const FieldDescriptor* field) const;
+#define DECLARE_GET_REPEATED_FIELD(TYPE) \
+ template <> \
+ PROTOBUF_EXPORT const RepeatedField<TYPE>& \
+ Reflection::GetRepeatedField<TYPE>(const Message& message, \
+ const FieldDescriptor* field) const; \
+ \
+ template <> \
+ PROTOBUF_EXPORT RepeatedField<TYPE>* Reflection::MutableRepeatedField<TYPE>( \
+ Message * message, const FieldDescriptor* field) const;
DECLARE_GET_REPEATED_FIELD(int32)
DECLARE_GET_REPEATED_FIELD(int64)
@@ -1196,16 +1199,16 @@ T dynamic_cast_if_available(Message* from) {
// Such a type presumably is a descendant of google::protobuf::Message.
template<>
-inline const RepeatedPtrField<string>& Reflection::GetRepeatedPtrField<string>(
+inline const RepeatedPtrField<std::string>& Reflection::GetRepeatedPtrField<std::string>(
const Message& message, const FieldDescriptor* field) const {
- return *static_cast<RepeatedPtrField<string>* >(
+ return *static_cast<RepeatedPtrField<std::string>* >(
MutableRawRepeatedString(const_cast<Message*>(&message), field, true));
}
template<>
-inline RepeatedPtrField<string>* Reflection::MutableRepeatedPtrField<string>(
+inline RepeatedPtrField<std::string>* Reflection::MutableRepeatedPtrField<std::string>(
Message* message, const FieldDescriptor* field) const {
- return static_cast<RepeatedPtrField<string>* >(
+ return static_cast<RepeatedPtrField<std::string>* >(
MutableRawRepeatedString(message, field, true));
}