From d36c0c538a545fac5d9db6ba65c525246d4efa95 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Wed, 29 Mar 2017 14:32:48 -0700 Subject: Down-integrate from google3. --- src/google/protobuf/message_lite.h | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 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 5e5ed306..046a736d 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -42,6 +42,7 @@ #include #include #include +#include namespace google { @@ -248,11 +249,7 @@ class LIBPROTOBUF_EXPORT MessageLite { virtual size_t ByteSizeLong() const = 0; // Legacy ByteSize() API. - int ByteSize() const { - size_t result = ByteSizeLong(); - GOOGLE_DCHECK_LE(result, static_cast(INT_MAX)); - return static_cast(result); - } + int ByteSize() const { return internal::ToIntSize(ByteSizeLong()); } // Serializes the message without recomputing the size. The message must not // have changed since the last call to ByteSize(), and the value returned by @@ -260,11 +257,17 @@ class LIBPROTOBUF_EXPORT MessageLite { virtual void SerializeWithCachedSizes( io::CodedOutputStream* output) const = 0; - // A version of SerializeWithCachedSizesToArray, below, that does - // not guarantee deterministic serialization. - virtual uint8* SerializeWithCachedSizesToArray(uint8* target) const { - return InternalSerializeWithCachedSizesToArray(false, target); - } + // Functions below here are not part of the public interface. It isn't + // enforced, but they should be treated as private, and will be private + // at some future time. Unfortunately the implementation of the "friend" + // keyword in GCC is broken at the moment, but we expect it will be fixed. + + // Like SerializeWithCachedSizes, but writes directly to *target, returning + // a pointer to the byte immediately after the last byte written. "target" + // must point at a byte array of at least ByteSize() bytes. Whether to use + // deterministic serialization, e.g., maps in sorted order, is determined by + // CodedOutputStream::IsDefaultSerializationDeterministic(). + virtual uint8* SerializeWithCachedSizesToArray(uint8* target) const; // Returns the result of the last call to ByteSize(). An embedded message's // size is needed both to serialize it (because embedded messages are @@ -279,16 +282,6 @@ class LIBPROTOBUF_EXPORT MessageLite { // method.) virtual int GetCachedSize() const = 0; - // Functions below here are not part of the public interface. It isn't - // enforced, but they should be treated as private, and will be private - // at some future time. Unfortunately the implementation of the "friend" - // keyword in GCC is broken at the moment, but we expect it will be fixed. - - // Like SerializeWithCachedSizes, but writes directly to *target, returning - // a pointer to the byte immediately after the last byte written. "target" - // must point at a byte array of at least ByteSize() bytes. If deterministic - // is true then we use deterministic serialization, e.g., map keys are sorted. - // FOR INTERNAL USE ONLY! virtual uint8* InternalSerializeWithCachedSizesToArray(bool deterministic, uint8* target) const; -- cgit v1.2.3