Index: third_party/protobuf/src/google/protobuf/generated_message_util.h |
diff --git a/third_party/protobuf/src/google/protobuf/generated_message_util.h b/third_party/protobuf/src/google/protobuf/generated_message_util.h |
index 6e4669c271a858c3a0028f7e2447cbf6c90889b7..813fb43dfb21d39d02c819e7646e7a5f2b5442b9 100644 |
--- a/third_party/protobuf/src/google/protobuf/generated_message_util.h |
+++ b/third_party/protobuf/src/google/protobuf/generated_message_util.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 |
@@ -38,14 +38,22 @@ |
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__ |
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__ |
+#include <assert.h> |
#include <string> |
-#include <google/protobuf/stubs/common.h> |
#include <google/protobuf/stubs/once.h> |
+ |
+#include <google/protobuf/stubs/common.h> |
namespace google { |
+ |
namespace protobuf { |
+ |
+class Arena; |
+namespace io { class CodedInputStream; } |
+ |
namespace internal { |
+ |
// Annotation for the compiler to emit a deprecation message if a field marked |
// with option 'deprecated=true' is used in the code, or for other things in |
// generated code which are deprecated. |
@@ -60,23 +68,49 @@ namespace internal { |
LIBPROTOBUF_EXPORT double Infinity(); |
LIBPROTOBUF_EXPORT double NaN(); |
+// TODO(jieluo): Change to template. We have tried to use template, |
+// but it causes net/rpc/python:rpcutil_test fail (the empty string will |
+// init twice). It may related to swig. Change to template after we |
+// found the solution. |
+ |
// Default empty string object. Don't use the pointer directly. Instead, call |
// GetEmptyString() to get the reference. |
LIBPROTOBUF_EXPORT extern const ::std::string* empty_string_; |
LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_; |
- |
LIBPROTOBUF_EXPORT void InitEmptyString(); |
+ |
+LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() { |
+ assert(empty_string_ != NULL); |
+ return *empty_string_; |
+} |
+ |
LIBPROTOBUF_EXPORT const ::std::string& GetEmptyString(); |
-// Defined in generated_message_reflection.cc -- not actually part of the lite |
-// library. |
-// |
-// TODO(jasonh): The various callers get this declaration from a variety of |
-// places: probably in most cases repeated_field.h. Clean these up so they all |
-// get the declaration from this file. |
LIBPROTOBUF_EXPORT int StringSpaceUsedExcludingSelf(const string& str); |
+ |
+// True if IsInitialized() is true for all elements of t. Type is expected |
+// to be a RepeatedPtrField<some message type>. It's useful to have this |
+// helper here to keep the protobuf compiler from ever having to emit loops in |
+// IsInitialized() methods. We want the C++ compiler to inline this or not |
+// as it sees fit. |
+template <class Type> bool AllAreInitialized(const Type& t) { |
+ for (int i = t.size(); --i >= 0; ) { |
+ if (!t.Get(i).IsInitialized()) return false; |
+ } |
+ return true; |
+} |
+ |
+class ArenaString; |
+ |
+// Read a length (varint32), followed by a string, from *input. Return a |
+// pointer to a copy of the string that resides in *arena. Requires both |
+// args to be non-NULL. If something goes wrong while reading the data |
+// then NULL is returned (e.g., input does not start with a valid varint). |
+ArenaString* ReadArenaString(::google::protobuf::io::CodedInputStream* input, |
+ ::google::protobuf::Arena* arena); |
+ |
} // namespace internal |
} // namespace protobuf |