activemq-cpp-3.6.0
decaf::nio::ByteBuffer Class Reference

This class defines six categories of operations upon byte buffers: More...

#include <src/main/decaf/nio/ByteBuffer.h>

Inheritance diagram for decaf::nio::ByteBuffer:

Public Member Functions

virtual ~ByteBuffer ()
virtual std::string toString () const
ByteBufferget (std::vector< unsigned char > buffer)
 Relative bulk get method.
ByteBufferget (unsigned char *buffer, int size, int offset, int length)
 Relative bulk get method.
ByteBufferput (ByteBuffer &src)
 This method transfers the bytes remaining in the given source buffer into this buffer.
ByteBufferput (const unsigned char *buffer, int size, int offset, int length)
 This method transfers bytes into this buffer from the given source array.
ByteBufferput (std::vector< unsigned char > &buffer)
 This method transfers the entire content of the given source byte array into this buffer.
virtual bool isReadOnly () const =0
 Tells whether or not this buffer is read-only.
virtual unsigned char * array ()=0
 Returns the byte array that backs this buffer.
virtual int arrayOffset () const =0
 Returns the offset within this buffer's backing array of the first element of the buffer.
virtual bool hasArray () const =0
 Tells whether or not this buffer is backed by an accessible byte array.
virtual CharBufferasCharBuffer () const =0
 Creates a view of this byte buffer as a char buffer.
virtual DoubleBufferasDoubleBuffer () const =0
 Creates a view of this byte buffer as a double buffer.
virtual FloatBufferasFloatBuffer () const =0
 Creates a view of this byte buffer as a float buffer.
virtual IntBufferasIntBuffer () const =0
 Creates a view of this byte buffer as a int buffer.
virtual LongBufferasLongBuffer () const =0
 Creates a view of this byte buffer as a long buffer.
virtual ShortBufferasShortBuffer () const =0
 Creates a view of this byte buffer as a short buffer.
virtual ByteBufferasReadOnlyBuffer () const =0
 Creates a new, read-only byte buffer that shares this buffer's content.
virtual ByteBuffercompact ()=0
 Compacts this buffer.
virtual ByteBufferduplicate ()=0
 Creates a new byte buffer that shares this buffer's content.
virtual unsigned char get () const =0
 Relative get method.
virtual unsigned char get (int index) const =0
 Absolute get method.
virtual char getChar ()=0
 Reads the next byte at this buffer's current position, and then increments the position by one.
virtual char getChar (int index) const =0
 Reads one byte at the given index and returns it.
virtual double getDouble ()=0
 Reads the next eight bytes at this buffer's current position, and then increments the position by that amount.
virtual double getDouble (int index) const =0
 Reads eight bytes at the given index and returns it.
virtual float getFloat ()=0
 Reads the next four bytes at this buffer's current position, and then increments the position by that amount.
virtual float getFloat (int index) const =0
 Reads four bytes at the given index and returns it.
virtual long long getLong ()=0
 Reads the next eight bytes at this buffer's current position, and then increments the position by that amount.
virtual long long getLong (int index) const =0
 Reads eight bytes at the given index and returns it.
virtual int getInt ()=0
 Reads the next four bytes at this buffer's current position, and then increments the position by that amount.
virtual int getInt (int index) const =0
 Reads four bytes at the given index and returns it.
virtual short getShort ()=0
 Reads the next two bytes at this buffer's current position, and then increments the position by that amount.
virtual short getShort (int index) const =0
 Reads two bytes at the given index and returns it.
virtual ByteBufferput (unsigned char value)=0
 Writes the given byte into this buffer at the current position, and then increments the position.
virtual ByteBufferput (int index, unsigned char value)=0
 Writes the given byte into this buffer at the given index.
virtual ByteBufferputChar (char value)=0
 Writes one byte containing the given value, into this buffer at the current position, and then increments the position by one.
virtual ByteBufferputChar (int index, char value)=0
 Writes one byte containing the given value, into this buffer at the given index.
virtual ByteBufferputDouble (double value)=0
 Writes eight bytes containing the given value, into this buffer at the current position, and then increments the position by eight.
