aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/any.h
diff options
context:
space:
mode:
authorJisi Liu <jisi.liu@gmail.com>2016-03-30 11:39:59 -0700
committerJisi Liu <jisi.liu@gmail.com>2016-03-30 11:39:59 -0700
commit3b3c8abb9635eb3ea078a821a99c9ef29d66dff7 (patch)
tree7d2ec154f15c9f9153d890e76b6cf30e471ea488 /src/google/protobuf/any.h
parent78105897a8f01c7be9cf8502b6c58d47eb1ccdd7 (diff)
downloadprotobuf-3b3c8abb9635eb3ea078a821a99c9ef29d66dff7.tar.gz
protobuf-3b3c8abb9635eb3ea078a821a99c9ef29d66dff7.tar.bz2
protobuf-3b3c8abb9635eb3ea078a821a99c9ef29d66dff7.zip
Integrate google internal changes.
Diffstat (limited to 'src/google/protobuf/any.h')
-rw-r--r--src/google/protobuf/any.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/google/protobuf/any.h b/src/google/protobuf/any.h
index c8dbef13..04e54166 100644
--- a/src/google/protobuf/any.h
+++ b/src/google/protobuf/any.h
@@ -50,10 +50,26 @@ class LIBPROTOBUF_EXPORT AnyMetadata {
// AnyMetadata does not take ownership of "type_url" and "value".
AnyMetadata(UrlType* type_url, ValueType* value);
+ // Packs a message using the default type URL prefix: "type.googleapis.com".
+ // The resulted type URL will be "type.googleapis.com/<message_full_name>".
void PackFrom(const Message& message);
-
+ // Packs a message using the given type URL prefix. The type URL will be
+ // constructed by concatenating the message type's full name to the prefix
+ // with an optional "/" separator if the prefix doesn't already end up "/".
+ // For example, both PackFrom(message, "type.googleapis.com") and
+ // PackFrom(message, "type.googleapis.com/") yield the same result type
+ // URL: "type.googleapis.com/<message_full_name>".
+ void PackFrom(const Message& message, const string& type_url_prefix);
+
+ // Unpacks the payload into the given message. Returns false if the message's
+ // type doesn't match the type specified in the type URL (i.e., the full
+ // name after the last "/" of the type URL doesn't match the message's actaul
+ // full name) or parsing the payload has failed.
bool UnpackTo(Message* message) const;
+ // Checks whether the type specified in the type URL matches the given type.
+ // A type is consdiered matching if its full name matches the full name after
+ // the last "/" in the type URL.
template<typename T>
bool Is() const {
return InternalIs(T::default_instance().GetDescriptor());