Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Unified Diff: third_party/protobuf/src/google/protobuf/any.h

Issue 1842653006: Update //third_party/protobuf to version 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/protobuf/src/google/protobuf/SEBS ('k') | third_party/protobuf/src/google/protobuf/any.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/protobuf/src/google/protobuf/any.h
diff --git a/third_party/protobuf/src/google/protobuf/reflection_ops.h b/third_party/protobuf/src/google/protobuf/any.h
similarity index 51%
copy from third_party/protobuf/src/google/protobuf/reflection_ops.h
copy to third_party/protobuf/src/google/protobuf/any.h
index 60165c2a65ef3d443cd6c08c13fa6bf37a4e924e..c8dbef1301c105398e82538faf6d42f797848576 100644
--- a/third_party/protobuf/src/google/protobuf/reflection_ops.h
+++ b/third_party/protobuf/src/google/protobuf/any.h
@@ -1,6 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
-// http://code.google.com/p/protobuf/
+// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -28,54 +28,64 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Author: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// This header is logically internal, but is made public because it is used
-// from protocol-compiler-generated code, which may reside in other components.
+#ifndef GOOGLE_PROTOBUF_ANY_H__
+#define GOOGLE_PROTOBUF_ANY_H__
-#ifndef GOOGLE_PROTOBUF_REFLECTION_OPS_H__
-#define GOOGLE_PROTOBUF_REFLECTION_OPS_H__
+#include <string>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/descriptor.h>
#include <google/protobuf/message.h>
+#include <google/protobuf/arenastring.h>
namespace google {
namespace protobuf {
namespace internal {
-// Basic operations that can be performed using reflection.
-// These can be used as a cheap way to implement the corresponding
-// methods of the Message interface, though they are likely to be
-// slower than implementations tailored for the specific message type.
-//
-// This class should stay limited to operations needed to implement
-// the Message interface.
-//
-// This class is really a namespace that contains only static methods.
-class LIBPROTOBUF_EXPORT ReflectionOps {
+// Helper class used to implement google::protobuf::Any.
+class LIBPROTOBUF_EXPORT AnyMetadata {
+ typedef ArenaStringPtr UrlType;
+ typedef ArenaStringPtr ValueType;
public:
- static void Copy(const Message& from, Message* to);
- static void Merge(const Message& from, Message* to);
- static void Clear(Message* message);
- static bool IsInitialized(const Message& message);
- static void DiscardUnknownFields(Message* message);
-
- // Finds all unset required fields in the message and adds their full
- // paths (e.g. "foo.bar[5].baz") to *names. "prefix" will be attached to
- // the front of each name.
- static void FindInitializationErrors(const Message& message,
- const string& prefix,
- vector<string>* errors);
+ // AnyMetadata does not take ownership of "type_url" and "value".
+ AnyMetadata(UrlType* type_url, ValueType* value);
+
+ void PackFrom(const Message& message);
+
+ bool UnpackTo(Message* message) const;
+
+ template<typename T>
+ bool Is() const {
+ return InternalIs(T::default_instance().GetDescriptor());
+ }
private:
- // All methods are static. No need to construct.
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionOps);
+ bool InternalIs(const Descriptor* message) const;
+
+ UrlType* type_url_;
+ ValueType* value_;
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(AnyMetadata);
};
+extern const char kAnyFullTypeName[]; // "google.protobuf.Any".
+extern const char kTypeGoogleApisComPrefix[]; // "type.googleapis.com/".
+extern const char kTypeGoogleProdComPrefix[]; // "type.googleprod.com/".
+
+// Get the proto type name from Any::type_url value. For example, passing
+// "type.googleapis.com/rpc.QueryOrigin" will return "rpc.QueryOrigin" in
+// *full_type_name. Returns false if type_url does not start with
+// "type.googleapis.com" or "type.googleprod.com".
+bool ParseAnyTypeUrl(const string& type_url, string* full_type_name);
+
+// See if message is of type google.protobuf.Any, if so, return the descriptors
+// for "type_url" and "value" fields.
+bool GetAnyFieldDescriptors(const Message& message,
+ const FieldDescriptor** type_url_field,
+ const FieldDescriptor** value_field);
+
} // namespace internal
} // namespace protobuf
} // namespace google
-#endif // GOOGLE_PROTOBUF_REFLECTION_OPS_H__
+#endif // GOOGLE_PROTOBUF_ANY_H__
« no previous file with comments | « third_party/protobuf/src/google/protobuf/SEBS ('k') | third_party/protobuf/src/google/protobuf/any.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698