virtual ByteBufferputDouble (int index, double value)=0
 Writes eight bytes containing the given value, into this buffer at the given index.
virtual ByteBufferputFloat (float value)=0
 Writes four bytes containing the given value, into this buffer at the current position, and then increments the position by eight.
virtual ByteBufferputFloat (int index, float value)=0
 Writes four bytes containing the given value, into this buffer at the given index.
virtual ByteBufferputLong (long long value)=0
 Writes eight bytes containing the given value, into this buffer at the current position, and then increments the position by eight.
virtual ByteBufferputLong (int index, long long value)=0
 Writes eight bytes containing the given value, into this buffer at the given index.
virtual ByteBufferputInt (int value)=0
 Writes four bytes containing the given value, into this buffer at the current position, and then increments the position by eight.
virtual ByteBufferputInt (int index, int value)=0
 Writes four bytes containing the given value, into this buffer at the given index.
virtual ByteBufferputShort (short value)=0
 Writes two bytes containing the given value, into this buffer at the current position, and then increments the position by eight.
virtual ByteBufferputShort (int index, short value)=0
 Writes two bytes containing the given value, into this buffer at the given index.
virtual ByteBufferslice () const =0
 Creates a new byte buffer whose content is a shared subsequence of this buffer's content.
virtual int compareTo (const ByteBuffer &value) const
 
virtual bool equals (const ByteBuffer &value) const
 
virtual bool operator== (const ByteBuffer &value) const
 
virtual bool operator< (const ByteBuffer &value) const
 
- Public Member Functions inherited from decaf::nio::Buffer
 Buffer (int capactiy)
 Buffer (const Buffer &other)
virtual ~Buffer ()
virtual int capacity () const
virtual int position () const
virtual Bufferposition (int newPosition)
 Sets this buffer's position.
virtual int limit () const
virtual Bufferlimit (int newLimit)
 Sets this buffer's limit.
virtual Buffermark ()
 Sets this buffer's mark at its position.
virtual Bufferreset ()
 Resets this buffer's position to the previously-marked position.
virtual Bufferclear ()
 Clears this buffer.
virtual Bufferflip ()
 Flips this buffer.
virtual Bufferrewind ()
 Rewinds this buffer.
virtual int remaining () const
 Returns the number of elements between the current position and the limit.
virtual bool hasRemaining () const
 Tells whether there are any elements between the current position and the limit.
- Public Member Functions inherited from decaf::lang::Comparable< ByteBuffer >
virtual ~Comparable ()
virtual int compareTo (const ByteBuffer &value) const =0
 Compares this object with the specified object for order.
virtual bool equals (const ByteBuffer &value) const =0
virtual bool operator== (const ByteBuffer &value) const =0
 Compares equality between this object and the one passed.
virtual bool operator< (const ByteBuffer &value) const =0
 Compares this object to another and returns true if this object is considered to be less than the one passed.

Static Public Member Functions

static ByteBufferallocate (int capacity)
 Allocates a new byte buffer whose position will be zero its limit will be its capacity and its mark is not set.
static ByteBufferwrap (unsigned char *array, int size, int offset, int length)
 Wraps the passed buffer with a new ByteBuffer.
static ByteBufferwrap (std::vector< unsigned char > &buffer)
 Wraps the passed STL Byte Vector in a ByteBuffer.

Protected Member Functions

 ByteBuffer (int capacity)
 Creates a ByteBuffer object that has its backing array allocated internally and is then owned and deleted when this object is deleted.

Additional Inherited Members

- Protected Attributes inherited from decaf::nio::Buffer
int _position
int _capacity
int _limit
int _mark
bool _markSet

Detailed Description

This class defines six categories of operations upon byte buffers:

  1. Absolute and relative get and put methods that read and write single bytes;
  2. Relative bulk get methods that transfer contiguous sequences of bytes from this buffer into an array;
  3. Relative bulk put methods that transfer contiguous sequences of bytes from a byte array or some other byte buffer into this buffer;
  4. Absolute and relative get and put methods that read and write values of other primitive types, translating them to and from sequences of bytes in a particular byte order;
  5. Methods for creating view buffers, which allow a byte buffer to be viewed as a buffer containing values of some other primitive type; and
  6. Methods for compacting, duplicating, and slicing a byte buffer.

