diff options
Diffstat (limited to 'src/google/protobuf/generated_message_util.h')
-rw-r--r-- | src/google/protobuf/generated_message_util.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h index 8ebfc13b..cd74b45e 100644 --- a/src/google/protobuf/generated_message_util.h +++ b/src/google/protobuf/generated_message_util.h @@ -47,6 +47,7 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/once.h> #include <google/protobuf/has_bits.h> +#include <google/protobuf/implicit_weak_message.h> #include <google/protobuf/map_entry_lite.h> #include <google/protobuf/message_lite.h> #include <google/protobuf/wire_format_lite.h> @@ -120,6 +121,21 @@ template <class Type> bool AllAreInitialized(const Type& t) { return true; } +// "Weak" variant of AllAreInitialized, used to implement implicit weak fields. +// This version operates on MessageLite to avoid introducing a dependency on the +// concrete message type. +template <class T> +bool AllAreInitializedWeak(const ::google::protobuf::RepeatedPtrField<T>& t) { + for (int i = t.size(); --i >= 0;) { + if (!reinterpret_cast<const ::google::protobuf::internal::RepeatedPtrFieldBase&>(t) + .Get< ::google::protobuf::internal::ImplicitWeakTypeHandler<T> >(i) + .IsInitialized()) { + return false; + } + } + return true; +} + LIBPROTOBUF_EXPORT void InitProtobufDefaults(); struct LIBPROTOBUF_EXPORT FieldMetadata { |