Oracle Coherence for C++ API
Release 3.7.1.0

E22845-01

AbstractWriteBuffer Class Reference

#include <coherence/io/AbstractWriteBuffer.hpp>

Inherits Object, and WriteBuffer.

Inherited by DelegatingWriteBuffer, and OctetArrayWriteBuffer.

List of all members.


Detailed Description

The AbstractWriteBuffer is a partial implementation of the WriteBuffer interface intended to be used as a base class for easily creating concrete WriteBuffer implementations.

This implementation is explicitly not thread-safe.

Author:
jh 2008.01.08
 

Public Types

typedef spec::Handle Handle
 AbstractWriteBuffer Handle definition.
typedef spec::View View
 AbstractWriteBuffer View definition.
typedef spec::Holder Holder
 AbstractWriteBuffer Holder definition.
typedef this_spec::Handle Handle
 WriteBuffer Handle definition.
typedef this_spec::View View
 WriteBuffer View definition.
typedef this_spec::Holder Holder
 WriteBuffer Holder definition.
typedef TypedHandle
< const
coherence::util::Binary
BinaryView
 Binary View definition.

Public Member Functions

virtual size32_t getMaximumCapacity () const
 Determine the maximum number of octets that the buffer can hold.

If the maximum size is greater than the current size, then the buffer is expected to resize itself as necessary up to the maximum size in order to contain the data given to it.

Returns:
the maximum number of octets of data that the WriteBuffer can hold
virtual void write (size32_t ofDest, Array< octet_t >::View vabSrc)
 Store the specified octets at the specified offset within the buffer.

For purposes of side-effects and potential exceptions, this method is functionally equivalent to the following code:

 write(ofDest, vabSrc, 0, vabSrc.length);
 

Parameters:
 ofDest the offset within this buffer to store the passed data
 vabSrc the array of octets to store in this buffer
virtual void write (size32_t ofDest, ReadBuffer::View vBufSrc)
 Store the contents of the specified ReadBuffer at the specified offset within this buffer.

For purposes of side-effects and potential exceptions, this method is functionally equivalent to the following code:

 Array<octet_t>::View vabSrc = vBufSrc->toOctetArray();
 write(ofDest, vabSrc, 0, vabSrc->length);
 

Parameters:
 ofDest the offset within this buffer to store the passed data
 vBufSrc the array of octets to store in this buffer
virtual void write (size32_t ofDest, ReadBuffer::View vBufSrc, size32_t ofSrc, size32_t cbSrc)
 Store the specified portion of the contents of the specified ReadBuffer at the specified offset within this buffer.

For purposes of side-effects and potential exceptions, this method is functionally equivalent to the following code:

 Array<octet_t>::View vabSrc = vbufSrc.toOctetArray(ofSrc, cbSrc);
 write(ofDest, vabSrc, 0, vabSrc->length);
 

Parameters:
 ofDest the offset within this buffer to store the passed data
 vBufSrc the source ReadBuffer
 ofSrc the offset within the passed ReadBuffer to copy from
 cbSrc the number of octets to copy from the passed ReadBuffer
virtual void retain (size32_t of)
 Starting with the octet at offset of, retain the remainder of this WriteBuffer, such that the octet at offset of is shifted to offset 0, the octet at offset of + 1 is shifted to offset 1, and so on up to the octet at offset length() - 1, which is shifted to offset length() - of - 1.

After this method, the length of of the buffer as indicated by the length() method will be equal to length() - of.

This method is functionally equivalent to the following code:

 retain(of, length() - of);
 

Parameters:
 of the offset of the first octet within the WriteBuffer that will be retained
Exceptions:
 IndexOutOfBoundsException if of is greater than length()
virtual void clear ()
 Set the length of the buffer as indicated by the length() method to zero.

The effect on the capacity of the buffer is implementation-specific; some implementations are expected to retain the same capacity while others are expected to shrink accordingly.

virtual
WriteBuffer::Handle 
getWriteBuffer (size32_t of)
 Obtain a WriteBuffer starting at a particular offset within this WriteBuffer.

This is functionally equivalent to:

 return getWriteBuffer(of, getMaximumCapacity() - of);
 

Parameters:
 of the beginning index, inclusive
Returns:
a WriteBuffer that represents a portion of this WriteBuffer
Exceptions:
 IndexOutOfBoundsException if of is larger than the getMaximumCapacity() of this WriteBuffer