Byte buffers can be created either by allocation, which allocates space for the buffer's content, or by wrapping an existing byte array into a buffer.

Access to binary data:

This class defines methods for reading and writing values of all other primitive types, except boolean. Primitive values are translated to (or from) sequences of bytes according to the buffer's current byte order.

For access to heterogeneous binary data, that is, sequences of values of different types, this class defines a family of absolute and relative get and put methods for each type. For 32-bit floating-point values, for example, this class defines:

float getFloat() float getFloat(int index) void putFloat(float f) void putFloat(int index, float f)

Corresponding methods are defined for the types char, short, int, long, and double. The index parameters of the absolute get and put methods are in terms of bytes rather than of the type being read or written.

For access to homogeneous binary data, that is, sequences of values of the same type, this class defines methods that can create views of a given byte buffer. A view buffer is simply another buffer whose content is backed by the byte buffer. Changes to the byte buffer's content will be visible in the view buffer, and vice versa; the two buffers' position, limit, and mark values are independent. The asFloatBuffer method, for example, creates an instance of the FloatBuffer class that is backed by the byte buffer upon which the method is invoked. Corresponding view-creation methods are defined for the types char, short, int, long, and double.

View buffers have two important advantages over the families of type-specific get and put methods described above:

A view buffer is indexed not in terms of bytes but rather in terms of the type-specific size of its values;

A view buffer provides relative bulk get and put methods that can transfer contiguous sequences of values between a buffer and an array or some other buffer of the same type; and

Constructor & Destructor Documentation

decaf::nio::ByteBuffer::ByteBuffer ( int  capacity)
protected

Creates a ByteBuffer object that has its backing array allocated internally and is then owned and deleted when this object is deleted.

The array is initially created with all elements initialized to zero.

Parameters
capacityThe size of the array, this is the limit we read and write to.
Exceptions
IllegalArgumentExceptionif capacity is negative.
virtual decaf::nio::ByteBuffer::~ByteBuffer ( )
inlinevirtual

Member Function Documentation

static ByteBuffer* decaf::nio::ByteBuffer::allocate ( int  capacity)
static

Allocates a new byte buffer whose position will be zero its limit will be its capacity and its mark is not set.

Parameters
capacityThe internal buffer's capacity.
Returns
a newly allocated ByteBuffer which the caller owns.
Exceptions
IllegalArgumentExceptionif capacity is negative.
virtual unsigned char* decaf::nio::ByteBuffer::array ( )
pure virtual

Returns the byte array that backs this buffer.

Modifications to this buffer's content will cause the returned array's content to be modified, and vice versa.

Invoke the hasArray method before invoking this method in order to ensure that this buffer has an accessible backing array.

Returns
The array that backs this buffer
Exceptions
ReadOnlyBufferExceptionif this buffer is backed by an array but is read-only
UnsupportedOperationExceptionif this buffer is not backed by an accessible array

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual int decaf::nio::ByteBuffer::arrayOffset ( ) const
pure virtual

Returns the offset within this buffer's backing array of the first element of the buffer.

If this buffer is backed by an array then buffer position p corresponds to array index p + arrayOffset().

Invoke the hasArray method before invoking this method in order to ensure that this buffer has an accessible backing array.

Returns
The offset within this buffer's array of the first element of the buffer.
Exceptions
ReadOnlyBufferExceptionif this buffer is backed by an array but is read-only.
UnsupportedOperationExceptionif this buffer is not backed by an accessible array.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual CharBuffer* decaf::nio::ByteBuffer::asCharBuffer ( ) const
pure virtual

Creates a view of this byte buffer as a char buffer.

The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.

The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer, and its mark will be undefined. The new buffer will be read-only if, and only if, this buffer is read-only.

