|
|
|
@ -35,6 +35,7 @@ |
|
|
|
|
#include <utility> |
|
|
|
|
#include <vector> |
|
|
|
|
|
|
|
|
|
#include "google/protobuf/endian.h" |
|
|
|
|
#include "google/protobuf/text_format.h" |
|
|
|
|
#include "google/protobuf/util/json_util.h" |
|
|
|
|
#include "google/protobuf/util/type_resolver_util.h" |
|
|
|
@ -58,6 +59,7 @@ using google::protobuf::Descriptor; |
|
|
|
|
using google::protobuf::FieldDescriptor; |
|
|
|
|
using google::protobuf::Message; |
|
|
|
|
using google::protobuf::internal::WireFormatLite; |
|
|
|
|
using google::protobuf::internal::little_endian::FromHost; |
|
|
|
|
using google::protobuf::util::NewTypeResolverForDescriptorPool; |
|
|
|
|
using proto2_messages::TestAllTypesProto2; |
|
|
|
|
using protobuf_test_messages::proto3::TestAllTypesProto3; |
|
|
|
@ -117,9 +119,18 @@ string longvarint(uint64_t x, int extra) { |
|
|
|
|
return string(buf, len); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: proper byte-swapping for big-endian machines.
|
|
|
|
|
string fixed32(void* data) { return string(static_cast<char*>(data), 4); } |
|
|
|
|
string fixed64(void* data) { return string(static_cast<char*>(data), 8); } |
|
|
|
|
string fixed32(void* data) { |
|
|
|
|
uint32_t data_le; |
|
|
|
|
std::memcpy(&data_le, data, 4); |
|
|
|
|
data_le = FromHost(data_le); |
|
|
|
|
return string(reinterpret_cast<char*>(&data_le), 4); |
|
|
|
|
} |
|
|
|
|
string fixed64(void* data) { |
|
|
|
|
uint64_t data_le; |
|
|
|
|
std::memcpy(&data_le, data, 8); |
|
|
|
|
data_le = FromHost(data_le); |
|
|
|
|
return string(reinterpret_cast<char*>(&data_le), 8); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
string delim(const string& buf) { |
|
|
|
|
return absl::StrCat(varint(buf.size()), buf); |
|
|
|
|