| Index: third_party/protobuf/src/google/protobuf/message_lite.h
|
| diff --git a/third_party/protobuf/src/google/protobuf/message_lite.h b/third_party/protobuf/src/google/protobuf/message_lite.h
|
| index 4c16f4c0572be88df0a702e8a5455d0ec78fc385..5e5ed306810a7b8ee758b37273b368cf06a14d03 100644
|
| --- a/third_party/protobuf/src/google/protobuf/message_lite.h
|
| +++ b/third_party/protobuf/src/google/protobuf/message_lite.h
|
| @@ -39,7 +39,9 @@
|
| #ifndef GOOGLE_PROTOBUF_MESSAGE_LITE_H__
|
| #define GOOGLE_PROTOBUF_MESSAGE_LITE_H__
|
|
|
| +#include <climits>
|
| #include <google/protobuf/stubs/common.h>
|
| +#include <google/protobuf/stubs/logging.h>
|
|
|
|
|
| namespace google {
|
| @@ -51,6 +53,9 @@ namespace io {
|
| class ZeroCopyInputStream;
|
| class ZeroCopyOutputStream;
|
| }
|
| +namespace internal {
|
| + class WireFormatLite;
|
| +}
|
|
|
| // Interface to light weight protocol messages.
|
| //
|
| @@ -78,7 +83,7 @@ namespace io {
|
| class LIBPROTOBUF_EXPORT MessageLite {
|
| public:
|
| inline MessageLite() {}
|
| - virtual ~MessageLite();
|
| + virtual ~MessageLite() {}
|
|
|
| // Basic Operations ------------------------------------------------
|
|
|
| @@ -236,23 +241,30 @@ class LIBPROTOBUF_EXPORT MessageLite {
|
| bool AppendPartialToString(string* output) const;
|
|
|
| // Computes the serialized size of the message. This recursively calls
|
| - // ByteSize() on all embedded messages. If a subclass does not override
|
| - // this, it MUST override SetCachedSize().
|
| + // ByteSizeLong() on all embedded messages.
|
| //
|
| - // ByteSize() is generally linear in the number of fields defined for the
|
| + // ByteSizeLong() is generally linear in the number of fields defined for the
|
| // proto.
|
| - virtual int ByteSize() const = 0;
|
| -
|
| - // Serializes the message without recomputing the size. The message must
|
| - // not have changed since the last call to ByteSize(); if it has, the results
|
| - // are undefined.
|
| + virtual size_t ByteSizeLong() const = 0;
|
| +
|
| + // Legacy ByteSize() API.
|
| + int ByteSize() const {
|
| + size_t result = ByteSizeLong();
|
| + GOOGLE_DCHECK_LE(result, static_cast<size_t>(INT_MAX));
|
| + return static_cast<int>(result);
|
| + }
|
| +
|
| + // Serializes the message without recomputing the size. The message must not
|
| + // have changed since the last call to ByteSize(), and the value returned by
|
| + // ByteSize must be non-negative. Otherwise the results are undefined.
|
| virtual void SerializeWithCachedSizes(
|
| io::CodedOutputStream* output) const = 0;
|
|
|
| - // 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.
|
| - virtual uint8* SerializeWithCachedSizesToArray(uint8* target) const;
|
| + // A version of SerializeWithCachedSizesToArray, below, that does
|
| + // not guarantee deterministic serialization.
|
| + virtual uint8* SerializeWithCachedSizesToArray(uint8* target) const {
|
| + return InternalSerializeWithCachedSizesToArray(false, target);
|
| + }
|
|
|
| // Returns the result of the last call to ByteSize(). An embedded message's
|
| // size is needed both to serialize it (because embedded messages are
|
| @@ -267,7 +279,22 @@ 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;
|
| +
|
| private:
|
| + friend class internal::WireFormatLite;
|
| +
|
| GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageLite);
|
| };
|
|
|
|
|