Returns
the new Char Buffer, which the caller then owns.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual DoubleBuffer* decaf::nio::ByteBuffer::asDoubleBuffer ( ) const
pure virtual

Creates a view of this byte buffer as a double buffer.

The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.

The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by eight, and its mark will be undefined. The new buffer will be read-only if, and only if, this buffer is read-only.

Returns
the new double Buffer, which the caller then owns.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual FloatBuffer* decaf::nio::ByteBuffer::asFloatBuffer ( ) const
pure virtual

Creates a view of this byte buffer as a float buffer.

The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.

The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by four, and its mark will be undefined. The new buffer will be read-only if, and only if, this buffer is read-only.

Returns
the new float Buffer, which the caller then owns.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual IntBuffer* decaf::nio::ByteBuffer::asIntBuffer ( ) const
pure virtual

Creates a view of this byte buffer as a int buffer.

The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.

The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by four, and its mark will be undefined. The new buffer will be read-only if, and only if, this buffer is read-only.

Returns
the new int Buffer, which the caller then owns.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual LongBuffer* decaf::nio::ByteBuffer::asLongBuffer ( ) const
pure virtual

Creates a view of this byte buffer as a long buffer.

The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.

The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by eight, and its mark will be undefined. The new buffer will be read-only if, and only if, this buffer is read-only.

Returns
the new long Buffer, which the caller then owns.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer* decaf::nio::ByteBuffer::asReadOnlyBuffer ( ) const
pure virtual

Creates a new, read-only byte buffer that shares this buffer's content.

The content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer; the new buffer itself, however, will be read-only and will not allow the shared content to be modified. The two buffers' position, limit, and mark values will be independent.

If this buffer is itself read-only then this method behaves in exactly the same way as the duplicate method.

The new buffer's capacity, limit, position, and mark values will be identical to those of this buffer.

Returns
The new, read-only byte buffer which the caller then owns.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ShortBuffer* decaf::nio::ByteBuffer::asShortBuffer ( ) const
pure virtual

Creates a view of this byte buffer as a short buffer.

The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.

The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by two, and its mark will be undefined. The new buffer will be read-only if, and only if, this buffer is read-only.

Returns
the new short Buffer, which the caller then owns.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::compact ( )
pure virtual

Compacts this buffer.

The bytes between the buffer's current position and its limit, if any, are copied to the beginning of the buffer. That is, the byte at index p = position() is copied to index zero, the byte at index p + 1 is copied to index one, and so forth until the byte at index limit() - 1 is copied to index n = limit() - 1 - p. The buffer's position is then set to n+1 and its limit is set to its capacity. The mark, if defined, is discarded.

The buffer's position is set to the number of bytes copied, rather than to zero, so that an invocation of this method can be followed immediately by an invocation of another relative put method.

Returns
a reference to this ByteBuffer.
Exceptions
ReadOnlyBufferExceptionif this buffer is read-only.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual int decaf::nio::ByteBuffer::compareTo ( const ByteBuffer value) const
virtual

virtual ByteBuffer* decaf::nio::ByteBuffer::duplicate ( )
pure virtual

Creates a new byte buffer that shares this buffer's content.

The content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.

The new buffer's capacity, limit, position, and mark values will be identical to those of this buffer. The new buffer will be read-only if, and only if, this buffer is read-only.

Returns
a new Byte Buffer which the caller owns.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual bool decaf::nio::ByteBuffer::equals ( const ByteBuffer value) const
virtual

ByteBuffer& decaf::nio::ByteBuffer::get ( std::vector< unsigned char >  buffer)

Relative bulk get method.

This method transfers bytes from this buffer into the given destination vector. An invocation of this method of the form src.get(a) behaves in exactly the same way as the invocation. The vector must be sized to the amount of data that is to be read, that is to say, the caller should call buffer.resize( N ) before calling this get method.

Returns
a reference to this Byte Buffer.
Exceptions
BufferUnderflowExceptionif there are fewer than length bytes remaining in this buffer
ByteBuffer& decaf::nio::ByteBuffer::get ( unsigned char *  buffer,
int  size,
int  offset,
int  length 
)

