44 template <
typename IdType, std::
size_t MaxPacketSize = 1024,
typename CharType =
char,
typename PacketTraits = DefaultPacketTraits>
47 typedef tld_packet<IdType, CharType, PacketTraits> self_type;
59 typedef std::vector<CharType> contents_type;
60 typedef typename contents_type::size_type contents_offset_type;
78 return iContents.size();
82 return MaxPacketSize != 0;
92 iWritePosition = iContents.size();
93 iReadPosition = PacketTraits::HeaderSize;
102 virtual void copy_from(
const basic_packet<CharType>& aSource)
104 iContents = aSource.iContents;
106 iWritePosition = iContents.size();
107 iReadPosition = PacketTraits::HeaderSize;
111 contents_offset_type oldPosition = iWritePosition;
112 iWritePosition = PacketTraits::IdOffset;
113 encode(
static_cast<uint32_t
>(Id));
114 iWritePosition = oldPosition;
118 contents_offset_type oldPosition = iReadPosition;
119 iReadPosition = PacketTraits::IdOffset;
120 IdType result =
static_cast<IdType
>(decode<uint32_t>());
121 iReadPosition = oldPosition;
126 virtual void write(
const void* aData, std::size_t aLength)
129 virtual void read(
void* aData, std::size_t aLength)
const
132 void allocate(std::size_t aLength)
134 iContents.resize(std::max(iContents.size() + aLength, PacketTraits::HeaderSize));
138 contents_type iContents;
139 contents_offset_type iWritePosition;
140 mutable contents_offset_type iReadPosition;
base_type::const_pointer const_pointer
base_type::string_type string_type
base_type::const_iterator const_iterator
base_type::iterator iterator
base_type::pointer pointer
base_type::character_type character_type
base_type::size_type size_type
base_type::character_type character_type
base_type::string_type string_type
virtual clone_pointer clone() const
virtual bool has_max_length() const
virtual void copy_from(const basic_packet< CharType > &aSource)
base_type::pointer pointer
virtual const_pointer data() const
base_type::const_iterator const_iterator
virtual size_type length() const
virtual size_type max_length() const
base_type::const_pointer const_pointer
base_type::iterator iterator
virtual bool take_some(const_pointer &aFirst, const_pointer aLast)
base_type::size_type size_type
std::unique_ptr< i_basic_packet > clone_pointer
basic_data_packet< char > data_packet