Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Unified Diff: third_party/protobuf/src/google/protobuf/message_lite.h

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Update to new HEAD (b7632464b4) + restore GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..884556696c93380e3e7ee3b27f92f830a15d59d9 100644
--- a/third_party/protobuf/src/google/protobuf/message_lite.h
+++ b/third_party/protobuf/src/google/protobuf/message_lite.h
@@ -51,6 +51,9 @@ namespace io {
class ZeroCopyInputStream;
class ZeroCopyOutputStream;
}
+namespace internal {
+ class WireFormatLite;
+}
// Interface to light weight protocol messages.
//
@@ -78,7 +81,7 @@ namespace io {
class LIBPROTOBUF_EXPORT MessageLite {
public:
inline MessageLite() {}
- virtual ~MessageLite();
+ virtual ~MessageLite() {}
// Basic Operations ------------------------------------------------
@@ -236,12 +239,13 @@ 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().
+ // ByteSize() on all embedded messages. Subclasses MUST override either
+ // ByteSize() or ByteSizeLong() (overriding both is fine).
//
// ByteSize() is generally linear in the number of fields defined for the
// proto.
- virtual int ByteSize() const = 0;
+ virtual int ByteSize() const { return static_cast<int>(ByteSizeLong()); }
+ virtual size_t ByteSizeLong() const;
// Serializes the message without recomputing the size. The message must
// not have changed since the last call to ByteSize(); if it has, the results
@@ -249,10 +253,11 @@ class LIBPROTOBUF_EXPORT MessageLite {
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 +272,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);
};

Powered by Google App Engine
This is Rietveld 408576698