Bug 1294 - New PeekU8 () and Read (Buffer::Iterator start, uint32_t size) methods in Buffer::Iterator
This commit is contained in:
@@ -31,6 +31,7 @@ New user-visible features
|
||||
|
||||
Bugs fixed
|
||||
----------
|
||||
- Bug 1294 - New PeekU8 () and Read (Buffer::Iterator start, uint32_t size) methods in Buffer::Iterator
|
||||
- Bug 1653 - Extension of CommandLine interface: restored operator << (CommandLine)
|
||||
- Bug 1739 - The endpoint is not deallocated for UDP sockets
|
||||
- Bug 1786 - os << int64x64_t prints un-normalized fractional values
|
||||
|
||||
@@ -250,6 +250,13 @@ public:
|
||||
*/
|
||||
void Write (Iterator start, Iterator end);
|
||||
|
||||
/**
|
||||
* \return the byte read in the buffer.
|
||||
*
|
||||
* Read data, but do not advance the Iterator read.
|
||||
*/
|
||||
inline uint8_t PeekU8 (void);
|
||||
|
||||
/**
|
||||
* \return the byte read in the buffer.
|
||||
*
|
||||
@@ -334,11 +341,21 @@ public:
|
||||
* \param size number of bytes to copy
|
||||
*
|
||||
* Copy size bytes of data from the internal buffer to the
|
||||
* input buffer and avance the Iterator by the number of
|
||||
* input buffer and advance the Iterator by the number of
|
||||
* bytes read.
|
||||
*/
|
||||
void Read (uint8_t *buffer, uint32_t size);
|
||||
|
||||
/**
|
||||
* \param start start iterator of the buffer to copy data into
|
||||
* \param size number of bytes to copy
|
||||
*
|
||||
* Copy size bytes of data from the internal buffer to the input buffer via
|
||||
* the provided iterator and advance the Iterator by the number of bytes
|
||||
* read.
|
||||
*/
|
||||
inline void Read (Iterator start, uint32_t size);
|
||||
|
||||
/**
|
||||
* \brief Calculate the checksum.
|
||||
* \param size size of the buffer.
|
||||
@@ -816,7 +833,7 @@ Buffer::Iterator::ReadNtohU32 (void)
|
||||
}
|
||||
|
||||
uint8_t
|
||||
Buffer::Iterator::ReadU8 (void)
|
||||
Buffer::Iterator::PeekU8 (void)
|
||||
{
|
||||
NS_ASSERT_MSG (m_current >= m_dataStart &&
|
||||
m_current <= m_dataEnd,
|
||||
@@ -825,22 +842,27 @@ Buffer::Iterator::ReadU8 (void)
|
||||
if (m_current < m_zeroStart)
|
||||
{
|
||||
uint8_t data = m_data[m_current];
|
||||
m_current++;
|
||||
return data;
|
||||
}
|
||||
else if (m_current < m_zeroEnd)
|
||||
{
|
||||
m_current++;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t data = m_data[m_current - (m_zeroEnd-m_zeroStart)];
|
||||
m_current++;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t
|
||||
Buffer::Iterator::ReadU8 (void)
|
||||
{
|
||||
uint8_t ret = PeekU8 ();
|
||||
m_current ++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
Buffer::Iterator::ReadU16 (void)
|
||||
{
|
||||
@@ -853,6 +875,16 @@ Buffer::Iterator::ReadU16 (void)
|
||||
return data;
|
||||
}
|
||||
|
||||
void
|
||||
Buffer::Iterator::Read (Buffer::Iterator start, uint32_t size)
|
||||
{
|
||||
Buffer::Iterator end = *this;
|
||||
end.Next (size);
|
||||
|
||||
start.Write (*this, end);
|
||||
}
|
||||
|
||||
|
||||
Buffer::Buffer (Buffer const&o)
|
||||
: m_data (o.m_data),
|
||||
m_maxZeroAreaStart (o.m_zeroAreaStart),
|
||||
|
||||
Reference in New Issue
Block a user