add packet constructor which accepts payload buffer.

This commit is contained in:
Mathieu Lacage
2007-02-10 10:24:36 +01:00
parent 1df1c2d0c2
commit ec6e1ff8bc
2 changed files with 19 additions and 0 deletions

View File

@@ -38,6 +38,16 @@ Packet::Packet (uint32_t size)
{
m_global_uid++;
}
Packet::Packet (uint8_t const*buffer, uint32_t size)
: m_buffer (),
m_uid (m_global_uid)
{
m_global_uid++;
m_buffer.AddAtStart (size);
Buffer::Iterator i = m_buffer.Begin ();
i.Write (buffer, size);
}
Packet::Packet (Buffer buffer, Tags tags, uint32_t uid)
: m_buffer (buffer),
m_tags (tags),

View File

@@ -103,6 +103,15 @@ public:
* \param size the size of the zero-filled payload
*/
Packet (uint32_t size);
/**
* Create a packet with payload filled with the content
* of this buffer. The input data is copied: the input
* buffer is untouched.
*
* \param buffer the data to store in the packet.
* \param size the size of the input buffer.
*/
Packet (uint8_t const*buffer, uint32_t size);
/**
* Create a new packet which contains a fragment of the original
* packet. The returned packet shares the same uid as this packet.