virtual
WriteBuffer::Handle 
getWriteBuffer (size32_t of, size32_t cb)
 Obtain a WriteBuffer for a portion of this WriteBuffer.

Use of the resulting buffer will correspond to using this buffer directly but with the offset being passed to the buffer methods automatically having of added. As a result, the length of this buffer can be modified by writing to the new buffer; however, changes made directly to this buffer will not affect the length of the new buffer.

Note that the resulting WriteBuffer is limited in the number of octets that can be written to it; in other words, its getMaximumCapacity() must return the same value as was passed in cb.

Parameters:
 of the offset of the first octet within this WriteBuffer to map to offset 0 of the new WriteBuffer
 cb the number of octets to cover in the resulting WriteBuffer
Returns:
a WriteBuffer that represents a portion of this WriteBuffer
Exceptions:
 IndexOutOfBoundsException if of + cb is larger than the getMaximumCapacity() of this WriteBuffer
virtual ReadBuffer::View getReadBuffer () const
 Get a ReadBuffer object that is a snapshot of this WriteBuffer's data.

This method is functionally equivalent to the following code:

 Array<octet_t>::View vab = toOctetArray();
 return OctetArrayReadBuffer::create(vab, 0, vab->length(), true);
 

Returns:
a ReadBuffer that reflects the point-in-time contents of this WriteBuffer; the returned ReadBuffer is inherently immutable
virtual Array
< octet_t >::View 
toOctetArray () const
 Returns an octet array that holds the complete contents of this WriteBuffer.

This method is functionally equivalent to the following code:

 return getUnsafeReadBuffer()->toOctetArray();
 

Returns:
the contents of this WriteBuffer as an octet array
virtual BinaryView toBinary () const
 Returns a new Binary object that holds the complete contents of this WriteBuffer.

This method is functionally equivalent to the following code:

 return getUnsafeReadBuffer()->toBinary();
 

Returns:
the contents of this WriteBuffer as a Binary object
Since:
Coherence 3.7.1
virtual
BufferOutput::Handle 
getBufferOutput (size32_t of=0)
 Get a BufferOutput object to write data to this buffer starting at a particular offset.

Note that each call to this method will return a new BufferOutput object, with the possible exception being that a zero-length non-resizing WriteBuffer could always return the same instance (since it is not writable).

Parameters:
 of the offset of the first octet of this buffer that the BufferOutput will write to
Returns:
a BufferOutput that will write to this buffer
virtual
BufferOutput::Handle 
getAppendingBufferOutput ()
 Get a BufferOutput object to write data to this buffer.

The BufferOutput object returned by this method is set to append to the WriteBuffer, meaning that its offset is pre-set to the length() of this buffer.

This is functionally equivalent to:

 return getBufferOutput(length());
 

Returns:
a BufferOutput configured to append to this buffer

Protected Member Functions

virtual
BufferOutput::Handle 
instantiateBufferOutput ()
 Factory method: Instantiate a BufferOutput object to write data to the WriteBuffer.
virtual Array
< octet_t >::Handle 
tmpbuf ()
 Get a small buffer for formating data.
virtual Array
< octet_t >::Handle 
tmpbuf (size32_t cb)
 Get a buffer for formating data.

Protected Attributes

MemberHandle< Array
< octet_t > > 
m_habBuf
 A temp buffer to use for building the data to write.

Classes

class  AbstractBufferOutput
 AbstractBufferOutput is a concrete implementation of BufferOutput for the non-concrete AbstractWriteBuffer implementation. More...

Member Function Documentation

virtual BufferOutput::Handle instantiateBufferOutput (  )  [protected, virtual]

Factory method: Instantiate a BufferOutput object to write data to the WriteBuffer.

Returns:
a new BufferOutput writing to this ReadBuffer

Reimplemented in DelegatingWriteBuffer, and OctetArrayWriteBuffer.

virtual Array<octet_t>::Handle tmpbuf (  )  [protected, virtual]

Get a small buffer for formating data.

Returns:
a small octet array

virtual Array<octet_t>::Handle tmpbuf ( size32_t  cb  )  [protected, virtual]

Get a buffer for formating data.

Parameters:
 cb the minimum size for the buffer
Returns:
an octet array that is at least cb octets long


The documentation for this class was generated from the following file:
Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.