Author: tabish Date: Fri Oct 5 10:11:11 2007 New Revision: 582348 URL: http://svn.apache.org/viewvc?rev=582348&view=rev Log: https://issues.apache.org/activemq/browse/AMQCPP-143 Made the bytes message read methods all const and made the input streams mutable in each of the stomp and openwire vversions. Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h activemq/activemq-cpp/trunk/src/main/cms/BytesMessage.h Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp?rev=582348&r1=582347&r2=582348&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.cpp Fri Oct 5 10:11:11 2007 @@ -94,7 +94,7 @@ } //////////////////////////////////////////////////////////////////////////////// -bool ActiveMQBytesMessage::readBoolean() throw ( cms::CMSException ) { +bool ActiveMQBytesMessage::readBoolean() const throw ( cms::CMSException ) { try{ checkReadOnly(); @@ -116,7 +116,7 @@ } //////////////////////////////////////////////////////////////////////////////// -unsigned char ActiveMQBytesMessage::readByte() throw ( cms::CMSException ) { +unsigned char ActiveMQBytesMessage::readByte() const throw ( cms::CMSException ) { try{ checkReadOnly(); @@ -138,7 +138,7 @@ } //////////////////////////////////////////////////////////////////////////////// -std::size_t ActiveMQBytesMessage::readBytes( std::vector& value ) +std::size_t ActiveMQBytesMessage::readBytes( std::vector& value ) const throw ( cms::CMSException ) { try{ @@ -161,7 +161,7 @@ } //////////////////////////////////////////////////////////////////////////////// -std::size_t ActiveMQBytesMessage::readBytes( unsigned char*& buffer, std::size_t length ) +std::size_t ActiveMQBytesMessage::readBytes( unsigned char*& buffer, std::size_t length ) const throw ( cms::CMSException ) { try{ @@ -186,7 +186,7 @@ } //////////////////////////////////////////////////////////////////////////////// -char ActiveMQBytesMessage::readChar() throw ( cms::CMSException ) { +char ActiveMQBytesMessage::readChar() const throw ( cms::CMSException ) { try{ checkReadOnly(); @@ -208,7 +208,7 @@ } //////////////////////////////////////////////////////////////////////////////// -float ActiveMQBytesMessage::readFloat() throw ( cms::CMSException ) { +float ActiveMQBytesMessage::readFloat() const throw ( cms::CMSException ) { try{ checkReadOnly(); @@ -230,7 +230,7 @@ } //////////////////////////////////////////////////////////////////////////////// -double ActiveMQBytesMessage::readDouble() throw ( cms::CMSException ) { +double ActiveMQBytesMessage::readDouble() const throw ( cms::CMSException ) { try{ checkReadOnly(); @@ -252,7 +252,7 @@ } //////////////////////////////////////////////////////////////////////////////// -short ActiveMQBytesMessage::readShort() throw ( cms::CMSException ) { +short ActiveMQBytesMessage::readShort() const throw ( cms::CMSException ) { try{ checkReadOnly(); @@ -274,7 +274,7 @@ } //////////////////////////////////////////////////////////////////////////////// -unsigned short ActiveMQBytesMessage::readUnsignedShort() throw ( cms::CMSException ) { +unsigned short ActiveMQBytesMessage::readUnsignedShort() const throw ( cms::CMSException ) { try{ checkReadOnly(); @@ -296,7 +296,7 @@ } //////////////////////////////////////////////////////////////////////////////// -int ActiveMQBytesMessage::readInt() throw ( cms::CMSException ) { +int ActiveMQBytesMessage::readInt() const throw ( cms::CMSException ) { try{ checkReadOnly(); @@ -318,7 +318,7 @@ } //////////////////////////////////////////////////////////////////////////////// -long long ActiveMQBytesMessage::readLong() throw ( cms::CMSException ) { +long long ActiveMQBytesMessage::readLong() const throw ( cms::CMSException ) { try{ checkReadOnly(); @@ -340,7 +340,7 @@ } //////////////////////////////////////////////////////////////////////////////// -std::string ActiveMQBytesMessage::readString() throw ( cms::CMSException ) { +std::string ActiveMQBytesMessage::readString() const throw ( cms::CMSException ) { try{ checkReadOnly(); @@ -362,7 +362,7 @@ } //////////////////////////////////////////////////////////////////////////////// -std::string ActiveMQBytesMessage::readUTF() throw ( cms::CMSException ) { +std::string ActiveMQBytesMessage::readUTF() const throw ( cms::CMSException ) { try{ checkReadOnly(); Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h?rev=582348&r1=582347&r2=582348&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQBytesMessage.h Fri Oct 5 10:11:11 2007 @@ -164,7 +164,7 @@ * @returns boolean value from stream * @throws CMSException */ - virtual bool readBoolean() throw ( cms::CMSException ); + virtual bool readBoolean() const throw ( cms::CMSException ); /** * Writes a boolean to the bytes message stream as a 1-byte value. @@ -180,7 +180,7 @@ * @returns unsigned char value from stream * @throws CMSException */ - virtual unsigned char readByte() throw ( cms::CMSException ); + virtual unsigned char readByte() const throw ( cms::CMSException ); /** * Writes a byte to the bytes message stream as a 1-byte value @@ -209,7 +209,7 @@ * been reached * @throws CMSException if an error occurs. */ - virtual std::size_t readBytes( std::vector& value ) + virtual std::size_t readBytes( std::vector& value ) const throw ( cms::CMSException ); /** @@ -245,7 +245,7 @@ * been reached * @throws CMSException */ - virtual std::size_t readBytes( unsigned char*& buffer, std::size_t length ) + virtual std::size_t readBytes( unsigned char*& buffer, std::size_t length ) const throw ( cms::CMSException ); /** @@ -265,7 +265,7 @@ * @returns char value from stream * @throws CMSException */ - virtual char readChar() throw ( cms::CMSException ); + virtual char readChar() const throw ( cms::CMSException ); /** * Writes a char to the bytes message stream as a 1-byte value @@ -279,7 +279,7 @@ * @returns double value from stream * @throws CMSException */ - virtual float readFloat() throw ( cms::CMSException ); + virtual float readFloat() const throw ( cms::CMSException ); /** * Writes a float to the bytes message stream as a 4 byte value @@ -293,7 +293,7 @@ * @returns double value from stream * @throws CMSException */ - virtual double readDouble() throw ( cms::CMSException ); + virtual double readDouble() const throw ( cms::CMSException ); /** * Writes a double to the bytes message stream as a 8 byte value @@ -307,7 +307,7 @@ * @returns short value from stream * @throws CMSException */ - virtual short readShort() throw ( cms::CMSException ); + virtual short readShort() const throw ( cms::CMSException ); /** * Writes a signed short to the bytes message stream as a 2 byte value @@ -321,7 +321,7 @@ * @returns unsigned short value from stream * @throws CMSException */ - virtual unsigned short readUnsignedShort() throw ( cms::CMSException ); + virtual unsigned short readUnsignedShort() const throw ( cms::CMSException ); /** * Writes a unsigned short to the bytes message stream as a 2 byte value @@ -335,7 +335,7 @@ * @returns int value from stream * @throws CMSException */ - virtual int readInt() throw ( cms::CMSException ); + virtual int readInt() const throw ( cms::CMSException ); /** * Writes a signed int to the bytes message stream as a 4 byte value @@ -349,7 +349,7 @@ * @returns long long value from stream * @throws CMSException */ - virtual long long readLong() throw ( cms::CMSException ); + virtual long long readLong() const throw ( cms::CMSException ); /** * Writes a long long to the bytes message stream as a 8 byte value @@ -363,7 +363,7 @@ * @returns String from stream * @throws CMSException */ - virtual std::string readString() throw ( cms::CMSException ); + virtual std::string readString() const throw ( cms::CMSException ); /** * Writes an ASCII String to the Bytes message stream @@ -377,7 +377,7 @@ * @returns String from stream * @throws CMSException */ - virtual std::string readUTF() throw ( cms::CMSException ); + virtual std::string readUTF() const throw ( cms::CMSException ); /** * Writes an UTF String to the BytesMessage stream @@ -392,7 +392,7 @@ * Throws an exception if not in write-only mode. * @throws CMSException. */ - void checkWriteOnly() throw (cms::CMSException){ + void checkWriteOnly() const throw (cms::CMSException){ if( readOnly ){ throw exceptions::IllegalStateException( __FILE__, __LINE__, "message is in read-only mode and cannot be written to" ); @@ -403,7 +403,7 @@ * Throws an exception if not in read-only mode. * @throws CMSException */ - void checkReadOnly() throw (cms::CMSException){ + void checkReadOnly() const throw (cms::CMSException){ if( !readOnly ){ throw exceptions::IllegalStateException( __FILE__, __LINE__, "message is in write-only mode and cannot be read from" ); @@ -423,7 +423,7 @@ * InputStream that wraps around the command's content when in * read-only mode. */ - io::ByteArrayInputStream inputStream; + mutable io::ByteArrayInputStream inputStream; /** * OutputStream that wraps around the command's content when in @@ -434,7 +434,7 @@ /** * DataInputStream wrapper around the input stream. */ - io::DataInputStream dataInputStream; + mutable io::DataInputStream dataInputStream; /** * DataOutputStream wrapper around the output stream. Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h?rev=582348&r1=582347&r2=582348&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h (original) +++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h Fri Oct 5 10:11:11 2007 @@ -52,7 +52,7 @@ * InputStream that wraps around the frame's body when in read-only * mode. */ - io::ByteArrayInputStream inputStream; + mutable io::ByteArrayInputStream inputStream; /** * OutputStream that wraps around the frame's body when in write-only @@ -63,7 +63,7 @@ /** * DataInputStream wrapper around the input stream. */ - io::DataInputStream dataInputStream; + mutable io::DataInputStream dataInputStream; /** * DataOutputStream wrapper around the output stream. @@ -210,7 +210,7 @@ * @returns boolean value from stream * @throws CMSException */ - virtual bool readBoolean() throw ( cms::CMSException ){ + virtual bool readBoolean() const throw ( cms::CMSException ){ checkReadOnly(); return dataInputStream.readBoolean(); } @@ -232,7 +232,7 @@ * @returns unsigned char value from stream * @throws CMSException */ - virtual unsigned char readByte() throw ( cms::CMSException ){ + virtual unsigned char readByte() const throw ( cms::CMSException ){ checkReadOnly(); return dataInputStream.readByte(); } @@ -266,7 +266,7 @@ * been reached * @throws CMSException if an error occurs. */ - virtual std::size_t readBytes( std::vector& value ) + virtual std::size_t readBytes( std::vector& value ) const throw ( cms::CMSException ){ checkReadOnly(); return dataInputStream.read( value ); @@ -309,7 +309,7 @@ * been reached * @throws CMSException */ - virtual std::size_t readBytes( unsigned char*& buffer, std::size_t length ) + virtual std::size_t readBytes( unsigned char*& buffer, std::size_t length ) const throw ( cms::CMSException ) { checkReadOnly(); @@ -336,7 +336,7 @@ * @returns char value from stream * @throws CMSException */ - virtual char readChar() throw ( cms::CMSException ){ + virtual char readChar() const throw ( cms::CMSException ){ checkReadOnly(); return dataInputStream.readChar(); } @@ -356,7 +356,7 @@ * @returns double value from stream * @throws CMSException */ - virtual float readFloat() throw ( cms::CMSException ){ + virtual float readFloat() const throw ( cms::CMSException ){ checkReadOnly(); return dataInputStream.readFloat(); } @@ -376,7 +376,7 @@ * @returns double value from stream * @throws CMSException */ - virtual double readDouble() throw ( cms::CMSException ){ + virtual double readDouble() const throw ( cms::CMSException ){ checkReadOnly(); return dataInputStream.readDouble(); } @@ -396,7 +396,7 @@ * @returns short value from stream * @throws CMSException */ - virtual short readShort() throw ( cms::CMSException ){ + virtual short readShort() const throw ( cms::CMSException ){ checkReadOnly(); return dataInputStream.readShort(); } @@ -416,7 +416,7 @@ * @returns unsigned short value from stream * @throws CMSException */ - virtual unsigned short readUnsignedShort() throw ( cms::CMSException ){ + virtual unsigned short readUnsignedShort() const throw ( cms::CMSException ){ checkReadOnly(); return dataInputStream.readUnsignedShort(); } @@ -436,7 +436,7 @@ * @returns int value from stream * @throws CMSException */ - virtual int readInt() throw ( cms::CMSException ){ + virtual int readInt() const throw ( cms::CMSException ){ checkReadOnly(); return dataInputStream.readInt(); } @@ -456,7 +456,7 @@ * @returns long long value from stream * @throws CMSException */ - virtual long long readLong() throw ( cms::CMSException ){ + virtual long long readLong() const throw ( cms::CMSException ){ checkReadOnly(); return dataInputStream.readLong(); } @@ -476,7 +476,7 @@ * @returns String from stream * @throws CMSException */ - virtual std::string readString() throw ( cms::CMSException ){ + virtual std::string readString() const throw ( cms::CMSException ){ checkReadOnly(); return dataInputStream.readString(); } @@ -496,7 +496,7 @@ * @returns String from stream * @throws CMSException */ - virtual std::string readUTF() throw ( cms::CMSException ){ + virtual std::string readUTF() const throw ( cms::CMSException ){ checkReadOnly(); return dataInputStream.readUTF(); } @@ -517,7 +517,7 @@ * Throws an exception if not in write-only mode. * @throws CMSException. */ - void checkWriteOnly() throw (cms::CMSException){ + void checkWriteOnly() const throw (cms::CMSException){ if( readOnly ){ throw exceptions::IllegalStateException( __FILE__, __LINE__, "message is in read-only mode and cannot be written to" ); @@ -528,7 +528,7 @@ * Throws an exception if not in read-only mode. * @throws CMSException */ - void checkReadOnly() throw (cms::CMSException){ + void checkReadOnly() const throw (cms::CMSException){ if( !readOnly ){ throw exceptions::IllegalStateException( __FILE__, __LINE__, "message is in write-only mode and cannot be read from" ); Modified: activemq/activemq-cpp/trunk/src/main/cms/BytesMessage.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/cms/BytesMessage.h?rev=582348&r1=582347&r2=582348&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/cms/BytesMessage.h (original) +++ activemq/activemq-cpp/trunk/src/main/cms/BytesMessage.h Fri Oct 5 10:11:11 2007 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + #ifndef _CMS_BYTESMESSAGE_H_ #define _CMS_BYTESMESSAGE_H_ @@ -22,55 +22,54 @@ #include namespace cms{ - + class CMS_API BytesMessage : public Message{ - public: - + virtual ~BytesMessage(){} /** - * sets the bytes given to the message body. + * sets the bytes given to the message body. * @param Byte Buffer to copy * @param Number of bytes in Buffer to copy * @throws CMSException */ - virtual void setBodyBytes( - const unsigned char* buffer, std::size_t numBytes ) + virtual void setBodyBytes( + const unsigned char* buffer, std::size_t numBytes ) throw( CMSException ) = 0; - + /** * Gets the bytes that are contained in this message, user should - * copy this data into a user allocated buffer. Call + * copy this data into a user allocated buffer. Call * getBodyLength to determine the number of bytes * to expect. * @return const pointer to a byte buffer */ virtual const unsigned char* getBodyBytes() const = 0; - + /** * Returns the number of bytes contained in the body of this message. * @return number of bytes. */ virtual std::size_t getBodyLength() const = 0; - + /** - * Puts the message body in read-only mode and repositions the stream + * 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; - + /** * 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() const throw ( cms::CMSException ) = 0; + /** - * 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 + * 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 @@ -82,7 +81,7 @@ * @returns unsigned char value from stream * @throws CMSException */ - virtual unsigned char readByte() throw ( cms::CMSException ) = 0; + virtual unsigned char readByte() const throw ( cms::CMSException ) = 0; /** * Writes a byte to the bytes message stream as a 1-byte value @@ -95,22 +94,22 @@ * 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 + * 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 + * 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 + * 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 + * @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 std::size_t readBytes( std::vector& value ) + virtual std::size_t readBytes( std::vector& value ) const throw ( cms::CMSException ) = 0; /** @@ -119,35 +118,35 @@ * @param value - bytes to write to the stream * @throws CMSException */ - virtual void writeBytes( const std::vector& value ) + virtual void writeBytes( const std::vector& value ) throw ( cms::CMSException ) = 0; /** * 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 + * + * 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 + * + * 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 + * + * 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 + * @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 + * @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 std::size_t readBytes( unsigned char*& buffer, std::size_t length ) + virtual std::size_t readBytes( unsigned char*& buffer, std::size_t length ) const throw ( cms::CMSException ) = 0; /** @@ -167,7 +166,7 @@ * @returns char value from stream * @throws CMSException */ - virtual char readChar() throw ( cms::CMSException ) = 0; + virtual char readChar() const throw ( cms::CMSException ) = 0; /** * Writes a char to the bytes message stream as a 1-byte value @@ -181,7 +180,7 @@ * @returns double value from stream * @throws CMSException */ - virtual float readFloat() throw ( cms::CMSException ) = 0; + virtual float readFloat() const throw ( cms::CMSException ) = 0; /** * Writes a float to the bytes message stream as a 4 byte value @@ -195,7 +194,7 @@ * @returns double value from stream * @throws CMSException */ - virtual double readDouble() throw ( cms::CMSException ) = 0; + virtual double readDouble() const throw ( cms::CMSException ) = 0; /** * Writes a double to the bytes message stream as a 8 byte value @@ -209,7 +208,7 @@ * @returns short value from stream * @throws CMSException */ - virtual short readShort() throw ( cms::CMSException ) = 0; + virtual short readShort() const throw ( cms::CMSException ) = 0; /** * Writes a signed short to the bytes message stream as a 2 byte value @@ -223,7 +222,7 @@ * @returns unsigned short value from stream * @throws CMSException */ - virtual unsigned short readUnsignedShort() throw ( cms::CMSException ) = 0; + virtual unsigned short readUnsignedShort() const throw ( cms::CMSException ) = 0; /** * Writes a unsigned short to the bytes message stream as a 2 byte value @@ -237,7 +236,7 @@ * @returns int value from stream * @throws CMSException */ - virtual int readInt() throw ( cms::CMSException ) = 0; + virtual int readInt() const throw ( cms::CMSException ) = 0; /** * Writes a signed int to the bytes message stream as a 4 byte value @@ -251,7 +250,7 @@ * @returns long long value from stream * @throws CMSException */ - virtual long long readLong() throw ( cms::CMSException ) = 0; + virtual long long readLong() const throw ( cms::CMSException ) = 0; /** * Writes a long long to the bytes message stream as a 8 byte value @@ -265,7 +264,7 @@ * @returns String from stream * @throws CMSException */ - virtual std::string readString() throw ( cms::CMSException ) = 0; + virtual std::string readString() const throw ( cms::CMSException ) = 0; /** * Writes an ASCII String to the Bytes message stream @@ -279,7 +278,7 @@ * @returns String from stream * @throws CMSException */ - virtual std::string readUTF() throw ( cms::CMSException ) = 0; + virtual std::string readUTF() const throw ( cms::CMSException ) = 0; /** * Writes an UTF String to the BytesMessage stream @@ -289,6 +288,7 @@ virtual void writeUTF( const std::string& value ) throw ( cms::CMSException ) = 0; virtual BytesMessage* clone() const = 0; + }; }