Relative bulk get method.

This method transfers bytes from this buffer into the given destination array. If there are fewer bytes remaining in the buffer than are required to satisfy the request, that is, if length > remaining(), then no bytes are transferred and a BufferUnderflowException is thrown.

Otherwise, this method copies length bytes from this buffer into the given array, starting at the current position of this buffer and at the given offset in the array. The position of this buffer is then incremented by length.

Parameters
bufferThe pointer to an allocated buffer to fill.
sizeThe size of the passed in Buffer.
offsetThe position in the buffer to start filling.
lengthThe amount of data to put in the passed buffer.
Returns
a reference to this Buffer.
Exceptions
IndexOutOfBoundsExceptionif the preconditions of size, offset, or length are not met.
BufferUnderflowExceptionif there are fewer than length bytes remaining in this buffer.
NullPointerExceptionif the passed buffer is null.
virtual unsigned char decaf::nio::ByteBuffer::get ( ) const
pure virtual

Relative get method.

Reads the byte at this buffer's current position, and then increments the position.

Returns
The byte at the buffer's current position.
Exceptions
BufferUnderflowExceptionif the buffer's current position is not smaller than its limit.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual unsigned char decaf::nio::ByteBuffer::get ( int  index) const
pure virtual

Absolute get method.

Reads the byte at the given index.

Parameters
indexThe index in the Buffer where the byte is to be read.
Returns
the byte that is located at the given index.
Exceptions
IndexOutOfBoundsExceptionif index is not smaller than the buffer's limit, or index is negative.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual char decaf::nio::ByteBuffer::getChar ( )
pure virtual

Reads the next byte at this buffer's current position, and then increments the position by one.

Returns
the next char in the buffer.
Exceptions
BufferUnderflowExceptionif there are no more bytes remaining in this buffer, meaning we have reached the set limit.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual char decaf::nio::ByteBuffer::getChar ( int  index) const
pure virtual

Reads one byte at the given index and returns it.

Parameters
indexThe index in the Buffer where the byte is to be read.
Returns
the char at the given index in the buffer
Exceptions
IndexOutOfBoundsExceptionif index is not smaller than the buffer's limit, or index is negative.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual double decaf::nio::ByteBuffer::getDouble ( )
pure virtual

Reads the next eight bytes at this buffer's current position, and then increments the position by that amount.

Returns
the next double in the buffer.
Exceptions
BufferUnderflowExceptionif there are no more bytes remaining in this buffer, meaning we have reached the set limit.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual double decaf::nio::ByteBuffer::getDouble ( int  index) const
pure virtual

Reads eight bytes at the given index and returns it.

Parameters
indexThe index in the Buffer where the bytes are to be read.
Returns
the double at the given index in the buffer.
Exceptions
IndexOutOfBoundsExceptionif index is not smaller than the buffer's limit, or index is negative.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual float decaf::nio::ByteBuffer::getFloat ( )
pure virtual

Reads the next four bytes at this buffer's current position, and then increments the position by that amount.

Returns
the next float in the buffer.
Exceptions
BufferUnderflowExceptionif there are no more bytes remaining in this buffer, meaning we have reached the set limit.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual float decaf::nio::ByteBuffer::getFloat ( int  index) const
pure virtual

Reads four bytes at the given index and returns it.

Parameters
indexThe index in the Buffer where the bytes are to be read.
Returns
the float at the given index in the buffer.
Exceptions
IndexOutOfBoundsExceptionif there are not enough bytes remaining to fill the requested Data Type, or index is negative.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual int decaf::nio::ByteBuffer::getInt ( )
pure virtual

Reads the next four bytes at this buffer's current position, and then increments the position by that amount.

Returns
the next int in the buffer.
Exceptions
BufferUnderflowExceptionif there are no more bytes remaining in this buffer, meaning we have reached the set limit.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual int decaf::nio::ByteBuffer::getInt ( int  index) const
pure virtual

Reads four bytes at the given index and returns it.

