aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/generated_message_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/generated_message_util.cc')
-rw-r--r--src/google/protobuf/generated_message_util.cc64
1 files changed, 23 insertions, 41 deletions
diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc
index e0241361..ba8ec6d4 100644
--- a/src/google/protobuf/generated_message_util.cc
+++ b/src/google/protobuf/generated_message_util.cc
@@ -47,13 +47,14 @@
#include <google/protobuf/message_lite.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/stubs/mutex.h>
-#include <google/protobuf/stubs/port.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/wire_format_lite_inl.h>
-namespace google {
+#include <google/protobuf/port_def.inc>
+
+namespace google {
namespace protobuf {
namespace internal {
@@ -62,14 +63,8 @@ void DestroyMessage(const void* message) {
}
void DestroyString(const void* s) { static_cast<const string*>(s)->~string(); }
-ExplicitlyConstructed<std::string> fixed_address_empty_string;
+ExplicitlyConstructed<::std::string> fixed_address_empty_string;
-double Infinity() {
- return std::numeric_limits<double>::infinity();
-}
-double NaN() {
- return std::numeric_limits<double>::quiet_NaN();
-}
static bool InitProtobufDefaultsImpl() {
fixed_address_empty_string.DefaultConstruct();
@@ -108,8 +103,7 @@ struct PrimitiveTypeHelper;
template <>
struct PrimitiveTypeHelper<WireFormatLite::TYPE_BOOL> {
typedef bool Type;
- static void Serialize(const void* ptr,
- ::google::protobuf::io::CodedOutputStream* output) {
+ static void Serialize(const void* ptr, io::CodedOutputStream* output) {
WireFormatLite::WriteBoolNoTag(Get<bool>(ptr), output);
}
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
@@ -120,8 +114,7 @@ struct PrimitiveTypeHelper<WireFormatLite::TYPE_BOOL> {
template <>
struct PrimitiveTypeHelper<WireFormatLite::TYPE_INT32> {
typedef int32 Type;
- static void Serialize(const void* ptr,
- ::google::protobuf::io::CodedOutputStream* output) {
+ static void Serialize(const void* ptr, io::CodedOutputStream* output) {
WireFormatLite::WriteInt32NoTag(Get<int32>(ptr), output);
}
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
@@ -132,8 +125,7 @@ struct PrimitiveTypeHelper<WireFormatLite::TYPE_INT32> {
template <>
struct PrimitiveTypeHelper<WireFormatLite::TYPE_SINT32> {
typedef int32 Type;
- static void Serialize(const void* ptr,
- ::google::protobuf::io::CodedOutputStream* output) {
+ static void Serialize(const void* ptr, io::CodedOutputStream* output) {
WireFormatLite::WriteSInt32NoTag(Get<int32>(ptr), output);
}
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
@@ -144,8 +136,7 @@ struct PrimitiveTypeHelper<WireFormatLite::TYPE_SINT32> {
template <>
struct PrimitiveTypeHelper<WireFormatLite::TYPE_UINT32> {
typedef uint32 Type;
- static void Serialize(const void* ptr,
- ::google::protobuf::io::CodedOutputStream* output) {
+ static void Serialize(const void* ptr, io::CodedOutputStream* output) {
WireFormatLite::WriteUInt32NoTag(Get<uint32>(ptr), output);
}
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
@@ -155,8 +146,7 @@ struct PrimitiveTypeHelper<WireFormatLite::TYPE_UINT32> {
template <>
struct PrimitiveTypeHelper<WireFormatLite::TYPE_INT64> {
typedef int64 Type;
- static void Serialize(const void* ptr,
- ::google::protobuf::io::CodedOutputStream* output) {
+ static void Serialize(const void* ptr, io::CodedOutputStream* output) {
WireFormatLite::WriteInt64NoTag(Get<int64>(ptr), output);
}
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
@@ -167,8 +157,7 @@ struct PrimitiveTypeHelper<WireFormatLite::TYPE_INT64> {
template <>
struct PrimitiveTypeHelper<WireFormatLite::TYPE_SINT64> {
typedef int64 Type;
- static void Serialize(const void* ptr,
- ::google::protobuf::io::CodedOutputStream* output) {
+ static void Serialize(const void* ptr, io::CodedOutputStream* output) {
WireFormatLite::WriteSInt64NoTag(Get<int64>(ptr), output);
}
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
@@ -178,8 +167,7 @@ struct PrimitiveTypeHelper<WireFormatLite::TYPE_SINT64> {
template <>
struct PrimitiveTypeHelper<WireFormatLite::TYPE_UINT64> {
typedef uint64 Type;
- static void Serialize(const void* ptr,
- ::google::protobuf::io::CodedOutputStream* output) {
+ static void Serialize(const void* ptr, io::CodedOutputStream* output) {
WireFormatLite::WriteUInt64NoTag(Get<uint64>(ptr), output);
}
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
@@ -190,8 +178,7 @@ struct PrimitiveTypeHelper<WireFormatLite::TYPE_UINT64> {
template <>
struct PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED32> {
typedef uint32 Type;
- static void Serialize(const void* ptr,
- ::google::protobuf::io::CodedOutputStream* output) {
+ static void Serialize(const void* ptr, io::CodedOutputStream* output) {
WireFormatLite::WriteFixed32NoTag(Get<uint32>(ptr), output);
}
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
@@ -202,8 +189,7 @@ struct PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED32> {
template <>
struct PrimitiveTypeHelper<WireFormatLite::TYPE_FIXED64> {
typedef uint64 Type;
- static void Serialize(const void* ptr,
- ::google::protobuf::io::CodedOutputStream* output) {
+ static void Serialize(const void* ptr, io::CodedOutputStream* output) {
WireFormatLite::WriteFixed64NoTag(Get<uint64>(ptr), output);
}
static uint8* SerializeToArray(const void* ptr, uint8* buffer) {
@@ -239,8 +225,7 @@ struct PrimitiveTypeHelper<WireFormatLite::TYPE_DOUBLE>
template <>
struct PrimitiveTypeHelper<WireFormatLite::TYPE_STRING> {
typedef string Type;
- static void Serialize(const void* ptr,
- ::google::protobuf::io::CodedOutputStream* output) {
+ static void Serialize(const void* ptr, io::CodedOutputStream* output) {
const Type& value = *static_cast<const Type*>(ptr);
output->WriteVarint32(value.size());
output->WriteRawMaybeAliased(value.data(), value.size());
@@ -283,9 +268,8 @@ void WriteLengthTo(uint32 length, O* output) {
// Specialization for coded output stream
template <int type>
-struct OutputHelper<::google::protobuf::io::CodedOutputStream, type> {
- static void Serialize(const void* ptr,
- ::google::protobuf::io::CodedOutputStream* output) {
+struct OutputHelper<io::CodedOutputStream, type> {
+ static void Serialize(const void* ptr, io::CodedOutputStream* output) {
PrimitiveTypeHelper<type>::Serialize(ptr, output);
}
};
@@ -304,7 +288,7 @@ struct OutputHelper<ArrayOutput, type> {
};
void SerializeMessageNoTable(const MessageLite* msg,
- ::google::protobuf::io::CodedOutputStream* output) {
+ io::CodedOutputStream* output) {
msg->SerializeWithCachedSizes(output);
}
@@ -314,10 +298,10 @@ void SerializeMessageNoTable(const MessageLite* msg, ArrayOutput* output) {
}
// Helper to branch to fast path if possible
-void SerializeMessageDispatch(const ::google::protobuf::MessageLite& msg,
+void SerializeMessageDispatch(const MessageLite& msg,
const FieldMetadata* field_table, int num_fields,
int32 cached_size,
- ::google::protobuf::io::CodedOutputStream* output) {
+ io::CodedOutputStream* output) {
const uint8* base = reinterpret_cast<const uint8*>(&msg);
// Try the fast path
uint8* ptr = output->GetDirectBufferForNBytesAndAdvance(cached_size);
@@ -332,7 +316,7 @@ void SerializeMessageDispatch(const ::google::protobuf::MessageLite& msg,
}
// Helper to branch to fast path if possible
-void SerializeMessageDispatch(const ::google::protobuf::MessageLite& msg,
+void SerializeMessageDispatch(const MessageLite& msg,
const FieldMetadata* field_table, int num_fields,
int32 cached_size, ArrayOutput* output) {
const uint8* base = reinterpret_cast<const uint8*>(&msg);
@@ -635,8 +619,7 @@ bool IsNull<FieldMetadata::kInlinedType>(const void* ptr) {
void SerializeInternal(const uint8* base,
const FieldMetadata* field_metadata_table,
- int32 num_fields,
- ::google::protobuf::io::CodedOutputStream* output) {
+ int32 num_fields, io::CodedOutputStream* output) {
for (int i = 0; i < num_fields; i++) {
const FieldMetadata& field_metadata = field_metadata_table[i];
const uint8* ptr = base + field_metadata.offset;
@@ -725,15 +708,14 @@ uint8* SerializeInternalToArray(const uint8* base,
#undef SERIALIZERS_FOR_TYPE
void ExtensionSerializer(const uint8* ptr, uint32 offset, uint32 tag,
- uint32 has_offset,
- ::google::protobuf::io::CodedOutputStream* output) {
+ uint32 has_offset, io::CodedOutputStream* output) {
reinterpret_cast<const ExtensionSet*>(ptr + offset)
->SerializeWithCachedSizes(tag, has_offset, output);
}
void UnknownFieldSerializerLite(const uint8* ptr, uint32 offset, uint32 tag,
uint32 has_offset,
- ::google::protobuf::io::CodedOutputStream* output) {
+ io::CodedOutputStream* output) {
output->WriteString(
reinterpret_cast<const InternalMetadataWithArenaLite*>(ptr + offset)
->unknown_fields());