activemq-cpp-3.6.0
decaf::io::ByteArrayOutputStream Class Reference

#include <src/main/decaf/io/ByteArrayOutputStream.h>

Inheritance diagram for decaf::io::ByteArrayOutputStream:

Public Member Functions

 ByteArrayOutputStream ()
 Default Constructor - uses a default internal buffer of 32 bytes, the size increases as the need for more room arises.
 ByteArrayOutputStream (int bufferSize)
 Creates a ByteArrayOutputStream with an internal buffer allocated with the given size.
virtual ~ByteArrayOutputStream ()
std::pair< unsigned char *, int > toByteArray () const
 Creates a newly allocated byte array.
long long size () const
 Gets the current count of bytes written into this ByteArrayOutputStream.
virtual void reset ()
 Clear current Stream contents.
virtual std::string toString () const
 Converts the bytes in the buffer into a standard C++ string.
void writeTo (OutputStream *out) const
 Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using out.write( buf, 0, count ).
- Public Member Functions inherited from decaf::io::OutputStream
 OutputStream ()
virtual ~OutputStream ()
virtual void close ()
 Closes this object and deallocates the appropriate resources.The object is generally no longer usable after calling close.
Exceptions
IOExceptionif an error occurs while closing.

virtual void flush ()
 Flushes this stream by writing any buffered output to the underlying stream.
Exceptions
IOExceptionif an I/O error occurs.

virtual void write (unsigned char c)
 Writes a single byte to the output stream.
virtual void write (const unsigned char *buffer, int size)
 Writes an array of bytes to the output stream.
virtual void write (const unsigned char *buffer, int size, int offset, int length)
 Writes an array of bytes to the output stream in order starting at buffer[offset] and proceeding until the number of bytes specified by the length argument are written or an error occurs.
virtual void lock ()
 Locks the object.
virtual bool tryLock ()
 Attempts to Lock the object, if the lock is already held by another thread than this method returns false.
virtual void unlock ()
 Unlocks the object.
virtual void wait ()
 Waits on a signal from this object, which is generated by a call to Notify.
virtual void wait (long long millisecs)
 Waits on a signal from this object, which is generated by a call to Notify.
virtual void wait (long long millisecs, int nanos)
 Waits on a signal from this object, which is generated by a call to Notify.
virtual void notify ()
 Signals a waiter on this object that it can now wake up and continue.
virtual void notifyAll ()
 Signals the waiters on this object that it can now wake up and continue.
- Public Member Functions inherited from decaf::io::Closeable
virtual ~Closeable ()
- Public Member Functions inherited from decaf::io::Flushable
virtual ~Flushable ()
- Public Member Functions inherited from decaf::util::concurrent::Synchronizable
virtual ~Synchronizable ()

Protected Member Functions

virtual void doWriteByte (unsigned char value)
virtual void doWriteArrayBounded (const unsigned char *buffer, int size, int offset, int length)
- Protected Member Functions inherited from decaf::io::OutputStream
virtual void doWriteArray (const unsigned char *buffer, int size)

Constructor & Destructor Documentation

decaf::io::ByteArrayOutputStream::ByteArrayOutputStream ( )

Default Constructor - uses a default internal buffer of 32 bytes, the size increases as the need for more room arises.

decaf::io::ByteArrayOutputStream::ByteArrayOutputStream ( int  bufferSize)

Creates a ByteArrayOutputStream with an internal buffer allocated with the given size.

Parameters
bufferSizeThe size to use for the internal buffer.
Exceptions
IllegalArgumentExceptionif the size is less than or equal to zero.
virtual decaf::io::ByteArrayOutputStream::~ByteArrayOutputStream ( )
virtual

Member Function Documentation

virtual void decaf::io::ByteArrayOutputStream::doWriteArrayBounded ( const unsigned char *  buffer,
int  size,
int  offset,
int  length 
)
protectedvirtual

Reimplemented from decaf::io::OutputStream.

virtual void decaf::io::ByteArrayOutputStream::doWriteByte ( unsigned char  value)
protectedvirtual
virtual void decaf::io::ByteArrayOutputStream::reset ( )
virtual

Clear current Stream contents.

Exceptions
IOException
long long decaf::io::ByteArrayOutputStream::size ( ) const

Gets the current count of bytes written into this ByteArrayOutputStream.

Returns
the number of valid bytes contained in the ByteArrayOutputStream.
std::pair<unsigned char*, int> decaf::io::ByteArrayOutputStream::toByteArray ( ) const

Creates a newly allocated byte array.

Its size is the current size of this output stream and the valid contents of the buffer have been copied into it. The newly allocated array and its size are returned inside an STL pair structure, the caller is responsible for freeing the returned array.

Returns
an STL pair containing the copied array and its size.
virtual std::string decaf::io::ByteArrayOutputStream::toString ( ) const
virtual

Converts the bytes in the buffer into a standard C++ string.

Returns
a string containing the bytes in the buffer

Reimplemented from decaf::io::OutputStream.

void decaf::io::ByteArrayOutputStream::writeTo ( OutputStream out) const

Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using out.write( buf, 0, count ).


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