You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by nm...@apache.org on 2006/12/15 02:47:19 UTC
svn commit: r487422 [1/2] - in
/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src: main/
main/activemq/connector/openwire/commands/
main/activemq/connector/stomp/commands/ main/activemq/io/
main/activemq/network/ main/cms/ test/activemq/connector/...
Author: nmittler
Date: Thu Dec 14 17:47:17 2006
New Revision: 487422
URL: http://svn.apache.org/viewvc?view=rev&rev=487422
Log:
[AMQCPP-16] - Updating ByteMessage to have a DataStream-like API (similar to the JMS BytesMessage)
Added:
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BlockingByteArrayInputStream.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BlockingByteArrayInputStream.h
Modified:
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedInputStream.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedInputStream.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedOutputStream.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayInputStream.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayInputStream.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayOutputStream.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayOutputStream.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/FilterInputStream.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/FilterOutputStream.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/InputStream.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/OutputStream.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/StandardErrorOutputStream.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/BytesMessage.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/BytesMessageCommandTest.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/io/BufferedInputStreamTest.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/io/BufferedOutputStreamTest.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/transport/IOTransportTest.h
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Thu Dec 14 17:47:17 2006
@@ -29,6 +29,7 @@
activemq/logger/LogManager.cpp \
activemq/logger/SimpleLogger.cpp \
activemq/support/InitDirector.cpp \
+ activemq/io/BlockingByteArrayInputStream.cpp \
activemq/io/ByteArrayInputStream.cpp \
activemq/io/BufferedInputStream.cpp \
activemq/io/DataInputStream.cpp \
@@ -103,6 +104,7 @@
activemq/support/LibraryInit.h \
activemq/support/InitDirector.h \
activemq/io/StandardErrorOutputStream.h \
+ activemq/io/BlockingByteArrayInputStream.h \
activemq/io/ByteArrayInputStream.h \
activemq/io/InputStream.h \
activemq/io/DataOutputStream.h \
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h Thu Dec 14 17:47:17 2006
@@ -433,6 +433,226 @@
* @return number of bytes.
*/
virtual unsigned long long getBodyLength(void) const;
+
+ /**
+ * Puts the message body in read-only mode and repositions the stream
+ * of bytes to the beginning.
+ * @throws CMSException
+ */
+ virtual void reset() throw ( cms::CMSException );
+
+ /**
+ * Reads a Boolean from the Bytes message stream
+ * @returns boolean value from stream
+ * @throws CMSException
+ */
+ virtual bool readBoolean() throw ( cms::CMSException );
+
+ /**
+ * Writes a boolean to the bytes message stream as a 1-byte value.
+ * The value true is written as the value (byte)1; the value false
+ * is written as the value (byte)0.
+ * @param value - boolean to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeBoolean( bool value ) throw ( cms::CMSException );
+
+ /**
+ * Reads a Byte from the Bytes message stream
+ * @returns unsigned char value from stream
+ * @throws CMSException
+ */
+ virtual unsigned char readByte() throw ( cms::CMSException );
+
+ /**
+ * Writes a byte to the bytes message stream as a 1-byte value
+ * @param value - byte to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeByte( unsigned char value ) throw ( cms::CMSException );
+
+
+ /**
+ * Reads a byte array from the bytes message stream.
+ *
+ * If the length of vector value is less than the number of bytes
+ * remaining to be read from the stream, the vector should be filled. A
+ * subsequent call reads the next increment, and so on.
+ *
+ * If the number of bytes remaining in the stream is less than the
+ * length of vector value, the bytes should be read into the vector. The
+ * return value of the total number of bytes read will be less than the
+ * length of the vector, indicating that there are no more bytes left to
+ * be read from the stream. The next read of the stream returns -1.
+ *
+ * @param value - buffer to place data in
+ * @returns the total number of bytes read into the buffer, or -1 if
+ * there is no more data because the end of the stream has
+ * been reached
+ * @throws CMSException if an error occurs.
+ */
+ virtual int readBytes( std::vector<unsigned char>& value )
+ throw ( cms::CMSException );
+
+ /**
+ * Writes a byte array to the bytes message stream using the vector
+ * size as the number of bytes to write.
+ * @param value - bytes to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeBytes( const std::vector<unsigned char>& value ) throw ( cms::CMSException );
+
+ /**
+ * Reads a portion of the bytes message stream.
+ *
+ * If the length of array value is less than the number of bytes
+ * remaining to be read from the stream, the array should be filled. A
+ * subsequent call reads the next increment, and so on.
+ *
+ * If the number of bytes remaining in the stream is less than the
+ * length of array value, the bytes should be read into the array. The
+ * return value of the total number of bytes read will be less than the
+ * length of the array, indicating that there are no more bytes left to
+ * be read from the stream. The next read of the stream returns -1.
+ *
+ * If length is negative, or length is greater than the length of the
+ * array value, then an IndexOutOfBoundsException is thrown. No bytes
+ * will be read from the stream for this exception case.
+ *
+ * @param value - the buffer into which the data is read
+ * @param length - the number of bytes to read; must be less than or
+ * equal to value.length
+ * @returns the total number of bytes read into the buffer, or -1 if
+ * there is no more data because the end of the stream has
+ * been reached
+ * @throws CMSException
+ */
+ virtual int readBytes( unsigned char*& buffer, int length )
+ throw ( cms::CMSException );
+
+ /**
+ * Writes a portion of a byte array to the bytes message stream.
+ * size as the number of bytes to write.
+ * @param value - bytes to write to the stream
+ * @param offset - the initial offset within the byte array
+ * @param length - the number of bytes to use
+ * @throws CMSException
+ */
+ virtual void writeBytes( const unsigned char* value,
+ int offset,
+ int length ) throw ( cms::CMSException );
+
+ /**
+ * Reads a Char from the Bytes message stream
+ * @returns char value from stream
+ * @throws CMSException
+ */
+ virtual char readChar() throw ( cms::CMSException );
+
+ /**
+ * Writes a char to the bytes message stream as a 1-byte value
+ * @param value - char to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeChar( char value ) throw ( cms::CMSException );
+
+ /**
+ * Reads a 32 bit float from the Bytes message stream
+ * @returns double value from stream
+ * @throws CMSException
+ */
+ virtual float readFloat() throw ( cms::CMSException );
+
+ /**
+ * Writes a float to the bytes message stream as a 4 byte value
+ * @param value - float to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeFloat( float value ) throw ( cms::CMSException );
+
+ /**
+ * Reads a 64 bit double from the Bytes message stream
+ * @returns double value from stream
+ * @throws CMSException
+ */
+ virtual double readDouble() throw ( cms::CMSException );
+
+ /**
+ * Writes a double to the bytes message stream as a 8 byte value
+ * @param value - double to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeDouble( double value ) throw ( cms::CMSException );
+
+ /**
+ * Reads a 16 bit signed short from the Bytes message stream
+ * @returns short value from stream
+ * @throws CMSException
+ */
+ virtual short readShort() throw ( cms::CMSException );
+
+ /**
+ * Writes a signed short to the bytes message stream as a 2 byte value
+ * @param value - signed short to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeShort( short value ) throw ( cms::CMSException );
+
+ /**
+ * Reads a 16 bit unsigned short from the Bytes message stream
+ * @returns unsigned short value from stream
+ * @throws CMSException
+ */
+ virtual unsigned short readUnsignedShort() throw ( cms::CMSException );
+
+ /**
+ * Writes a unsigned short to the bytes message stream as a 2 byte value
+ * @param value - unsigned short to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeUnsignedShort( unsigned short value ) throw ( cms::CMSException );
+
+ /**
+ * Reads a 32 bit signed intger from the Bytes message stream
+ * @returns int value from stream
+ * @throws CMSException
+ */
+ virtual int readInt() throw ( cms::CMSException );
+
+ /**
+ * Writes a signed int to the bytes message stream as a 4 byte value
+ * @param value - signed int to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeInt( int value ) throw ( cms::CMSException );
+
+ /**
+ * Reads a 64 bit long from the Bytes message stream
+ * @returns long long value from stream
+ * @throws CMSException
+ */
+ virtual long long readLong() throw ( cms::CMSException );
+
+ /**
+ * Writes a long long to the bytes message stream as a 8 byte value
+ * @param value - signed long long to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeLong( long long value ) throw ( cms::CMSException );
+
+ /**
+ * Reads an ASCII String from the Bytes message stream
+ * @returns String from stream
+ * @throws CMSException
+ */
+ virtual std::string readString() throw ( cms::CMSException );
+
+ /**
+ * Writes an ASCII String to the Bytes message stream
+ * @param value - String to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeString( const std::string& value ) throw ( cms::CMSException );
public: // ActiveMQMessage
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h Thu Dec 14 17:47:17 2006
@@ -22,6 +22,10 @@
#include <activemq/connector/stomp/commands/StompMessage.h>
#include <activemq/connector/stomp/commands/CommandConstants.h>
#include <activemq/exceptions/IllegalStateException.h>
+#include <activemq/io/ByteArrayInputStream.h>
+#include <activemq/io/ByteArrayOutputStream.h>
+#include <activemq/io/DataInputStream.h>
+#include <activemq/io/DataOutputStream.h>
namespace activemq{
namespace connector{
@@ -44,18 +48,53 @@
*/
bool readOnly;
+ /**
+ * InputStream that wraps around the frame's body when in read-only
+ * mode.
+ */
+ io::ByteArrayInputStream inputStream;
+
+ /**
+ * OutputStream that wraps around the frame's body when in write-only
+ * mode.
+ */
+ io::ByteArrayOutputStream outputStream;
+
+ /**
+ * DataInputStream wrapper around the input stream.
+ */
+ io::DataInputStream dataInputStream;
+
+ /**
+ * DataOutputStream wrapper around the output stream.
+ */
+ io::DataOutputStream dataOutputStream;
+
public:
+ /**
+ * Default constructor. Initializes in write-only mode.
+ */
BytesMessageCommand() :
- StompMessage< cms::BytesMessage >() {
+ StompMessage< cms::BytesMessage >(),
+ dataInputStream(&inputStream),
+ dataOutputStream(&outputStream)
+ {
initialize( getFrame() );
- readOnly = false;
+ clearBody();
}
+ /**
+ * Constructor for initialization in read-only mode.
+ * @param frame The stomp frame that was received from the broker.
+ */
BytesMessageCommand( StompFrame* frame ) :
- StompMessage< cms::BytesMessage >( frame ) {
+ StompMessage< cms::BytesMessage >( frame ),
+ dataInputStream(&inputStream),
+ dataOutputStream(&outputStream)
+ {
validate( getFrame() );
- readOnly = false;
+ reset();
}
virtual ~BytesMessageCommand() {}
@@ -71,6 +110,8 @@
// Set the stream in write only mode.
readOnly = false;
+
+ outputStream.setBuffer( getBytes() );
}
/**
@@ -80,6 +121,7 @@
*/
virtual void reset() throw ( cms::CMSException ){
readOnly = true;
+ inputStream.setBuffer( getBytes() );
}
/**
@@ -103,11 +145,7 @@
const unsigned long long numBytes )
throw( cms::CMSException ) {
- if( readOnly ){
- throw exceptions::IllegalStateException( __FILE__, __LINE__,
- "message is in read-only mode and cannot be written to" );
- }
-
+ checkWriteOnly();
this->setBytes( buffer, numBytes );
}
@@ -133,7 +171,316 @@
*/
virtual unsigned long long getBodyLength() const {
return this->getNumBytes();
- }
+ }
+
+ /**
+ * Reads a Boolean from the Bytes message stream
+ * @returns boolean value from stream
+ * @throws CMSException
+ */
+ virtual bool readBoolean() throw ( cms::CMSException ){
+ checkReadOnly();
+ return dataInputStream.readBoolean();
+ }
+
+ /**
+ * Writes a boolean to the bytes message stream as a 1-byte value.
+ * The value true is written as the value (byte)1; the value false
+ * is written as the value (byte)0.
+ * @param value - boolean to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeBoolean( bool value ) throw ( cms::CMSException ){
+ checkWriteOnly();
+ dataOutputStream.writeBoolean( value );
+ }
+
+ /**
+ * Reads a Byte from the Bytes message stream
+ * @returns unsigned char value from stream
+ * @throws CMSException
+ */
+ virtual unsigned char readByte() throw ( cms::CMSException ){
+ checkReadOnly();
+ return dataInputStream.readByte();
+ }
+
+ /**
+ * Writes a byte to the bytes message stream as a 1-byte value
+ * @param value - byte to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeByte( unsigned char value ) throw ( cms::CMSException ){
+ checkWriteOnly();
+ dataOutputStream.writeByte( value );
+ }
+
+ /**
+ * Reads a byte array from the bytes message stream.
+ *
+ * If the length of vector value is less than the number of bytes
+ * remaining to be read from the stream, the vector should be filled. A
+ * subsequent call reads the next increment, and so on.
+ *
+ * If the number of bytes remaining in the stream is less than the
+ * length of vector value, the bytes should be read into the vector. The
+ * return value of the total number of bytes read will be less than the
+ * length of the vector, indicating that there are no more bytes left to
+ * be read from the stream. The next read of the stream returns -1.
+ *
+ * @param value - buffer to place data in
+ * @returns the total number of bytes read into the buffer, or -1 if
+ * there is no more data because the end of the stream has
+ * been reached
+ * @throws CMSException if an error occurs.
+ */
+ virtual int readBytes( std::vector<unsigned char>& value )
+ throw ( cms::CMSException ){
+ checkReadOnly();
+ return dataInputStream.read( value );
+ }
+
+ /**
+ * Writes a byte array to the bytes message stream using the vector
+ * size as the number of bytes to write.
+ * @param value - bytes to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeBytes( const std::vector<unsigned char>& value )
+ throw ( cms::CMSException ){
+ checkWriteOnly();
+ dataOutputStream.write( value );
+ }
+
+ /**
+ * Reads a portion of the bytes message stream.
+ *
+ * If the length of array value is less than the number of bytes
+ * remaining to be read from the stream, the array should be filled. A
+ * subsequent call reads the next increment, and so on.
+ *
+ * If the number of bytes remaining in the stream is less than the
+ * length of array value, the bytes should be read into the array. The
+ * return value of the total number of bytes read will be less than the
+ * length of the array, indicating that there are no more bytes left to
+ * be read from the stream. The next read of the stream returns -1.
+ *
+ * If length is negative, or length is greater than the length of the
+ * array value, then an IndexOutOfBoundsException is thrown. No bytes
+ * will be read from the stream for this exception case.
+ *
+ * @param value - the buffer into which the data is read
+ * @param length - the number of bytes to read; must be less than or
+ * equal to value.length
+ * @returns the total number of bytes read into the buffer, or -1 if
+ * there is no more data because the end of the stream has
+ * been reached
+ * @throws CMSException
+ */
+ virtual int readBytes( unsigned char*& buffer, int length )
+ throw ( cms::CMSException ){
+ checkReadOnly();
+ return dataInputStream.read( buffer, 0, length );
+ }
+
+ /**
+ * Writes a portion of a byte array to the bytes message stream.
+ * size as the number of bytes to write.
+ * @param value - bytes to write to the stream
+ * @param offset - the initial offset within the byte array
+ * @param length - the number of bytes to use
+ * @throws CMSException
+ */
+ virtual void writeBytes( const unsigned char* value,
+ int offset,
+ int length ) throw ( cms::CMSException ){
+ checkWriteOnly();
+ dataOutputStream.write( value, offset, length );
+ }
+
+ /**
+ * Reads a Char from the Bytes message stream
+ * @returns char value from stream
+ * @throws CMSException
+ */
+ virtual char readChar() throw ( cms::CMSException ){
+ checkReadOnly();
+ return dataInputStream.readChar();
+ }
+
+ /**
+ * Writes a char to the bytes message stream as a 1-byte value
+ * @param value - char to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeChar( char value ) throw ( cms::CMSException ){
+ checkWriteOnly();
+ dataOutputStream.writeChar( value );
+ }
+
+ /**
+ * Reads a 32 bit float from the Bytes message stream
+ * @returns double value from stream
+ * @throws CMSException
+ */
+ virtual float readFloat() throw ( cms::CMSException ){
+ checkReadOnly();
+ return dataInputStream.readFloat();
+ }
+
+ /**
+ * Writes a float to the bytes message stream as a 4 byte value
+ * @param value - float to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeFloat( float value ) throw ( cms::CMSException ){
+ checkWriteOnly();
+ dataOutputStream.writeFloat( value );
+ }
+
+ /**
+ * Reads a 64 bit double from the Bytes message stream
+ * @returns double value from stream
+ * @throws CMSException
+ */
+ virtual double readDouble() throw ( cms::CMSException ){
+ checkReadOnly();
+ return dataInputStream.readDouble();
+ }
+
+ /**
+ * Writes a double to the bytes message stream as a 8 byte value
+ * @param value - double to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeDouble( double value ) throw ( cms::CMSException ){
+ checkWriteOnly();
+ dataOutputStream.writeDouble( value );
+ }
+
+ /**
+ * Reads a 16 bit signed short from the Bytes message stream
+ * @returns short value from stream
+ * @throws CMSException
+ */
+ virtual short readShort() throw ( cms::CMSException ){
+ checkReadOnly();
+ return dataInputStream.readShort();
+ }
+
+ /**
+ * Writes a signed short to the bytes message stream as a 2 byte value
+ * @param value - signed short to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeShort( short value ) throw ( cms::CMSException ){
+ checkWriteOnly();
+ dataOutputStream.writeShort( value );
+ }
+
+ /**
+ * Reads a 16 bit unsigned short from the Bytes message stream
+ * @returns unsigned short value from stream
+ * @throws CMSException
+ */
+ virtual unsigned short readUnsignedShort() throw ( cms::CMSException ){
+ checkReadOnly();
+ return dataInputStream.readUnsignedShort();
+ }
+
+ /**
+ * Writes a unsigned short to the bytes message stream as a 2 byte value
+ * @param value - unsigned short to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeUnsignedShort( unsigned short value ) throw ( cms::CMSException ){
+ checkWriteOnly();
+ dataOutputStream.writeUnsignedShort( value );
+ }
+
+ /**
+ * Reads a 32 bit signed intger from the Bytes message stream
+ * @returns int value from stream
+ * @throws CMSException
+ */
+ virtual int readInt() throw ( cms::CMSException ){
+ checkReadOnly();
+ return dataInputStream.readInt();
+ }
+
+ /**
+ * Writes a signed int to the bytes message stream as a 4 byte value
+ * @param value - signed int to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeInt( int value ) throw ( cms::CMSException ){
+ checkWriteOnly();
+ dataOutputStream.writeInt( value );
+ }
+
+ /**
+ * Reads a 64 bit long from the Bytes message stream
+ * @returns long long value from stream
+ * @throws CMSException
+ */
+ virtual long long readLong() throw ( cms::CMSException ){
+ checkReadOnly();
+ return dataInputStream.readLong();
+ }
+
+ /**
+ * Writes a long long to the bytes message stream as a 8 byte value
+ * @param value - signed long long to write to the stream
+ * @throws CMSException
+ */
+ virtual void writeLong( long long value ) throw ( cms::CMSException ){
+ checkWriteOnly();
+ dataOutputStream.writeLong( value );
+ }
+
+ /**
+ * Reads an ASCII String from the Bytes message stream
+ * @returns String from stream
+ * @throws CMSException
+ */
+ virtual std::string readString() throw ( cms::CMSException ){
+ checkReadOnly();
+ return dataInputStream.readString();
+ }
+
+ /**
+ * Writes an ASCII String to the Bytes message stream
+ * @param value The string to be written to the stream.
+ * @throws CMSException
+ */
+ virtual void writeString( const std::string& value ) throw ( cms::CMSException ){
+ checkWriteOnly();
+ dataOutputStream.writeBytes( value );
+ }
+
+ protected:
+
+ /**
+ * Throws an exception if not in write-only mode.
+ * @throws CMSException.
+ */
+ void checkWriteOnly() throw (cms::CMSException){
+ if( readOnly ){
+ throw exceptions::IllegalStateException( __FILE__, __LINE__,
+ "message is in read-only mode and cannot be written to" );
+ }
+ }
+
+ /**
+ * Throws an exception if not in read-only mode.
+ * @throws CMSException
+ */
+ void checkReadOnly() throw (cms::CMSException){
+ if( !readOnly ){
+ throw exceptions::IllegalStateException( __FILE__, __LINE__,
+ "message is in write-only mode and cannot be read from" );
+ }
+ }
};
Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BlockingByteArrayInputStream.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BlockingByteArrayInputStream.cpp?view=auto&rev=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BlockingByteArrayInputStream.cpp (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BlockingByteArrayInputStream.cpp Thu Dec 14 17:47:17 2006
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "BlockingByteArrayInputStream.h"
+#include <algorithm>
+
+using namespace activemq::io;
+using namespace std;
+
+////////////////////////////////////////////////////////////////////////////////
+BlockingByteArrayInputStream::BlockingByteArrayInputStream(){
+ pos = buffer.end();
+ closing = false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+BlockingByteArrayInputStream::BlockingByteArrayInputStream(
+ const unsigned char* buffer,
+ int bufferSize ){
+
+ closing = false;
+ setByteArray( buffer, bufferSize );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+BlockingByteArrayInputStream::~BlockingByteArrayInputStream(){
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BlockingByteArrayInputStream::setByteArray( const unsigned char* lbuffer,
+ int lbufferSize ){
+ synchronized( this ){
+
+ // Remove old data
+ this->buffer.clear();
+
+ // Copy data to internal buffer.
+ for( int ix = 0; ix < lbufferSize; ++ix )
+ {
+ this->buffer.push_back(lbuffer[ix]);
+ }
+
+ // Begin at the Beginning.
+ pos = this->buffer.begin();
+
+ // Notify any listening threds that there is now data available.
+ notifyAll();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BlockingByteArrayInputStream::close() throw (cms::CMSException){
+
+ synchronized( this ){
+
+ // Indicate that we're shutting down.
+ closing = true;
+
+ // Clear out the buffer.
+ buffer.clear();
+
+ // Notify that this stream is shutting down.
+ notifyAll();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned char BlockingByteArrayInputStream::read() throw ( IOException ){
+
+ synchronized( this ){
+
+ while( !closing ){
+
+ if( pos != buffer.end() ){
+ return *(pos++);
+ }
+
+ // Wait for more data
+ wait();
+ }
+
+ throw IOException( __FILE__, __LINE__, "close occurred during read" );
+ }
+
+ return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int BlockingByteArrayInputStream::read( unsigned char* buffer,
+ int bufferSize )
+ throw ( IOException ){
+ synchronized( this ){
+
+ int ix = 0;
+
+ for( ; ix < bufferSize && !closing; ++ix, ++pos)
+ {
+ if(pos == this->buffer.end())
+ {
+ // Wait for more data to come in.
+ wait();
+ }
+
+ if( !closing ){
+ buffer[ix] = *(pos);
+ }
+ }
+
+ if( closing ){
+ throw IOException( __FILE__, __LINE__, "close occurred during read" );
+ }
+
+ return ix;
+ }
+
+ return 0;
+}
Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BlockingByteArrayInputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BlockingByteArrayInputStream.h?view=auto&rev=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BlockingByteArrayInputStream.h (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BlockingByteArrayInputStream.h Thu Dec 14 17:47:17 2006
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACTIVEMQ_IO_BLOCKINGBYTEARRAYINPUTSTREAM_H_
+#define _ACTIVEMQ_IO_BLOCKINGBYTEARRAYINPUTSTREAM_H_
+
+#include <activemq/io/InputStream.h>
+#include <activemq/concurrent/Mutex.h>
+#include <vector>
+
+namespace activemq{
+namespace io{
+
+ /**
+ * This is a blocking version of a byte buffer stream. Read operations
+ * block until the requested data becomes available in the internal
+ * buffer via a call to setByteArray.
+ */
+ class BlockingByteArrayInputStream : public InputStream
+ {
+ private:
+
+ /**
+ * Default buffer to use, if none provided.
+ */
+ std::vector<unsigned char> buffer;
+
+ /**
+ * iterator to current position in buffer.
+ */
+ std::vector<unsigned char>::const_iterator pos;
+
+ /**
+ * Synchronization object.
+ */
+ concurrent::Mutex mutex;
+
+ /**
+ * Indicates that this stream is in the process of shutting
+ * down.
+ */
+ bool closing;
+
+ public:
+
+ /**
+ * Default Constructor - uses a default internal buffer
+ */
+ BlockingByteArrayInputStream();
+
+ /**
+ * Constructor that initializes the internal buffer.
+ * @see setByteArray.
+ */
+ BlockingByteArrayInputStream( const unsigned char* buffer,
+ int bufferSize );
+
+ /**
+ * Destructor
+ */
+ virtual ~BlockingByteArrayInputStream();
+
+ /**
+ * Sets the data that this reader uses. Replaces any existing
+ * data and resets the read index to the beginning of the buffer.
+ * When this method is called, it notifies any other threads that
+ * data is now available to be read.
+ * @param buffer The new data to be copied to the internal buffer.
+ * @param bufferSize The size of the new buffer.
+ */
+ virtual void setByteArray( const unsigned char* buffer,
+ int bufferSize );
+
+ /**
+ * Waits on a signal from this object, which is generated
+ * by a call to Notify. Must have this object locked before
+ * calling.
+ * @throws ActiveMQException
+ */
+ virtual void lock() throw( exceptions::ActiveMQException ){
+ mutex.lock();
+ }
+
+ /**
+ * Unlocks the object.
+ * @throws ActiveMQException
+ */
+ virtual void unlock() throw( exceptions::ActiveMQException ){
+ mutex.unlock();
+ }
+
+ /**
+ * Waits on a signal from this object, which is generated
+ * by a call to Notify. Must have this object locked before
+ * calling.
+ * @throws ActiveMQException
+ */
+ virtual void wait() throw( exceptions::ActiveMQException ){
+ mutex.wait();
+ }
+
+ /**
+ * Waits on a signal from this object, which is generated
+ * by a call to Notify. Must have this object locked before
+ * calling. This wait will timeout after the specified time
+ * interval.
+ * @param time in millisecsonds to wait, or WAIT_INIFINITE
+ * @throws ActiveMQException
+ */
+ virtual void wait( unsigned long millisecs ) throw( exceptions::ActiveMQException ){
+ mutex.wait(millisecs);
+ }
+
+ /**
+ * Signals a waiter on this object that it can now wake
+ * up and continue. Must have this object locked before
+ * calling.
+ * @throws ActiveMQException
+ */
+ virtual void notify() throw( exceptions::ActiveMQException ){
+ mutex.notify();
+ }
+
+ /**
+ * Signals the waiters on this object that it can now wake
+ * up and continue. Must have this object locked before
+ * calling.
+ * @throws ActiveMQException
+ */
+ virtual void notifyAll() throw( exceptions::ActiveMQException ){
+ mutex.notifyAll();
+ }
+
+ /**
+ * Indicates the number of bytes available to be read without
+ * blocking.
+ * @return the data available in the internal buffer.
+ * @throws IOException if an error occurs.
+ */
+ virtual int available() const throw (IOException){
+ return std::distance( pos, buffer.end() );
+ }
+
+ /**
+ * Reads a single byte from the buffer. This operation will
+ * block until data has been added to the buffer via a call
+ * to setByteArray.
+ * @return the next byte.
+ * @throws IOException if an error occurs.
+ */
+ virtual unsigned char read() throw (IOException);
+
+ /**
+ * Reads an array of bytes from the buffer. If the desired amount
+ * of data is not currently available, this operation
+ * will block until the appropriate amount of data is available
+ * in the buffer via a call to setByteArray.
+ * @param buffer (out) the target buffer
+ * @param bufferSize the size of the output buffer.
+ * @return the number of bytes read.
+ * @throws IOException f an error occurs.
+ */
+ virtual int read( unsigned char* buffer, const int bufferSize )
+ throw (IOException);
+
+ /**
+ * Closes the target input stream.
+ * @throws IOException if an error occurs.
+ */
+ virtual void close() throw (cms::CMSException);
+
+ };
+
+}}
+
+#endif /*_ACTIVEMQ_IO_BLOCKINGBYTEARRAYINPUTSTREAM_H_*/
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedInputStream.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedInputStream.cpp?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedInputStream.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedInputStream.cpp Thu Dec 14 17:47:17 2006
@@ -84,7 +84,7 @@
////////////////////////////////////////////////////////////////////////////////
int BufferedInputStream::read( unsigned char* targetBuffer,
- const int targetBufferSize ) throw ( IOException ){
+ int targetBufferSize ) throw ( IOException ){
try{
// If there's no data left, reset to pointers to the beginning of the
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedInputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedInputStream.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedInputStream.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedInputStream.h Thu Dec 14 17:47:17 2006
@@ -101,7 +101,7 @@
* @return The number of bytes read.
* @throws IOException thrown if an error occurs.
*/
- virtual int read( unsigned char* buffer, const int bufferSize )
+ virtual int read( unsigned char* buffer, int bufferSize )
throw ( IOException );
private:
@@ -117,7 +117,7 @@
* from the target input stream.
* @throws CMSException
*/
- void bufferData(void) throw ( IOException );
+ void bufferData() throw ( IOException );
/**
* Returns the number of bytes that are currently unused
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedOutputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedOutputStream.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedOutputStream.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/BufferedOutputStream.h Thu Dec 14 17:47:17 2006
@@ -76,7 +76,7 @@
* @param c the byte.
* @throws IOException thrown if an error occurs.
*/
- virtual void write( const unsigned char c ) throw ( IOException );
+ virtual void write( unsigned char c ) throw ( IOException );
/**
* Writes an array of bytes to the output stream.
@@ -84,7 +84,7 @@
* @param len The number of bytes from the buffer to be written.
* @throws IOException thrown if an error occurs.
*/
- virtual void write( const unsigned char* buffer, const int len ) throw ( IOException );
+ virtual void write( const unsigned char* buffer, int len ) throw ( IOException );
/**
* Invokes flush on the target output stream.
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayInputStream.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayInputStream.cpp?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayInputStream.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayInputStream.cpp Thu Dec 14 17:47:17 2006
@@ -22,114 +22,88 @@
using namespace std;
////////////////////////////////////////////////////////////////////////////////
-ByteArrayInputStream::ByteArrayInputStream()
-{
- pos = buffer.end();
- closing = false;
+ByteArrayInputStream::ByteArrayInputStream(){
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ByteArrayInputStream::ByteArrayInputStream( const vector<unsigned char>& buffer ){
+ setBuffer(buffer);
}
////////////////////////////////////////////////////////////////////////////////
ByteArrayInputStream::ByteArrayInputStream( const unsigned char* buffer,
- int bufferSize )
-{
- closing = false;
+ int bufferSize ){
setByteArray( buffer, bufferSize );
}
////////////////////////////////////////////////////////////////////////////////
-ByteArrayInputStream::~ByteArrayInputStream(void)
-{
+ByteArrayInputStream::~ByteArrayInputStream(){
}
////////////////////////////////////////////////////////////////////////////////
-void ByteArrayInputStream::setByteArray( const unsigned char* lbuffer,
- int lbufferSize )
-{
- synchronized( this ){
-
- // Remove old data
- this->buffer.clear();
-
- // Copy data to internal buffer.
- for( int ix = 0; ix < lbufferSize; ++ix )
- {
- this->buffer.push_back(lbuffer[ix]);
- }
-
- // Begin at the Beginning.
- pos = this->buffer.begin();
-
- // Notify any listening threads that there
- // is now data available.
- notifyAll();
- }
+void ByteArrayInputStream::setBuffer( const vector<unsigned char>& buffer ){
+
+ // We're using the default buffer.
+ activeBuffer = &buffer;
+
+ // Begin at the Beginning.
+ reset();
}
////////////////////////////////////////////////////////////////////////////////
-void ByteArrayInputStream::close() throw( cms::CMSException ){
+void ByteArrayInputStream::setByteArray( const unsigned char* lbuffer,
+ int lbufferSize ){
+ // We're using the default buffer.
+ activeBuffer = &defaultBuffer;
- synchronized( this ){
-
- // Indicate that this stream is closing.
- closing = true;
-
- // Close the delegate stream.
- buffer.clear();
-
- // Notify that this stream is shutting down.
- notifyAll();
+ // Remove old data
+ defaultBuffer.clear();
+
+ // Copy data to internal buffer.
+ for( int ix = 0; ix < lbufferSize; ++ix )
+ {
+ defaultBuffer.push_back(lbuffer[ix]);
}
+
+ // Begin at the Beginning.
+ reset();
}
////////////////////////////////////////////////////////////////////////////////
-unsigned char ByteArrayInputStream::read() throw ( IOException )
-{
- synchronized( this ){
-
- while( !closing ){
-
- if(pos != buffer.end())
- {
- return *(pos++);
- }
-
- // Wait for data to come in.
- wait();
- }
-
- throw IOException( __FILE__, __LINE__, "close occurred during a read" );
+void ByteArrayInputStream::reset() throw (cms::CMSException){
+ if( activeBuffer == NULL ){
+ throw IOException( __FILE__, __LINE__, "Buffer has not been initialized" );
}
+
+ // Begin at the Beginning.
+ pos = activeBuffer->begin();
+}
- return 0;
+////////////////////////////////////////////////////////////////////////////////
+unsigned char ByteArrayInputStream::read() throw ( IOException ){
+ if( pos == activeBuffer->end() ){
+ throw IOException( __FILE__, __LINE__, "Buffer is empty" );
+ }
+
+ return *(pos++);
}
////////////////////////////////////////////////////////////////////////////////
int ByteArrayInputStream::read( unsigned char* buffer,
- const int bufferSize )
- throw ( IOException )
-{
- synchronized( this ){
-
- int ix = 0;
-
- for( ; ix < bufferSize && !closing; ++ix, ++pos)
- {
- if(pos == this->buffer.end())
- {
- // We don't have the requested data yet -
- // wait for it.
- wait();
- }
-
- buffer[ix] = *(pos);
- }
-
- if( closing ){
- throw IOException( __FILE__, __LINE__, "close occurred during a read" );
+ int bufferSize )
+ throw ( IOException ){
+ int ix = 0;
+
+ for( ; ix < bufferSize; ++ix, ++pos)
+ {
+ if(pos == activeBuffer->end())
+ {
+ // We don't have enough data to fulfill the request.
+ throw IOException( __FILE__, __LINE__, "Reached the end of the buffer" );
}
-
- return ix;
+
+ buffer[ix] = *(pos);
}
-
- return 0;
+
+ return ix;
}
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayInputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayInputStream.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayInputStream.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayInputStream.h Thu Dec 14 17:47:17 2006
@@ -26,14 +26,23 @@
namespace activemq{
namespace io{
+ /**
+ * Simple implementation of InputStream that wraps around
+ * a std::vector<unsigned char>.
+ */
class ByteArrayInputStream : public InputStream
{
private:
/**
- * The Array of Bytes to read from.
+ * Default buffer to use, if none provided.
*/
- std::vector<unsigned char> buffer;
+ std::vector<unsigned char> defaultBuffer;
+
+ /**
+ * Reference to the buffer being used by this stream.
+ */
+ const std::vector<unsigned char>* activeBuffer;
/**
* iterator to current position in buffer.
@@ -43,22 +52,23 @@
/**
* Synchronization object.
*/
- concurrent::Mutex mutex;
-
- /**
- * Indicates that this stream is in the process
- * of shutting down.
- */
- bool closing;
+ concurrent::Mutex mutex;
public:
/**
* Default Constructor
*/
- ByteArrayInputStream(void);
+ ByteArrayInputStream();
/**
+ * Creates the input stream and calls setBuffer with the
+ * specified buffer object.
+ * @param buffer The buffer to be used.
+ */
+ ByteArrayInputStream( const std::vector<unsigned char>& buffer );
+
+ /**
* Constructor
* @param buffer initial byte array to use to read from
* @param bufferSize the size of the buffer
@@ -66,8 +76,19 @@
ByteArrayInputStream( const unsigned char* buffer,
int bufferSize );
- virtual ~ByteArrayInputStream(void);
+ virtual ~ByteArrayInputStream();
+ /**
+ * Sets the internal buffer. The input stream will wrap around
+ * this buffer and will perform all read operations on it. The
+ * position will be reinitialized to the beginning of the specified
+ * buffer. This class will not own the given buffer - it is the
+ * caller's responsibility to free the memory of the given buffer
+ * as appropriate.
+ * @param buffer The buffer to be used.
+ */
+ virtual void setBuffer( const std::vector<unsigned char>& buffer );
+
/**
* Sets the data that this reader uses, replaces any existing
* data and resets to beginning of the buffer.
@@ -140,12 +161,14 @@
/**
* Indcates the number of bytes avaialable.
- * @return the sum of the amount of data avalable
- * in the buffer and the data available on the target
- * input stream.
+ * @return The number of bytes until the end of the internal buffer.
*/
- virtual int available() const throw (IOException) {
- return std::distance( pos, buffer.end() );
+ virtual int available() const throw (IOException) {
+ if( activeBuffer == NULL ){
+ throw IOException( __FILE__, __LINE__, "buffer has not been initialized");
+ }
+
+ return std::distance( pos, activeBuffer->end() );
}
/**
@@ -162,14 +185,20 @@
* @return The number of bytes read.
* @throws IOException thrown if an error occurs.
*/
- virtual int read( unsigned char* buffer, const int bufferSize )
+ virtual int read( unsigned char* buffer, int bufferSize )
throw (IOException);
/**
* Closes the target input stream.
* @throws IOException thrown if an error occurs.
*/
- virtual void close() throw(cms::CMSException);
+ virtual void close() throw(cms::CMSException){ /* do nothing */ }
+
+ /**
+ * Resets the read index to the beginning of the byte
+ * array.
+ */
+ virtual void reset() throw (cms::CMSException);
};
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayOutputStream.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayOutputStream.cpp?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayOutputStream.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayOutputStream.cpp Thu Dec 14 17:47:17 2006
@@ -22,28 +22,35 @@
using namespace std;
////////////////////////////////////////////////////////////////////////////////
-void ByteArrayOutputStream::close() throw( cms::CMSException )
-{
- // Clear the Buffer
- flush();
+ByteArrayOutputStream::ByteArrayOutputStream()
+{
+ activeBuffer = &defaultBuffer;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ByteArrayOutputStream::ByteArrayOutputStream( vector<unsigned char>& buffer)
+{
+ setBuffer( buffer );
}
-
+
////////////////////////////////////////////////////////////////////////////////
-void ByteArrayOutputStream::flush() throw ( IOException )
-{}
+void ByteArrayOutputStream::setBuffer( vector<unsigned char>& buffer)
+{
+ activeBuffer = &buffer;
+}
////////////////////////////////////////////////////////////////////////////////
void ByteArrayOutputStream::clear() throw ( IOException )
{
// Empty the contents of the buffer to the output stream.
- buffer.clear();
+ activeBuffer->clear();
}
////////////////////////////////////////////////////////////////////////////////
-void ByteArrayOutputStream::write( const unsigned char c )
+void ByteArrayOutputStream::write( unsigned char c )
throw ( IOException )
{
- buffer.push_back( c );
+ activeBuffer->push_back( c );
}
////////////////////////////////////////////////////////////////////////////////
@@ -54,7 +61,7 @@
// Iterate until all the data is written.
for( int ix = 0; ix < len; ++ix)
{
- this->buffer.push_back( buffer[ix] );
+ activeBuffer->push_back( buffer[ix] );
}
}
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayOutputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayOutputStream.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayOutputStream.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/ByteArrayOutputStream.h Thu Dec 14 17:47:17 2006
@@ -30,9 +30,14 @@
private:
/**
- * The Array of Bytes to read from.
+ * Default buffer to use, if none provided.
*/
- std::vector<unsigned char> buffer;
+ std::vector<unsigned char> defaultBuffer;
+
+ /**
+ * Reference to the buffer being used by this stream.
+ */
+ std::vector<unsigned char>* activeBuffer;
/**
* Synchronization object.
@@ -42,29 +47,48 @@
public:
/**
- * Default Constructor
+ * Default Constructor - uses a default internal buffer
*/
- ByteArrayOutputStream(void) {};
+ ByteArrayOutputStream();
+
+ /**
+ * Uses the given buffer as the target. Calls setBuffer.
+ * @param buffer the target buffer.
+ */
+ ByteArrayOutputStream( std::vector<unsigned char>& buffer );
/**
* Destructor
*/
- virtual ~ByteArrayOutputStream(void) {};
+ virtual ~ByteArrayOutputStream() {};
/**
+ * Sets the internal buffer. This input stream will wrap around
+ * the given buffer and all writes will be performed directly on
+ * the buffer. This object does not retain control of the buffer's
+ * lifetime however - this is the job of the caller.
+ * @param buffer The target buffer.
+ */
+ virtual void setBuffer( std::vector<unsigned char>& buffer );
+
+ /**
* Get a snapshot of the data
* @return pointer to the data
*/
- virtual const unsigned char* getByteArray(void) const {
- return &buffer[0];
+ virtual const unsigned char* getByteArray() const {
+ if( activeBuffer->size() == 0 ){
+ return NULL;
+ }
+
+ return &(*activeBuffer)[0];
}
/**
* Get the Size of the Internal Buffer
* @return size of the internal buffer
*/
- virtual int getByteArraySize(void) const {
- return buffer.size();
+ virtual int getByteArraySize() const {
+ return activeBuffer->size();
}
/**
@@ -132,7 +156,7 @@
* @param c the byte.
* @throws IOException thrown if an error occurs.
*/
- virtual void write( const unsigned char c )
+ virtual void write( unsigned char c )
throw ( IOException );
/**
@@ -141,26 +165,26 @@
* @param len The number of bytes from the buffer to be written.
* @throws IOException thrown if an error occurs.
*/
- virtual void write( const unsigned char* buffer, const int len )
+ virtual void write( const unsigned char* buffer, int len )
throw ( IOException );
/**
* Invokes flush on the target output stream, has no affect.
* @throws IOException
*/
- virtual void flush( void ) throw ( IOException );
+ virtual void flush() throw ( IOException ){ /* do nothing */ }
/**
* Clear current Stream contents
* @throws IOException
*/
- virtual void clear( void ) throw ( IOException );
+ virtual void clear() throw ( IOException );
/**
* Invokes close on the target output stream.
* @throws CMSException
*/
- void close( void ) throw( cms::CMSException );
+ void close() throw( cms::CMSException ){ /* do nothing */ }
};
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.cpp?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.cpp Thu Dec 14 17:47:17 2006
@@ -218,12 +218,15 @@
while( true ){
temp = readChar();
- // Append no matter what
- retVal += temp;
-
// if null is found we are done.
- if( temp == '\0' ) break;
+ if( temp == '\0' ){
+ break;
+ }
+
+ // Append no matter what
+ retVal += temp;
}
+
return retVal;
}
AMQ_CATCH_RETHROW( IOException )
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/FilterInputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/FilterInputStream.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/FilterInputStream.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/FilterInputStream.h Thu Dec 14 17:47:17 2006
@@ -108,7 +108,7 @@
* @return The number of bytes read or -1 if EOS is detected
* @throws IOException thrown if an error occurs.
*/
- virtual int read( unsigned char* buffer, const int bufferSize )
+ virtual int read( unsigned char* buffer, int bufferSize )
throw ( IOException )
{
try {
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/FilterOutputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/FilterOutputStream.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/FilterOutputStream.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/FilterOutputStream.h Thu Dec 14 17:47:17 2006
@@ -84,7 +84,7 @@
* @param c the byte.
* @throws IOException thrown if an error occurs.
*/
- virtual void write( const unsigned char c ) throw ( IOException ) {
+ virtual void write( unsigned char c ) throw ( IOException ) {
try {
outputStream->write( c );
}
@@ -100,7 +100,7 @@
* @param len The number of bytes from the buffer to be written.
* @throws IOException thrown if an error occurs.
*/
- virtual void write( const unsigned char* buffer, const int len ) throw ( IOException ) {
+ virtual void write( const unsigned char* buffer, int len ) throw ( IOException ) {
try {
for( int ix = 0; ix < len; ++ix )
{
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/InputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/InputStream.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/InputStream.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/InputStream.h Thu Dec 14 17:47:17 2006
@@ -61,7 +61,7 @@
* @return The number of bytes read or -1 if EOF is detected
* @throws IOException thrown if an error occurs.
*/
- virtual int read( unsigned char* buffer, const int bufferSize )
+ virtual int read( unsigned char* buffer, int bufferSize )
throw ( IOException ) = 0;
/**
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/OutputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/OutputStream.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/OutputStream.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/OutputStream.h Thu Dec 14 17:47:17 2006
@@ -42,7 +42,7 @@
* @param c the byte.
* @throws IOException thrown if an error occurs.
*/
- virtual void write( const unsigned char c ) throw ( IOException ) = 0;
+ virtual void write( unsigned char c ) throw ( IOException ) = 0;
/**
* Writes an array of bytes to the output stream.
@@ -50,7 +50,7 @@
* @param len The number of bytes from the buffer to be written.
* @throws IOException thrown if an error occurs.
*/
- virtual void write( const unsigned char* buffer, const int len )
+ virtual void write( const unsigned char* buffer, int len )
throw ( IOException ) = 0;
/**
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/StandardErrorOutputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/StandardErrorOutputStream.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/StandardErrorOutputStream.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/StandardErrorOutputStream.h Thu Dec 14 17:47:17 2006
@@ -108,7 +108,7 @@
* @param c the byte.
* @throws IOException thrown if an error occurs.
*/
- virtual void write( const unsigned char c )
+ virtual void write( unsigned char c )
throw ( IOException )
{
std::cerr << c;
@@ -120,7 +120,7 @@
* @param len The number of bytes from the buffer to be written.
* @throws IOException thrown if an error occurs.
*/
- virtual void write( const unsigned char* buffer, const int len )
+ virtual void write( const unsigned char* buffer, int len )
throw ( IOException )
{
for(int i = 0; i < len; ++i)
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp Thu Dec 14 17:47:17 2006
@@ -130,7 +130,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-int SocketInputStream::read( unsigned char* buffer, const int bufferSize ) throw (IOException){
+int SocketInputStream::read( unsigned char* buffer, int bufferSize ) throw (IOException){
int len = ::recv(socket, (char*)buffer, bufferSize, 0);
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.h Thu Dec 14 17:47:17 2006
@@ -55,7 +55,7 @@
* Enables socket level output of the recieved data
* @param debug true to turn on debugging
*/
- virtual void setDebug( const bool debug ){
+ virtual void setDebug( bool debug ){
this->debug = debug;
}
@@ -143,7 +143,7 @@
* @return The number of bytes read.
* @throws IOException thrown if an error occurs.
*/
- virtual int read( unsigned char* buffer, const int bufferSize ) throw (io::IOException);
+ virtual int read( unsigned char* buffer, int bufferSize ) throw (io::IOException);
/**
* Close - does nothing. It is the responsibility of the owner
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.cpp?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.cpp Thu Dec 14 17:47:17 2006
@@ -49,18 +49,18 @@
}
////////////////////////////////////////////////////////////////////////////////
-SocketOutputStream::~SocketOutputStream(void)
+SocketOutputStream::~SocketOutputStream()
{
}
////////////////////////////////////////////////////////////////////////////////
-void SocketOutputStream::write( const unsigned char c ) throw (IOException)
+void SocketOutputStream::write( unsigned char c ) throw (IOException)
{
write( &c, 1 );
}
////////////////////////////////////////////////////////////////////////////////
-void SocketOutputStream::write( const unsigned char* buffer, const int len )
+void SocketOutputStream::write( const unsigned char* buffer, int len )
throw (IOException)
{
int remaining = len;
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/network/SocketOutputStream.h Thu Dec 14 17:47:17 2006
@@ -52,7 +52,7 @@
* Enables Debugging of Socket Data
* @param debug true to enable
*/
- virtual void setDebug( const bool debug ){
+ virtual void setDebug( bool debug ){
this->debug = debug;
}
@@ -120,7 +120,7 @@
* @param c the byte.
* @throws IOException thrown if an error occurs.
*/
- virtual void write( const unsigned char c ) throw ( io::IOException );
+ virtual void write( unsigned char c ) throw ( io::IOException );
/**
* Writes an array of bytes to the output stream.
@@ -128,7 +128,7 @@
* @param len The number of bytes from the buffer to be written.
* @throws IOException thrown if an error occurs.
*/
- virtual void write( const unsigned char* buffer, const int len ) throw ( io::IOException );
+ virtual void write( const unsigned char* buffer, int len ) throw ( io::IOException );
/**
* Flush - does nothing.
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/BytesMessage.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/BytesMessage.h?view=diff&rev=487422&r1=487421&r2=487422
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/BytesMessage.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/BytesMessage.h Thu Dec 14 17:47:17 2006
@@ -45,27 +45,27 @@
* to expect.
* @return const pointer to a byte buffer
*/
- virtual const unsigned char* getBodyBytes(void) const = 0;
+ virtual const unsigned char* getBodyBytes() const = 0;
/**
* Returns the number of bytes contained in the body of this message.
* @return number of bytes.
*/
- virtual unsigned long long getBodyLength(void) const = 0;
+ virtual unsigned long long getBodyLength() const = 0;
/**
* Puts the message body in read-only mode and repositions the stream
* of bytes to the beginning.
* @throws CMSException
*/
- //virtual void reset() throw ( cms::CMSException ) = 0;
+ virtual void reset() throw ( cms::CMSException ) = 0;
/**
* Reads a Boolean from the Bytes message stream
* @returns boolean value from stream
* @throws CMSException
*/
- //virtual bool readBoolean() throw ( cms::CMSException ) = 0;
+ virtual bool readBoolean() throw ( cms::CMSException ) = 0;
/**
* Writes a boolean to the bytes message stream as a 1-byte value.
@@ -74,21 +74,21 @@
* @param value - boolean to write to the stream
* @throws CMSException
*/
- //virtual void writeBoolean( const bool value ) throw cms::CMSException ) = 0;
+ virtual void writeBoolean( bool value ) throw ( cms::CMSException ) = 0;
/**
* Reads a Byte from the Bytes message stream
* @returns unsigned char value from stream
* @throws CMSException
*/
- //virtual unsigned char readByte() throw ( cms::CMSException ) = 0;
+ virtual unsigned char readByte() throw ( cms::CMSException ) = 0;
/**
* Writes a byte to the bytes message stream as a 1-byte value
* @param value - byte to write to the stream
* @throws CMSException
*/
- //virtual void writeByte( const unsigned char value ) throw cms::CMSException ) = 0;
+ virtual void writeByte( unsigned char value ) throw ( cms::CMSException ) = 0;
/**
* Reads a byte array from the bytes message stream.
@@ -109,8 +109,8 @@
* been reached
* @throws CMSException if an error occurs.
*/
- //virtual int readBytes( std::vector<unsigned char>& value )
- // throw ( cms::CMSException ) = 0;
+ virtual int readBytes( std::vector<unsigned char>& value )
+ throw ( cms::CMSException ) = 0;
/**
* Writes a byte array to the bytes message stream using the vector
@@ -118,7 +118,8 @@
* @param value - bytes to write to the stream
* @throws CMSException
*/
- //virtual void writeBytes( const std::vector<unsigned char>& value ) throw cms::CMSException ) = 0;
+ virtual void writeBytes( const std::vector<unsigned char>& value )
+ throw ( cms::CMSException ) = 0;
/**
* Reads a portion of the bytes message stream.
@@ -145,8 +146,8 @@
* been reached
* @throws CMSException
*/
- //virtual int readBytes( unsigned char*& buffer, int length )
- // throw ( cms::CMSException ) = 0;
+ virtual int readBytes( unsigned char*& buffer, int length )
+ throw ( cms::CMSException ) = 0;
/**
* Writes a portion of a byte array to the bytes message stream.
@@ -156,121 +157,121 @@
* @param length - the number of bytes to use
* @throws CMSException
*/
-// virtual void writeBytes( const unsigned char* value,
-// unsigned int offset,
-// unsigned int length ) throw cms::CMSException ) = 0;
+ virtual void writeBytes( const unsigned char* value,
+ int offset,
+ int length ) throw ( cms::CMSException ) = 0;
/**
* Reads a Char from the Bytes message stream
* @returns char value from stream
* @throws CMSException
*/
- //virtual char readChar() throw ( cms::CMSException ) = 0;
+ virtual char readChar() throw ( cms::CMSException ) = 0;
/**
* Writes a char to the bytes message stream as a 1-byte value
* @param value - char to write to the stream
* @throws CMSException
*/
- //virtual void writeChar( const char value ) throw cms::CMSException ) = 0;
+ virtual void writeChar( char value ) throw ( cms::CMSException ) = 0;
/**
* Reads a 32 bit float from the Bytes message stream
* @returns double value from stream
* @throws CMSException
*/
- //virtual float readFloat() throw ( cms::CMSException ) = 0;
+ virtual float readFloat() throw ( cms::CMSException ) = 0;
/**
* Writes a float to the bytes message stream as a 4 byte value
* @param value - float to write to the stream
* @throws CMSException
*/
- //virtual void writeFloat( const float value ) throw cms::CMSException ) = 0;
+ virtual void writeFloat( float value ) throw ( cms::CMSException ) = 0;
/**
* Reads a 64 bit double from the Bytes message stream
* @returns double value from stream
* @throws CMSException
*/
- //virtual double readDouble() throw ( cms::CMSException ) = 0;
+ virtual double readDouble() throw ( cms::CMSException ) = 0;
/**
* Writes a double to the bytes message stream as a 8 byte value
* @param value - double to write to the stream
* @throws CMSException
*/
- //virtual void writeDouble( const double value ) throw cms::CMSException ) = 0;
+ virtual void writeDouble( double value ) throw ( cms::CMSException ) = 0;
/**
* Reads a 16 bit signed short from the Bytes message stream
* @returns short value from stream
* @throws CMSException
*/
- //virtual short readShort() throw ( cms::CMSException ) = 0;
+ virtual short readShort() throw ( cms::CMSException ) = 0;
/**
* Writes a signed short to the bytes message stream as a 2 byte value
* @param value - signed short to write to the stream
* @throws CMSException
*/
- //virtual void writeShort( const short value ) throw cms::CMSException ) = 0;
+ virtual void writeShort( short value ) throw ( cms::CMSException ) = 0;
/**
* Reads a 16 bit unsigned short from the Bytes message stream
* @returns unsigned short value from stream
* @throws CMSException
*/
- //virtual unsigned short readUnsignedShort() throw ( cms::CMSException ) = 0;
+ virtual unsigned short readUnsignedShort() throw ( cms::CMSException ) = 0;
/**
* Writes a unsigned short to the bytes message stream as a 2 byte value
* @param value - unsigned short to write to the stream
* @throws CMSException
*/
- //virtual void writeUnsignedShort( const unsigned short value ) throw cms::CMSException ) = 0;
+ virtual void writeUnsignedShort( unsigned short value ) throw ( cms::CMSException ) = 0;
/**
* Reads a 32 bit signed intger from the Bytes message stream
* @returns int value from stream
* @throws CMSException
*/
- //virtual int readInt() throw ( cms::CMSException ) = 0;
+ virtual int readInt() throw ( cms::CMSException ) = 0;
/**
* Writes a signed int to the bytes message stream as a 4 byte value
* @param value - signed int to write to the stream
* @throws CMSException
*/
- //virtual void writeInt( const int value ) throw cms::CMSException ) = 0;
+ virtual void writeInt( int value ) throw ( cms::CMSException ) = 0;
/**
* Reads a 64 bit long from the Bytes message stream
* @returns long long value from stream
* @throws CMSException
*/
- //virtual long long readLong() throw ( cms::CMSException ) = 0;
+ virtual long long readLong() throw ( cms::CMSException ) = 0;
/**
* Writes a long long to the bytes message stream as a 8 byte value
* @param value - signed long long to write to the stream
* @throws CMSException
*/
- //virtual void writeLong( const long long value ) throw cms::CMSException ) = 0;
+ virtual void writeLong( long long value ) throw ( cms::CMSException ) = 0;
/**
* Reads an ASCII String from the Bytes message stream
* @returns String from stream
* @throws CMSException
*/
- //virtual std::string readString() throw ( cms::CMSException ) = 0;
+ virtual std::string readString() throw ( cms::CMSException ) = 0;
/**
* Writes an ASCII String to the Bytes message stream
* @param value - String to write to the stream
* @throws CMSException
*/
- //virtual void readString( const std::string& value ) throw ( cms::CMSException ) = 0;
+ virtual void writeString( const std::string& value ) throw ( cms::CMSException ) = 0;
};
}