From 6bbe197e9c1b6fc38cbdc45e3bf83fa7ced792a3 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Wed, 8 Aug 2018 17:00:41 -0700 Subject: Down-integrate from google3. --- src/google/protobuf/message_lite.h | 81 +++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 31 deletions(-) (limited to 'src/google/protobuf/message_lite.h') diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index b8644142..2e83a8a7 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -40,29 +40,47 @@ #define GOOGLE_PROTOBUF_MESSAGE_LITE_H__ #include +#include #include #include -#include #include -#include +#include +#include + + +#include + +#ifdef SWIG +#error "You cannot SWIG proto headers" +#endif namespace google { namespace protobuf { + template class RepeatedPtrField; + namespace io { + class CodedInputStream; class CodedOutputStream; class ZeroCopyInputStream; class ZeroCopyOutputStream; -} + +} // namespace io namespace internal { +#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER +// See parse_context.h for explanation +class ParseContext; +typedef const char* (*ParseFunc)(const char* ptr, const char* end, void* object, + ParseContext* ctx); +#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER + class RepeatedPtrFieldBase; class WireFormatLite; class WeakFieldMap; -#ifndef SWIG // We compute sizes as size_t but cache them as int. This function converts a // computed size to a cached size. Since we don't proceed with serialization // if the total size was > INT_MAX, it is not important what this function @@ -128,14 +146,16 @@ class ExplicitlyConstructed { // Default empty string object. Don't use this directly. Instead, call // GetEmptyString() to get the reference. -LIBPROTOBUF_EXPORT extern ExplicitlyConstructed<::std::string> fixed_address_empty_string; +LIBPROTOBUF_EXPORT extern ExplicitlyConstructed<::std::string> + fixed_address_empty_string; + LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() { return fixed_address_empty_string.get(); } LIBPROTOBUF_EXPORT size_t StringSpaceUsedExcludingSelfLong(const string& str); -#endif // SWIG + } // namespace internal // Interface to light weight protocol messages. @@ -177,14 +197,14 @@ class LIBPROTOBUF_EXPORT MessageLite { // Construct a new instance on the arena. Ownership is passed to the caller // if arena is a NULL. Default implementation for backwards compatibility. - virtual MessageLite* New(::google::protobuf::Arena* arena) const; + virtual MessageLite* New(Arena* arena) const; // Get the arena, if any, associated with this message. Virtual method // required for generic operations but most arena-related operations should // use the GetArenaNoVirtual() generated-code method. Default implementation // to reduce code size by avoiding the need for per-type implementations // when types do not implement arena support. - virtual ::google::protobuf::Arena* GetArena() const { return NULL; } + virtual Arena* GetArena() const { return NULL; } // Get a pointer that may be equal to this message's arena, or may not be. // If the value returned by this method is equal to some arena pointer, then @@ -248,7 +268,7 @@ class LIBPROTOBUF_EXPORT MessageLite { // This function takes a string in the (non-human-readable) binary wire // format, matching the encoding output by MessageLite::SerializeToString(). // If you'd like to convert a human-readable string into a protocol buffer - // object, see google::protobuf::TextFormat::ParseFromString(). + // object, see proto2::TextFormat::ParseFromString(). bool ParseFromString(const string& data); // Like ParseFromString(), but accepts messages that are missing // required fields. @@ -278,7 +298,14 @@ class LIBPROTOBUF_EXPORT MessageLite { // // MergeFromCodedStream() is just implemented as MergePartialFromCodedStream() // followed by IsInitialized(). +#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER + virtual bool MergePartialFromCodedStream(io::CodedInputStream* input); +#else virtual bool MergePartialFromCodedStream(io::CodedInputStream* input) = 0; +#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER + + // Merge a protocol buffer contained in a string. + bool MergeFromString(const string& data); // Serialization --------------------------------------------------- @@ -331,7 +358,7 @@ class LIBPROTOBUF_EXPORT MessageLite { virtual size_t ByteSizeLong() const = 0; // Legacy ByteSize() API. - PROTOBUF_RUNTIME_DEPRECATED("Please use ByteSizeLong() instead") + GOOGLE_PROTOBUF_DEPRECATED_MSG("Please use ByteSizeLong() instead") int ByteSize() const { return internal::ToIntSize(ByteSizeLong()); } @@ -370,19 +397,25 @@ class LIBPROTOBUF_EXPORT MessageLite { virtual uint8* InternalSerializeWithCachedSizesToArray(bool deterministic, uint8* target) const; +#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER + virtual internal::ParseFunc _ParseFunc() const { + return nullptr; + } +#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER + protected: // CastToBase allows generated code to cast a RepeatedPtrField to // RepeatedPtrFieldBase. We try to restrict access to RepeatedPtrFieldBase // because it is an implementation detail that user code should not access // directly. template - static ::google::protobuf::internal::RepeatedPtrFieldBase* CastToBase( - ::google::protobuf::RepeatedPtrField* repeated) { + static internal::RepeatedPtrFieldBase* CastToBase( + RepeatedPtrField* repeated) { return repeated; } template - static const ::google::protobuf::internal::RepeatedPtrFieldBase& CastToBase( - const ::google::protobuf::RepeatedPtrField& repeated) { + static const internal::RepeatedPtrFieldBase& CastToBase( + const RepeatedPtrField& repeated) { return repeated; } @@ -402,23 +435,9 @@ class LIBPROTOBUF_EXPORT MessageLite { GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageLite); }; -namespace internal { - -extern bool LIBPROTOBUF_EXPORT proto3_preserve_unknown_; - -// DO NOT USE: For migration only. Will be removed when Proto3 defaults to -// preserve unknowns. -inline bool GetProto3PreserveUnknownsDefault() { - return proto3_preserve_unknown_; -} - -// DO NOT USE: For migration only. Will be removed when Proto3 defaults to -// preserve unknowns. -void LIBPROTOBUF_EXPORT SetProto3PreserveUnknownsDefault(bool preserve); -} // namespace internal - - } // namespace protobuf - } // namespace google + +#include + #endif // GOOGLE_PROTOBUF_MESSAGE_LITE_H__ -- cgit v1.2.3