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.h33
1 files changed, 13 insertions, 20 deletions
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 <climits>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/generated_message_util.h>
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<size_t>(INT_MAX));
- return static_cast<int>(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;