diff -Naur krpc-cpp-0.5.2-orig/src/decoder.cpp krpc-cpp-0.5.2/src/decoder.cpp --- krpc-cpp-0.5.2-orig/src/decoder.cpp 2023-03-18 22:44:24.000000000 +0300 +++ krpc-cpp-0.5.2/src/decoder.cpp 2023-12-12 22:25:48.212875600 +0300 @@ -10,7 +10,7 @@ #include "krpc/event.hpp" #include "krpc/platform.hpp" -namespace pb = google::protobuf; +namespace gpb = google::protobuf; namespace krpc { namespace decoder { @@ -27,60 +27,60 @@ } void decode(double& value, const std::string& data, Client* client) { - pb::io::CodedInputStream stream((pb::uint8*)&data[0], static_cast(data.size())); - pb::uint64 value2 = 0; + gpb::io::CodedInputStream stream((gpb::uint8*)&data[0], static_cast(data.size())); + gpb::uint64 value2 = 0; if (!stream.ReadLittleEndian64(&value2)) throw EncodingError("Failed to decode double"); - value = pb::internal::WireFormatLite::DecodeDouble(value2); + value = gpb::internal::WireFormatLite::DecodeDouble(value2); } void decode(float& value, const std::string& data, Client* client) { - pb::io::CodedInputStream stream((pb::uint8*)(&data[0]), static_cast(data.size())); - pb::uint32 value2; + gpb::io::CodedInputStream stream((gpb::uint8*)(&data[0]), static_cast(data.size())); + gpb::uint32 value2; if (!stream.ReadLittleEndian32(&value2)) throw EncodingError("Failed to decode float"); - value = pb::internal::WireFormatLite::DecodeFloat(value2); + value = gpb::internal::WireFormatLite::DecodeFloat(value2); } -void decode(pb::int32& value, const std::string& data, Client* client) { - pb::io::CodedInputStream stream((pb::uint8*)&data[0], static_cast(data.size())); - pb::uint32 zigZagValue = 0; +void decode(gpb::int32& value, const std::string& data, Client* client) { + gpb::io::CodedInputStream stream((gpb::uint8*)&data[0], static_cast(data.size())); + gpb::uint32 zigZagValue = 0; if (!stream.ReadVarint32(&zigZagValue)) throw EncodingError("Failed to decode sint32"); - value = pb::internal::WireFormatLite::ZigZagDecode32(zigZagValue); + value = gpb::internal::WireFormatLite::ZigZagDecode32(zigZagValue); } -void decode(pb::int64& value, const std::string& data, Client* client) { - pb::io::CodedInputStream stream((pb::uint8*)&data[0], static_cast(data.size())); - pb::uint64 zigZagValue = 0; +void decode(gpb::int64& value, const std::string& data, Client* client) { + gpb::io::CodedInputStream stream((gpb::uint8*)&data[0], static_cast(data.size())); + gpb::uint64 zigZagValue = 0; if (!stream.ReadVarint64(&zigZagValue)) throw EncodingError("Failed to decode sint64"); - value = pb::internal::WireFormatLite::ZigZagDecode64(zigZagValue); + value = gpb::internal::WireFormatLite::ZigZagDecode64(zigZagValue); } -void decode(pb::uint32& value, const std::string& data, Client* client) { - pb::io::CodedInputStream stream((pb::uint8*)&data[0], static_cast(data.size())); +void decode(gpb::uint32& value, const std::string& data, Client* client) { + gpb::io::CodedInputStream stream((gpb::uint8*)&data[0], static_cast(data.size())); if (!stream.ReadVarint32(&value)) throw EncodingError("Failed to decode uint32"); } -void decode(pb::uint64& value, const std::string& data, Client* client) { - pb::io::CodedInputStream stream((pb::uint8*)&data[0], static_cast(data.size())); +void decode(gpb::uint64& value, const std::string& data, Client* client) { + gpb::io::CodedInputStream stream((gpb::uint8*)&data[0], static_cast(data.size())); if (!stream.ReadVarint64(&value)) throw EncodingError("Failed to decode uint64"); } void decode(bool& value, const std::string& data, Client* client) { - pb::io::CodedInputStream stream((pb::uint8*)&data[0], static_cast(data.size())); - pb::uint64 value2 = 0; + gpb::io::CodedInputStream stream((gpb::uint8*)&data[0], static_cast(data.size())); + gpb::uint64 value2 = 0; if (!stream.ReadVarint64(&value2)) throw EncodingError("Failed to decode bool"); value = (value2 != 0); } void decode(std::string& value, const std::string& data, Client* client) { - pb::io::CodedInputStream stream((pb::uint8*)&data[0], static_cast(data.size())); - pb::uint64 length; + gpb::io::CodedInputStream stream((gpb::uint8*)&data[0], static_cast(data.size())); + gpb::uint64 length; if (!stream.ReadVarint64(&length)) throw EncodingError("Failed to decode string (length)"); if (!stream.ReadString(&value, static_cast(length))) @@ -94,14 +94,14 @@ event = Event(client, message); } -void decode(pb::MessageLite& message, const std::string& data, Client* client) { +void decode(gpb::MessageLite& message, const std::string& data, Client* client) { if (!message.ParseFromString(data)) throw EncodingError("Failed to decode message"); } -pb::uint32 decode_size(const std::string& data) { - pb::uint32 result; - pb::io::CodedInputStream stream((pb::uint8*)&data[0], static_cast(data.size())); +gpb::uint32 decode_size(const std::string& data) { + gpb::uint32 result; + gpb::io::CodedInputStream stream((gpb::uint8*)&data[0], static_cast(data.size())); if (!stream.ReadVarint32(&result)) throw EncodingError("Failed to decode size"); return result; diff -Naur krpc-cpp-0.5.2-orig/src/encoder.cpp krpc-cpp-0.5.2/src/encoder.cpp --- krpc-cpp-0.5.2-orig/src/encoder.cpp 2023-03-18 22:44:24.000000000 +0300 +++ krpc-cpp-0.5.2/src/encoder.cpp 2023-12-12 22:23:48.087498100 +0300 @@ -9,7 +9,7 @@ #include "krpc/error.hpp" -namespace pb = google::protobuf; +namespace gpb = google::protobuf; namespace krpc { namespace encoder { @@ -18,54 +18,54 @@ static const size_t LITTLE_ENDIAN_64_LENGTH = 8; std::string encode(double value) { - pb::uint64 value2 = pb::internal::WireFormatLite::EncodeDouble(value); + gpb::uint64 value2 = gpb::internal::WireFormatLite::EncodeDouble(value); std::string data(LITTLE_ENDIAN_64_LENGTH, 0); - pb::io::CodedOutputStream::WriteLittleEndian64ToArray(value2, (pb::uint8*)&data[0]); + gpb::io::CodedOutputStream::WriteLittleEndian64ToArray(value2, (gpb::uint8*)&data[0]); return data; } std::string encode(float value) { - pb::uint32 value2 = pb::internal::WireFormatLite::EncodeFloat(value); + gpb::uint32 value2 = gpb::internal::WireFormatLite::EncodeFloat(value); std::string data(LITTLE_ENDIAN_32_LENGTH, 0); - pb::io::CodedOutputStream::WriteLittleEndian32ToArray(value2, (pb::uint8*)&data[0]); + gpb::io::CodedOutputStream::WriteLittleEndian32ToArray(value2, (gpb::uint8*)&data[0]); return data; } -std::string encode(pb::int32 value) { - pb::uint32 zigZagValue = pb::internal::WireFormatLite::ZigZagEncode32(value); - size_t length = pb::io::CodedOutputStream::VarintSize32(zigZagValue); +std::string encode(gpb::int32 value) { + gpb::uint32 zigZagValue = gpb::internal::WireFormatLite::ZigZagEncode32(value); + size_t length = gpb::io::CodedOutputStream::VarintSize32(zigZagValue); std::string data(length, 0); - pb::io::CodedOutputStream::WriteVarint32ToArray(zigZagValue, (pb::uint8*)&data[0]); + gpb::io::CodedOutputStream::WriteVarint32ToArray(zigZagValue, (gpb::uint8*)&data[0]); return data; } -std::string encode(pb::int64 value) { - pb::uint64 zigZagValue = pb::internal::WireFormatLite::ZigZagEncode64(value); - size_t length = pb::io::CodedOutputStream::VarintSize64(zigZagValue); +std::string encode(gpb::int64 value) { + gpb::uint64 zigZagValue = gpb::internal::WireFormatLite::ZigZagEncode64(value); + size_t length = gpb::io::CodedOutputStream::VarintSize64(zigZagValue); std::string data(length, 0); - pb::io::CodedOutputStream::WriteVarint64ToArray(zigZagValue, (pb::uint8*)&data[0]); + gpb::io::CodedOutputStream::WriteVarint64ToArray(zigZagValue, (gpb::uint8*)&data[0]); return data; } -std::string encode(pb::uint32 value) { - size_t length = pb::io::CodedOutputStream::VarintSize32(value); +std::string encode(gpb::uint32 value) { + size_t length = gpb::io::CodedOutputStream::VarintSize32(value); std::string data(length, 0); - pb::io::CodedOutputStream::WriteVarint32ToArray(value, (pb::uint8*)&data[0]); + gpb::io::CodedOutputStream::WriteVarint32ToArray(value, (gpb::uint8*)&data[0]); return data; } -std::string encode(pb::uint64 value) { - size_t length = pb::io::CodedOutputStream::VarintSize64(value); +std::string encode(gpb::uint64 value) { + size_t length = gpb::io::CodedOutputStream::VarintSize64(value); std::string data(length, 0); - pb::io::CodedOutputStream::WriteVarint64ToArray(value, (pb::uint8*)&data[0]); + gpb::io::CodedOutputStream::WriteVarint64ToArray(value, (gpb::uint8*)&data[0]); return data; } std::string encode(bool value) { - pb::uint32 value2 = (value ? 1 : 0); - size_t length = pb::io::CodedOutputStream::VarintSize32(value2); + gpb::uint32 value2 = (value ? 1 : 0); + size_t length = gpb::io::CodedOutputStream::VarintSize32(value2); std::string data(length, 0); - pb::io::CodedOutputStream::WriteVarint32ToArray(value, (pb::uint8*)&data[0]); + gpb::io::CodedOutputStream::WriteVarint32ToArray(value, (gpb::uint8*)&data[0]); return data; } @@ -75,26 +75,26 @@ std::string encode(const std::string& value) { size_t length = value.size(); - size_t header_length = pb::io::CodedOutputStream::VarintSize64(length); + size_t header_length = gpb::io::CodedOutputStream::VarintSize64(length); std::string data(header_length + length, 0); - pb::io::CodedOutputStream::WriteVarint64ToArray(length, (pb::uint8*)&data[0]); - pb::io::CodedOutputStream::WriteStringToArray(value, (pb::uint8*)&data[header_length]); + gpb::io::CodedOutputStream::WriteVarint64ToArray(length, (gpb::uint8*)&data[0]); + gpb::io::CodedOutputStream::WriteStringToArray(value, (gpb::uint8*)&data[header_length]); return data; } -std::string encode(const pb::MessageLite& message) { +std::string encode(const gpb::MessageLite& message) { std::string data; if (!message.SerializeToString(&data)) throw EncodingError("Failed to encode message"); return data; } -std::string encode_message_with_size(const pb::MessageLite& message) { +std::string encode_message_with_size(const gpb::MessageLite& message) { size_t length = message.ByteSizeLong(); - size_t header_length = pb::io::CodedOutputStream::VarintSize64(length); + size_t header_length = gpb::io::CodedOutputStream::VarintSize64(length); std::string data(header_length + length, 0); - pb::io::CodedOutputStream::WriteVarint64ToArray(length, (pb::uint8*)&data[0]); - if (!message.SerializeWithCachedSizesToArray((pb::uint8*)&data[header_length])) + gpb::io::CodedOutputStream::WriteVarint64ToArray(length, (gpb::uint8*)&data[0]); + if (!message.SerializeWithCachedSizesToArray((gpb::uint8*)&data[header_length])) throw EncodingError("Failed to encode message with size"); return data; }