Apache Log4cxx  Version 1.7.0
Loading...
Searching...
No Matches
log4cxx::helpers::ByteBuffer Class Reference

An area of memory and a cursor into that memory. More...

#include <bytebuffer.h>

Public Member Functions

 ByteBuffer (char *data, size_t capacity)
 A capacity sized area of memory at data.
 ~ByteBuffer ()
void carry ()
 Move the remaining bytes to the start of the memory area and set the cursor to the end of the those bytes.
void clear ()
 Set the cursor to the start of the memory area and use the capacity as the extent to which the cursor can advance.
void flip ()
 Set the extent to which the cursor can advance, limit(), to the current cursor position and move the cursor to the start of the memory area.
char * data ()
 The start of the memory area.
const char * data () const
 The start of the memory area.
char * current ()
 The memory at the cursor position.
const char * current () const
 The memory at the cursor position.
size_t limit () const
 The extent to which the cursor can advance as an offset from the start of the memory area.
void limit (size_t newLimit)
 Use newLimit as the extent to which the cursor can advance.
size_t position () const
 The offset of the current cursor from the start of the memory area.
size_t remaining () const
 The number of bytes from the current cursor until the cursor can no longer advance.
void position (size_t newPosition)
 Use newPosition as the cursor position providing it is less than the extent to which the cursor can advance, otherwise set the cursor to the extent to which the cursor can advance.
size_t increment_position (size_t byteCount)
 Advance the cursor by byteCount if that does not exceed the extent to which the cursor can advance, otherwise set the cursor to the extent to which the cursor can advance.
bool put (char byteValue)
 Store byteValue at the cursor position and advance the cursor position unless the cursor cannot advance any further.

Detailed Description

An area of memory and a cursor into that memory.

Provides the remaining bytes available for storage or to be processed.

The flip method switches its role from being a space for storage to being a collection of bytes to be processed.

The carry method switches it back to being a space for storage, while retaining any unprocessed bytes.

It does not own the memory, so does not allocate or free memory. The user must ensure the lifetime of the memory exceeds the lifeime of the class instance.

Constructor & Destructor Documentation

◆ ByteBuffer()

log4cxx::helpers::ByteBuffer::ByteBuffer ( char * data,
size_t capacity )

A capacity sized area of memory at data.

◆ ~ByteBuffer()

log4cxx::helpers::ByteBuffer::~ByteBuffer ( )

Member Function Documentation

◆ carry()

void log4cxx::helpers::ByteBuffer::carry ( )

Move the remaining bytes to the start of the memory area and set the cursor to the end of the those bytes.

◆ clear()

void log4cxx::helpers::ByteBuffer::clear ( )

Set the cursor to the start of the memory area and use the capacity as the extent to which the cursor can advance.

◆ current() [1/2]

char * log4cxx::helpers::ByteBuffer::current ( )

The memory at the cursor position.

◆ current() [2/2]

const char * log4cxx::helpers::ByteBuffer::current ( ) const

The memory at the cursor position.

◆ data() [1/2]

char * log4cxx::helpers::ByteBuffer::data ( )

The start of the memory area.

◆ data() [2/2]

const char * log4cxx::helpers::ByteBuffer::data ( ) const

The start of the memory area.

◆ flip()

void log4cxx::helpers::ByteBuffer::flip ( )

Set the extent to which the cursor can advance, limit(), to the current cursor position and move the cursor to the start of the memory area.

◆ increment_position()

size_t log4cxx::helpers::ByteBuffer::increment_position ( size_t byteCount)

Advance the cursor by byteCount if that does not exceed the extent to which the cursor can advance, otherwise set the cursor to the extent to which the cursor can advance.

Returns
The number of bytes until the cursor can no longer advance.

◆ limit() [1/2]

size_t log4cxx::helpers::ByteBuffer::limit ( ) const

The extent to which the cursor can advance as an offset from the start of the memory area.

Intially this is the capacity of the buffer.

◆ limit() [2/2]

void log4cxx::helpers::ByteBuffer::limit ( size_t newLimit)

Use newLimit as the extent to which the cursor can advance.

If newLimit exceeds the memory capacity, an exception is thrown. If the current cursor is currently beyond newLimit the cursor is changed to be at newLimit.

Deprecated
This function is deprecated and will be removed in a future version.

◆ position() [1/2]

size_t log4cxx::helpers::ByteBuffer::position ( ) const

The offset of the current cursor from the start of the memory area.

◆ position() [2/2]

void log4cxx::helpers::ByteBuffer::position ( size_t newPosition)

Use newPosition as the cursor position providing it is less than the extent to which the cursor can advance, otherwise set the cursor to the extent to which the cursor can advance.

Deprecated
This function is deprecated and will be removed in a future version.

◆ put()

bool log4cxx::helpers::ByteBuffer::put ( char byteValue)

Store byteValue at the cursor position and advance the cursor position unless the cursor cannot advance any further.

Returns
true if byteValue was stored in the buffer.

◆ remaining()

size_t log4cxx::helpers::ByteBuffer::remaining ( ) const

The number of bytes from the current cursor until the cursor can no longer advance.


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