ENUt
Public Member Functions

nut::Packet Class Reference

Container for a pointer to data and a length field. More...

#include <packet.h>

List of all members.

Public Member Functions

 Packet ()
 Construct an empty packet.
 Packet (uint8_t *pData, size_t length)
 Construct a packet containig specified data.
void setData (uint8_t *pData, size_t length)
 Store the specified data.
const uint8_t * getData () const
 Returns a pointer to the data.
size_t getLength () const
 Returns the length of the data.
uint8_t * extractData (size_t &length)
 Returns a pointer to the data and sets the stored pointer to null.

Detailed Description


Constructor & Destructor Documentation

nut::Packet::Packet ( ) [inline]
nut::Packet::Packet ( uint8_t *  pData,
size_t  length 
) [inline]

Construct a packet containig specified data. When this instance is destroyed, the data will be deleted as well. To prevent the data from getting lost, the Packet::extractData member function can be used.

Parameters:
pDataPointer to the data which should be stored.
lengthLength of the data.

Member Function Documentation

uint8_t* nut::Packet::extractData ( size_t &  length) [inline]

Returns a pointer to the data and sets the stored pointer to null. After this call, you have to delete the returned data somewhere yourself.

Parameters:
lengthThe length of the data which was returned.
const uint8_t* nut::Packet::getData ( ) const [inline]
size_t nut::Packet::getLength ( ) const [inline]
void nut::Packet::setData ( uint8_t *  pData,
size_t  length 
) [inline]

Store the specified data. When this instance is destroyed, the data will be deleted as well. To prevent the data from getting lost, the Packet::extractData member function can be used.

Parameters:
pDataPointer to the data which should be stored.
lengthLength of the data.

The documentation for this class was generated from the following file: