17#include <boost/shared_ptr.hpp> 
   91        : base_(static_cast<const uint8_t*>(
data)), current_(base_),
 
 
   97        return (
static_cast<size_t>(end_ - base_));
 
 
  102        return (
static_cast<size_t>(current_ - base_));
 
 
  113        if (base_ + position > end_) {
 
  115                      "InputBuffer::setPosition position is too large");
 
  118        current_ = base_ + position;
 
 
  126        if (current_ + 
sizeof(uint8_t) > end_) {
 
  128                      "InputBuffer::peekUint8 read beyond end of buffer");
 
 
  140        current_ += 
sizeof(uint8_t);
 
 
  150        if (current_ + 
sizeof(uint16_t) > end_) {
 
  152                      "InputBuffer::peekUint16 read beyond end of buffer");
 
  156        ret = (
static_cast<uint16_t
>(current_[0])) << 8;
 
  157        ret |= (
static_cast<uint16_t
>(current_[1]));
 
 
  168        current_ += 
sizeof(uint16_t);
 
 
  178        if (current_ + 
sizeof(uint32_t) > end_) {
 
  180                      "InputBuffer::peekUint32 read beyond end of buffer");
 
  184        ret = (
static_cast<uint32_t
>(current_[0])) << 24;
 
  185        ret |= (
static_cast<uint32_t
>(current_[1])) << 16;
 
  186        ret |= (
static_cast<uint32_t
>(current_[2])) << 8;
 
  187        ret |= (
static_cast<uint32_t
>(current_[3]));
 
 
  198        current_ += 
sizeof(uint32_t);
 
 
  211        if (current_ + len > end_) {
 
  213                      "InputBuffer::peekData read beyond end of buffer");
 
  216        static_cast<void>(std::memmove(
data, current_, len));
 
 
  242        if (current_ + len > end_) {
 
  244                      "InputBuffer::peekVector read beyond end of buffer");
 
 
  269    const uint8_t* base_;
 
  272    const uint8_t* current_;
 
 
  353            buffer_.reserve(len);
 
 
  361        size_t len = other.buffer_.capacity();
 
  363            buffer_.reserve(len);
 
 
  374        if (
this != &other) {
 
  376            buffer_ = other.buffer_;
 
  377            size_t len = other.buffer_.capacity();
 
  379                buffer_.reserve(len);
 
 
  388        return (buffer_.capacity());
 
 
  399        if (!buffer_.empty()) {
 
  400            return (&buffer_[0]);
 
 
  408        return (
static_cast<const void*
>(
getData()));
 
 
  413        return (buffer_.size());
 
 
  424        if (position >= buffer_.size()) {
 
  426                      "OutputBuffer::[]: pos (" << position
 
  427                      << 
") >= size (" << buffer_.size() << 
")");
 
  430        return (buffer_[position]);
 
 
  449        buffer_.resize(buffer_.size() + len);
 
 
  460        if (len > buffer_.size()) {
 
  462                      "OutputBuffer::trim length too large from output buffer");
 
  465        buffer_.resize(buffer_.size() - len);
 
 
  477        buffer_.push_back(
data);
 
 
  489        if (position + 
sizeof(
data) > buffer_.size()) {
 
  491                      "OutputBuffer::writeUint8At write at invalid position");
 
  494        buffer_[position] = 
data;
 
 
  502        buffer_.push_back(
static_cast<uint8_t
>((
data & 0xff00U) >> 8));
 
  503        buffer_.push_back(
static_cast<uint8_t
>(
data & 0x00ffU));
 
 
  518        if (position + 
sizeof(
data) > buffer_.size()) {
 
  520                      "OutputBuffer::writeUint16At write at invalid position");
 
  523        buffer_[position] = 
static_cast<uint8_t
>((
data & 0xff00U) >> 8);
 
  524        buffer_[position + 1] = 
static_cast<uint8_t
>(
data & 0x00ffU);
 
 
  532        buffer_.push_back(
static_cast<uint8_t
>((
data & 0xff000000) >> 24));
 
  533        buffer_.push_back(
static_cast<uint8_t
>((
data & 0x00ff0000) >> 16));
 
  534        buffer_.push_back(
static_cast<uint8_t
>((
data & 0x0000ff00) >> 8));
 
  535        buffer_.push_back(
static_cast<uint8_t
>(
data & 0x000000ff));
 
 
  543        buffer_.push_back(
static_cast<uint8_t
>((
data & 0xff00000000000000) >> 56));
 
  544        buffer_.push_back(
static_cast<uint8_t
>((
data & 0x00ff000000000000) >> 48));
 
  545        buffer_.push_back(
static_cast<uint8_t
>((
data & 0x0000ff0000000000) >> 40));
 
  546        buffer_.push_back(
static_cast<uint8_t
>((
data & 0x000000ff00000000) >> 32));
 
  547        buffer_.push_back(
static_cast<uint8_t
>((
data & 0x00000000ff000000) >> 24));
 
  548        buffer_.push_back(
static_cast<uint8_t
>((
data & 0x0000000000ff0000) >> 16));
 
  549        buffer_.push_back(
static_cast<uint8_t
>((
data & 0x000000000000ff00) >> 8));
 
  550        buffer_.push_back(
static_cast<uint8_t
>(
data & 0x00000000000000ff));
 
 
  564        const uint8_t* ptr = 
static_cast<const uint8_t*
>(
data);
 
  565        buffer_.insert(buffer_.end(), ptr, ptr + len);
 
 
  570    std::vector<uint8_t> buffer_;
 
 
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
OutputBuffer & operator=(const OutputBuffer &other)
Assignment operator.
~OutputBuffer()=default
Destructor.
void writeUint64(uint64_t data)
Write an unsigned 64-bit integer in host byte order into the buffer in network byte order.
OutputBuffer(const OutputBuffer &other)
Copy constructor.
void writeUint8(uint8_t data)
Write an unsigned 8-bit integer into the buffer.
void writeUint16(uint16_t data)
Write an unsigned 16-bit integer in host byte order into the buffer in network byte order.
const void * getDataAsVoidPtr() const
Return data as a pointer to void.
void writeUint16At(uint16_t data, size_t position)
Write an unsigned 16-bit integer in host byte order at the specified position of the buffer in networ...
uint8_t operator[](size_t position) const
Return the value of the buffer at the specified position.
void writeData(const void *data, size_t len)
Copy an arbitrary length of data into the buffer.
void writeUint32(uint32_t data)
Write an unsigned 32-bit integer in host byte order into the buffer in network byte order.
void trim(size_t len)
Trim the specified length of data from the end of the buffer.
OutputBuffer(size_t len)
Constructor.
void skip(size_t len)
Insert a specified length of gap at the end of the buffer.
const uint8_t * getData() const
Return a pointer to the head of the data stored in the buffer.
size_t getLength() const
Return the length of data written in the buffer.
void clear()
Clear buffer content.
size_t getCapacity() const
Return the current capacity of the buffer.
void writeUint8At(uint8_t data, size_t position)
Write an unsigned 8-bit integer into the buffer.
const std::vector< uint8_t > & getVector() const
Return the buffer.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< InputBuffer > InputBufferPtr
Type of pointers to input buffer.
boost::shared_ptr< OutputBuffer > OutputBufferPtr
Type of pointers to output buffers.
Defines the logger used by the top-level component of kea-lfc.