OctetArrayReadBuffer Class Reference

#include <coherence/io/OctetArrayReadBuffer.hpp>

Inherits AbstractReadBuffer.

Inherited by Binary.

List of all members.


Detailed Description

A ReadBuffer on top of an octet array.

Author:
jh 2008.01.03

Public Types

typedef spec::Handle Handle
 OctetArrayReadBuffer Handle definition.
typedef spec::View View
 OctetArrayReadBuffer View definition.
typedef spec::Holder Holder
 OctetArrayReadBuffer Holder definition.
typedef this_spec::Handle Handle
 AbstractReadBuffer Handle definition.
typedef this_spec::View View
 AbstractReadBuffer View definition.
typedef this_spec::Holder Holder
 AbstractReadBuffer Holder definition.

Public Member Functions

virtual size32_t length () const
 Determine the length of the buffer.

Returns:
the number of octets of data represented by this ReadBuffer

virtual octet_t read (size32_t of) const
 Returns the octet at the specified offset.

An offset ranges from 0 to length() - 1. The first octet of the sequence is at offset 0, the next at offset 1, and so on, as for array indexing.

Parameters:
of the offset (index) of the octet
Returns:
the octet at the specified offset in this ReadBuffer
Exceptions:
IndexOutOfBoundsException if the of argument is not less than the length of this ReadBuffer

virtual void read (size32_t ofBegin, size32_t ofEnd, Array< octet_t >::Handle habDest, size32_t ofDest) const
 Copies octets from this ReadBuffer into the destination octet array.

The first octet to be copied is at offset ofBegin; the last octet to be copied is at offset ofEnd-1 (thus the total number of octets to be copied is ofEnd - ofBegin). The octets are copied into the subarray of habDest starting at offset ofDest and ending at index:

     ofDest + (ofEnd - ofBegin) - 1
 
This method allows the caller to extract a chunk of octets into the caller's own array.

Parameters:
ofBegin offset of the first octet in the ReadBuffer to copy
ofEnd offset after the last octet in the ReadBuffer to copy
habDest the destination octet array
ofDest the offset in the destination octet array to copy the first octet to
Exceptions:
IndexOutOfBoundsException if any of the following is true:
  • ofBegin is greater than ofEnd
  • ofEnd is greater than the length of this ReadBuffer;
  • ofDest + (ofEnd - ofBegin) is larger than habDest->length
NullPointerException if habDest is NULL

virtual Array
< octet_t >::View 
toOctetArray (size32_t of, size32_t cb) const
 Get a portion of the contents of the ReadBuffer as an octet array.

Parameters:
of the beginning index, inclusive
cb the number of octets to include in the resulting array
Returns:
an octet array containing the specified portion of this ReadBuffer
Exceptions:
IndexOutOfBoundsException if of + cb is larger than the length of this ReadBuffer

virtual void toStream (std::ostream &out) const
 Output a human-readable description of this Object to the given stream.

coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toStream method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents.

 Object::View vKey   = ...
 Object::View vValue = ...
 std::cout << vKey << " = " << vValue << std::endl;

 String::Handle hs = COH_TO_STRING(vKey << " = " << vValue);

Parameters:
out the stream used to output the description


Protected Member Functions

 OctetArrayReadBuffer (Array< octet_t >::View vab, size32_t of, size32_t cb, bool fCopy=false)
 Construct an OctetArrayReadBuffer object from a portion of an octet array.
 OctetArrayReadBuffer (const OctetArrayReadBuffer &that)
 Copy constructor.
virtual void updateLength (size32_t cb)
 Allow the length to be modified.
virtual ReadBuffer::View instantiateReadBuffer (size32_t of, size32_t cb) const
 Factory method: Instantiate a ReadBuffer for a portion of this ReadBuffer.

Parameters:
of the beginning index, inclusive
cb the number of bytes to include in the resulting ReadBuffer
Returns:
a ReadBuffer that represents a portion of this ReadBuffer

virtual
BufferInput::Handle 
instantiateBufferInput () const
 Factory method: Instantiate a BufferInput object to read data from the ReadBuffer.

Returns:
a new BufferInput reading from this ReadBuffer


Protected Attributes

FinalView< Array
< octet_t > > 
m_vab
 The octet array that holds the binary data.
size32_t m_of
 Offset into the octet array at which the binary data is located.
size32_t m_cb
 Number of octets in the octet array that belong to this ReadBuffer object.

Classes

class  OctetArrayBufferInput
 This is an implementation of the BufferInput interface on top of a octet array. More...

Constructor & Destructor Documentation

OctetArrayReadBuffer ( Array< octet_t >::View  vab,
size32_t  of,
size32_t  cb,
bool  fCopy = false 
) [protected]

Construct an OctetArrayReadBuffer object from a portion of an octet array.

Parameters:
vab an array of octets
of the offset into the octet array
cb the number of octets to extract
fCopy true to make a copy of the passed array


Member Function Documentation

virtual void updateLength ( size32_t  cb  )  [protected, virtual]

Allow the length to be modified.

This method is provided for use by OctetArrayWriteBuffer only, and only for read buffers that it owns.

Parameters:
cb the new length

Reimplemented in Binary.


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