50 template <
typename CharType,
typename PacketTraits = DefaultPacketTraits>
66 virtual void encode(uint64_t aValue, std::size_t aLength)
69 for (std::size_t i = 0; i < aLength; ++i)
71 buffer[PacketTraits::NetworkByteOrder ? aLength - 1 - i : i] = result & 0xFF;
74 write(&buffer[0], aLength);
78 encode(
static_cast<uint8_t
>(aValue));
82 encode(
static_cast<uint32_t
>(aValue.size()));
83 write(&aValue[0], aValue.size());
88 read(&buffer[0], aLength);
90 for (std::size_t i = 0; i < aLength; ++i)
93 result += buffer[PacketTraits::NetworkByteOrder ? i : aLength - 1 - i];
99 return static_cast<bool>(decode<uint8_t>());
103 uint32_t
length = decode<uint32_t>();
109 virtual void write(
const void* aData, std::size_t aLength) = 0;
110 virtual void read(
void* aData, std::size_t aLength)
const = 0;
static const bool NetworkByteOrder
virtual void encode(bool aValue)
base_type::const_pointer const_pointer
base_type::string_type string_type
base_type::const_iterator const_iterator
virtual bool decode_bool() const
base_type::iterator iterator
base_type::pointer pointer
basic_binary_data_packet< CharType, PacketTraits > our_type
base_type::character_type character_type
virtual string_type decode_string() const
virtual uint64_t decode_integer(std::size_t aLength) const
base_type::size_type size_type
virtual void encode(uint64_t aValue, std::size_t aLength)
virtual void encode(const string_type &aValue)
base_type::character_type character_type
base_type::size_type size_type
base_type::pointer pointer
base_type::iterator iterator
std::basic_string< CharType > string_type
base_type::const_pointer const_pointer
base_type::const_iterator const_iterator
virtual size_type length() const =0
basic_binary_data_packet< char > binary_data_packet