Parameters
indexThe index in the Buffer where the bytes are to be read.
Returns
the int at the given index in the buffer.
Exceptions
IndexOutOfBoundsExceptionif there are not enough bytes remaining to fill the requested Data Type, or index is negative.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual long long decaf::nio::ByteBuffer::getLong ( )
pure virtual

Reads the next eight bytes at this buffer's current position, and then increments the position by that amount.

Returns
the next long long in the buffer.
Exceptions
BufferUnderflowExceptionif there are no more bytes remaining in this buffer, meaning we have reached the set limit.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual long long decaf::nio::ByteBuffer::getLong ( int  index) const
pure virtual

Reads eight bytes at the given index and returns it.

Parameters
indexThe index in the Buffer where the bytes are to be read.
Returns
the long long at the given index in the buffer.
Exceptions
IndexOutOfBoundsExceptionif there are not enough bytes remaining to fill the requested Data Type, or index is negative.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual short decaf::nio::ByteBuffer::getShort ( )
pure virtual

Reads the next two bytes at this buffer's current position, and then increments the position by that amount.

Returns
the next short in the buffer.
Exceptions
BufferUnderflowExceptionif there are no more bytes remaining in this buffer, meaning we have reached the set limit.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual short decaf::nio::ByteBuffer::getShort ( int  index) const
pure virtual

Reads two bytes at the given index and returns it.

Parameters
indexThe index in the Buffer where the bytes are to be read.
Returns
the short at the given index in the buffer.
Exceptions
IndexOutOfBoundsExceptionif there are not enough bytes remaining to fill the requested Data Type, or index is negative.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual bool decaf::nio::ByteBuffer::hasArray ( ) const
pure virtual

Tells whether or not this buffer is backed by an accessible byte array.

If this method returns true then the array and arrayOffset methods may safely be invoked. Subclasses should override this method if they do not have a backing array as this class always returns true.

Returns
true if, and only if, this buffer is backed by an array and is not read-only.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual bool decaf::nio::ByteBuffer::isReadOnly ( ) const
pure virtual

Tells whether or not this buffer is read-only.

Returns
true if, and only if, this buffer is read-only

Implements decaf::nio::Buffer.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual bool decaf::nio::ByteBuffer::operator< ( const ByteBuffer value) const
virtual

virtual bool decaf::nio::ByteBuffer::operator== ( const ByteBuffer value) const
virtual

ByteBuffer& decaf::nio::ByteBuffer::put ( ByteBuffer src)

This method transfers the bytes remaining in the given source buffer into this buffer.

If there are more bytes remaining in the source buffer than in this buffer, that is, if src.remaining() > remaining(), then no bytes are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies n = src.remaining() bytes from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.

Parameters
srcThe buffer to take bytes from an place in this one.
Returns
a reference to this buffer
Exceptions
BufferOverflowExceptionif there is insufficient space in this buffer for the remaining bytes in the source buffer
IllegalArgumentExceptionif the source buffer is this buffer
ReadOnlyBufferExceptionif this buffer is read-only
ByteBuffer& decaf::nio::ByteBuffer::put ( const unsigned char *  buffer,
int  size,
int  offset,
int  length 
)

This method transfers bytes into this buffer from the given source array.

If there are more bytes to be copied from the array than remain in this buffer, that is, if length > remaining(), then no bytes are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies length bytes from the given array into this buffer, starting at the given offset in the array and at the current position of this buffer. The position of this buffer is then incremented by length.

Parameters
bufferThe array from which bytes are to be read.
sizeThe size of the given array.
offsetThe offset within the array of the first byte to be read.
lengthThe number of bytes to be read from the given array.
Returns
a reference to this buffer.
Exceptions
BufferOverflowExceptionif there is insufficient space in this buffer.
ReadOnlyBufferExceptionif this buffer is read-only.
NullPointerExceptionif the passed buffer is null.
IndexOutOfBoundsExceptionif the preconditions of size, offset, or length are not met.
ByteBuffer& decaf::nio::ByteBuffer::put ( std::vector< unsigned char > &  buffer)

