aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/message_lite.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/message_lite.h')
-rw-r--r--src/google/protobuf/message_lite.h40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h
index 5cd6babc..4cbec330 100644
--- a/src/google/protobuf/message_lite.h
+++ b/src/google/protobuf/message_lite.h
@@ -43,11 +43,13 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/once.h>
+#include <google/protobuf/arena.h>
#include <google/protobuf/stubs/port.h>
namespace google {
namespace protobuf {
-class Arena;
+template <typename T>
+class RepeatedPtrField;
namespace io {
class CodedInputStream;
class CodedOutputStream;
@@ -56,7 +58,9 @@ class ZeroCopyOutputStream;
}
namespace internal {
+class RepeatedPtrFieldBase;
class WireFormatLite;
+class WeakFieldMap;
#ifndef SWIG
// We compute sizes as size_t but cache them as int. This function converts a
@@ -110,13 +114,7 @@ class ExplicitlyConstructed {
get_mutable()->~T();
}
-#if LANG_CXX11
- constexpr
-#endif
- const T&
- get() const {
- return reinterpret_cast<const T&>(union_);
- }
+ constexpr const T& get() const { return reinterpret_cast<const T&>(union_); }
T* get_mutable() { return reinterpret_cast<T*>(&union_); }
private:
@@ -130,7 +128,7 @@ class ExplicitlyConstructed {
// Default empty string object. Don't use this directly. Instead, call
// GetEmptyString() to get the reference.
-extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string;
+LIBPROTOBUF_EXPORT extern ExplicitlyConstructed<::std::string> fixed_address_empty_string;
LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_;
LIBPROTOBUF_EXPORT void InitEmptyString();
@@ -271,7 +269,7 @@ class LIBPROTOBUF_EXPORT MessageLite {
// Reads a protocol buffer from the stream and merges it into this
- // Message. Singular fields read from the input overwrite what is
+ // Message. Singular fields read from the what is
// already in the Message and repeated fields are appended to those
// already present.
//
@@ -380,12 +378,34 @@ class LIBPROTOBUF_EXPORT MessageLite {
virtual uint8* InternalSerializeWithCachedSizesToArray(bool deterministic,
uint8* target) const;
+ protected:
+ // CastToBase allows generated code to cast a RepeatedPtrField<T> to
+ // RepeatedPtrFieldBase. We try to restrict access to RepeatedPtrFieldBase
+ // because it is an implementation detail that user code should not access
+ // directly.
+ template <typename T>
+ static ::google::protobuf::internal::RepeatedPtrFieldBase* CastToBase(
+ ::google::protobuf::RepeatedPtrField<T>* repeated) {
+ return repeated;
+ }
+ template <typename T>
+ static const ::google::protobuf::internal::RepeatedPtrFieldBase& CastToBase(
+ const ::google::protobuf::RepeatedPtrField<T>& repeated) {
+ return repeated;
+ }
+
+ template <typename T>
+ static T* CreateMaybeMessage(Arena* arena) {
+ return Arena::CreateMaybeMessage<T>(arena);
+ }
+
private:
// TODO(gerbens) make this a pure abstract function
virtual const void* InternalGetTable() const { return NULL; }
friend class internal::WireFormatLite;
friend class Message;
+ friend class internal::WeakFieldMap;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageLite);
};