This method transfers the entire content of the given source byte array into this buffer.

This is the same as calling put( &buffer[0], buffer.size(), 0, buffer.size() )

Parameters
bufferThe buffer whose contents are copied to this ByteBuffer.
Returns
a reference to this buffer.
Exceptions
BufferOverflowExceptionif there is insufficient space in this buffer.
ReadOnlyBufferExceptionif this buffer is read-only.
virtual ByteBuffer& decaf::nio::ByteBuffer::put ( unsigned char  value)
pure virtual

Writes the given byte into this buffer at the current position, and then increments the position.

Parameters
value- the byte value to be written.
Returns
a reference to this buffer.
Exceptions
BufferOverflowExceptionif this buffer's current position is not smaller than its limit.
ReadOnlyBufferExceptionif this buffer is read-only.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::put ( int  index,
unsigned char  value 
)
pure virtual

Writes the given byte into this buffer at the given index.

Parameters
index- position in the Buffer to write the data
value- the byte to write.
Returns
a reference to this buffer.
Exceptions
IndexOutOfBoundsExceptionif index greater than the buffer's limit minus the size of the type being written, or index is negative.
ReadOnlyBufferExceptionif this buffer is read-only.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::putChar ( char  value)
pure virtual

Writes one byte containing the given value, into this buffer at the current position, and then increments the position by one.

Parameters
valueThe value to be written.
Returns
a reference to this buffer.
Exceptions
BufferOverflowExceptionif there are fewer than bytes remaining in this buffer than the size of the data to be written
ReadOnlyBufferExceptionif this buffer is read-only

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::putChar ( int  index,
char  value 
)
pure virtual

Writes one byte containing the given value, into this buffer at the given index.

Parameters
indexThe position in the Buffer to write the data.
valueThe value to write.
Returns
a reference to this buffer.
Exceptions
IndexOutOfBoundsExceptionif index greater than the buffer's limit minus the size of the type being written, or index is negative.
ReadOnlyBufferExceptionif this buffer is read-only

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::putDouble ( double  value)
pure virtual

Writes eight bytes containing the given value, into this buffer at the current position, and then increments the position by eight.

Parameters
valueThe value to be written.
Returns
a reference to this buffer.
Exceptions
BufferOverflowExceptionif there are fewer than bytes remaining in this buffer than the size of the data to be written
ReadOnlyBufferExceptionif this buffer is read-only

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::putDouble ( int  index,
double  value 
)
pure virtual

Writes eight bytes containing the given value, into this buffer at the given index.

Parameters
indexThe position in the Buffer to write the data
valueThe value to write.
Returns
a reference to this buffer.
Exceptions
IndexOutOfBoundsExceptionif index greater than the buffer's limit minus the size of the type being written, or index is negative.
ReadOnlyBufferExceptionif this buffer is read-only.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::putFloat ( float  value)
pure virtual

Writes four bytes containing the given value, into this buffer at the current position, and then increments the position by eight.

Parameters
valueThe value to be written.
Returns
a reference to this buffer.
Exceptions
BufferOverflowExceptionif there are fewer than bytes remaining in this buffer than the size of the data to be written.
ReadOnlyBufferExceptionif this buffer is read-only.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::putFloat ( int  index,
float  value 
)
pure virtual

Writes four bytes containing the given value, into this buffer at the given index.

Parameters
indexThe position in the Buffer to write the data
valueThe value to write.
Returns
a reference to this buffer.
Exceptions
IndexOutOfBoundsExceptionif index greater than the buffer's limit minus the size of the type being written, or index is negative.
ReadOnlyBufferExceptionif this buffer is read-only.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::putInt ( int  value)
pure virtual

Writes four bytes containing the given value, into this buffer at the current position, and then increments the position by eight.

Parameters
valueThe value to be written.
Returns
a reference to this buffer.
Exceptions
BufferOverflowExceptionif there are fewer than bytes remaining in this buffer than the size of the data to be written
ReadOnlyBufferExceptionif this buffer is read-only

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::putInt ( int  index,
int  value 
)
pure virtual

Writes four bytes containing the given value, into this buffer at the given index.

Parameters
indexThe position in the Buffer to write the data.
valueThe value to write.
Returns
a reference to this buffer
Exceptions
IndexOutOfBoundsExceptionif index greater than the buffer's limit minus the size of the type being written, or index is negative.
ReadOnlyBufferExceptionif this buffer is read-only

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::putLong ( long long  value)
pure virtual

Writes eight bytes containing the given value, into this buffer at the current position, and then increments the position by eight.

Parameters
valueThe value to be written.
Returns
a reference to this buffer.
Exceptions
BufferOverflowExceptionif there are fewer than bytes remaining in this buffer than the size of the data to be written.
ReadOnlyBufferExceptionif this buffer is read-only.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::putLong ( int  index,
long long  value 
)
pure virtual

Writes eight bytes containing the given value, into this buffer at the given index.

Parameters
indexThe position in the Buffer to write the data.
valueThe value to write.
Returns
a reference to this buffer.
Exceptions
IndexOutOfBoundsExceptionif index greater than the buffer's limit minus the size of the type being written, or index is negative.
ReadOnlyBufferExceptionif this buffer is read-only.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::putShort ( short  value)
pure virtual

Writes two bytes containing the given value, into this buffer at the current position, and then increments the position by eight.

Parameters
valueThe value to be written.
Returns
a reference to this buffer.
Exceptions
BufferOverflowExceptionif there are fewer than bytes remaining in this buffer than the size of the data to be written.
ReadOnlyBufferExceptionif this buffer is read-only.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer& decaf::nio::ByteBuffer::putShort ( int  index,
short  value 
)
pure virtual

Writes two bytes containing the given value, into this buffer at the given index.

Parameters
indexThe position in the Buffer to write the data
valueThe value to write.
Returns
a reference to this buffer
Exceptions
IndexOutOfBoundsExceptionif index greater than the buffer's limit minus the size of the type being written, or index is negative.
ReadOnlyBufferExceptionif this buffer is read-only.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual ByteBuffer* decaf::nio::ByteBuffer::slice ( ) const
pure virtual

Creates a new byte buffer whose content is a shared subsequence of this buffer's content.

The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.

The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer, and its mark will be undefined. The new buffer will be read-only if, and only if, this buffer is read-only.

Returns
the newly create ByteBuffer which the caller owns.

Implemented in decaf::internal::nio::ByteArrayBuffer.

virtual std::string decaf::nio::ByteBuffer::toString ( ) const
virtual
Returns
a std::string describing this object
static ByteBuffer* decaf::nio::ByteBuffer::wrap ( unsigned char *  array,
int  size,
int  offset,
int  length 
)
static

Wraps the passed buffer with a new ByteBuffer.

The new buffer will be backed by the given byte array; that is, modifications to the buffer will cause the array to be modified and vice versa. The new buffer's capacity will be array.length, its position will be offset, its limit will be offset + length, and its mark will be undefined. Its backing array will be the given array, and its array offset will be zero.

Parameters
arrayThe array that will back the new buffer.
sizeThe size of the provided array.
offsetThe offset of the subarray to be used.
lengthThe length of the subarray to be used.
Returns
a new ByteBuffer that is backed by buffer, caller owns.
Exceptions
NullPointerExceptionif the array passed in is NULL.
IndexOutOfBoundsExceptionif the preconditions of size, offset, or length are not met.
static ByteBuffer* decaf::nio::ByteBuffer::wrap ( std::vector< unsigned char > &  buffer)
static

Wraps the passed STL Byte Vector in a ByteBuffer.

The new buffer will be backed by the given byte array; modifications to the buffer will cause the array to be modified and vice versa. The new buffer's capacity and limit will be buffer.size(), its position will be zero, and its mark will be undefined. Its backing array will be the given array, and its array offset will be zero.

Parameters
bufferThe vector that will back the new buffer, the vector must have been sized to the desired size already by calling vector.resize( N ).
Returns
a new ByteBuffer that is backed by buffer, caller owns.

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