activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r591825 [1/2] - in /activemq/activemq-cpp/decaf/trunk/src: main/decaf/io/ main/decaf/net/ test/ test/decaf/io/ test/decaf/lang/ test/decaf/net/
Date Sun, 04 Nov 2007 19:59:11 GMT
Author: tabish
Date: Sun Nov  4 11:59:09 2007
New Revision: 591825

URL: http://svn.apache.org/viewvc?rev=591825&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103
http://issues.apache.org/activemq/browse/AMQCPP-136

Modified:
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BlockingByteArrayInputStream.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BlockingByteArrayInputStream.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedInputStream.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedInputStream.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedOutputStream.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedOutputStream.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayInputStream.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayInputStream.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayOutputStream.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayOutputStream.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataInputStream.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataInputStream.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/FilterInputStream.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/FilterOutputStream.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/InputStream.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/OutputStream.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/StandardErrorOutputStream.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketInputStream.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketInputStream.h
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketOutputStream.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketOutputStream.h
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedInputStreamTest.cpp
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedInputStreamTest.h
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedOutputStreamTest.cpp
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedOutputStreamTest.h
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/ByteArrayInputStreamTest.cpp
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/ByteArrayOutputStreamTest.cpp
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/DataOutputStreamTest.cpp
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/FilterInputStreamTest.cpp
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/FilterInputStreamTest.h
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/FilterOutputStreamTest.cpp
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/lang/MathTest.cpp
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/net/SocketFactoryTest.h
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/net/SocketTest.cpp
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/net/SocketTest.h
    activemq/activemq-cpp/decaf/trunk/src/test/testRegistry.cpp

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BlockingByteArrayInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BlockingByteArrayInputStream.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BlockingByteArrayInputStream.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BlockingByteArrayInputStream.cpp Sun Nov  4 11:59:09 2007
@@ -103,6 +103,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 int BlockingByteArrayInputStream::read( unsigned char* buffer,
+                                        std::size_t offset,
                                         std::size_t bufferSize )
     throw ( IOException, lang::exceptions::NullPointerException ){
 
@@ -129,7 +130,7 @@
             }
 
             if( !closing ){
-                buffer[ix] = *(pos);
+                buffer[ix + offset] = *(pos);
             }
         }
 

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BlockingByteArrayInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BlockingByteArrayInputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BlockingByteArrayInputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BlockingByteArrayInputStream.h Sun Nov  4 11:59:09 2007
@@ -109,11 +109,14 @@
          * 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 offset the position in the buffer to start from.
          * @param bufferSize the size of the output buffer.
          * @return the number of bytes read. or -1 if EOF
          * @throws IOException f an error occurs.
          */
-        virtual int read( unsigned char* buffer, std::size_t bufferSize )
+        virtual int read( unsigned char* buffer,
+                          std::size_t offset,
+                          std::size_t bufferSize )
             throw ( IOException, lang::exceptions::NullPointerException );
 
         /**

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedInputStream.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedInputStream.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedInputStream.cpp Sun Nov  4 11:59:09 2007
@@ -67,9 +67,11 @@
     this->bufferSize = bufferSize;
 
     // Create the buffer and initialize the head and tail positions.
-    buffer = new unsigned char[bufferSize];
-    head = 0;
-    tail = 0;
+    this->buffer = new unsigned char[bufferSize];
+    this->head = 0;
+    this->tail = 0;
+    this->markLimit = 0;
+    this->markpos = -1;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -123,6 +125,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 int BufferedInputStream::read( unsigned char* targetBuffer,
+                               std::size_t offset,
                                std::size_t targetBufferSize )
     throw ( IOException, NullPointerException ){
 
@@ -158,7 +161,7 @@
             std::size_t bytesToCopy = min( tail-head, (targetBufferSize-totalRead) );
 
             // Copy the data to the output buffer.
-            memcpy( targetBuffer+totalRead, this->buffer+head, bytesToCopy );
+            memcpy( targetBuffer+totalRead+offset, this->buffer+head, bytesToCopy );
 
             // Increment the total bytes read.
             totalRead += bytesToCopy;
@@ -254,7 +257,7 @@
         std::size_t bytesToRead = max( (std::size_t)1, min( available, getUnusedBytes() ) );
 
         // Read the bytes from the input stream.
-        int bytesRead = inputStream->read( getTail(), bytesToRead );
+        int bytesRead = inputStream->read( getTail(), 0, bytesToRead );
         if( bytesRead == 0 ){
             throw IOException(
                 __FILE__, __LINE__,
@@ -274,4 +277,3 @@
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
-

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedInputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedInputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedInputStream.h Sun Nov  4 11:59:09 2007
@@ -53,6 +53,17 @@
          */
         std::size_t tail;
 
+        /**
+         * The current limit, which when passed, invalidates the current mark.
+         */
+        int markLimit;
+
+        /**
+         * The currently marked position. -1 indicates no mark has been set or the
+         * mark has been invalidated.
+         */
+        int markpos;
+
     public:
 
         /**
@@ -110,12 +121,15 @@
          * Reads an array of bytes from the buffer.  Blocks
          * until the requested number of bytes are available.
          * @param buffer (out) the target buffer.
+         * @param offset the position in the buffer to start reading from.
          * @param bufferSize the size of the output buffer.
          * @return The number of bytes read or -1 if EOF
          * @throws IOException thrown if an error occurs.
          * @throws NullPointerException if buffer is NULL
          */
-        virtual int read( unsigned char* buffer, std::size_t bufferSize )
+        virtual int read( unsigned char* buffer,
+                          std::size_t offset,
+                          std::size_t bufferSize )
             throw ( IOException,
                     lang::exceptions::NullPointerException );
 
@@ -137,6 +151,58 @@
          */
         virtual std::size_t skip( std::size_t num )
             throw ( io::IOException, lang::exceptions::UnsupportedOperationException );
+
+        /**
+         * Marks the current position in the stream A subsequent call to the
+         * reset method repositions this stream at the last marked position so
+         * that subsequent reads re-read the same bytes.
+         *
+         * If a stream instance reports that marks are supported then the stream
+         * will ensure that the same bytes can be read again after the reset method
+         * is called so long the readLimit is not reached.
+         * @param readLimit - max bytes read before marked position is invalid.
+         */
+        virtual void mark( int readLimit ) {
+            this->markLimit = readLimit;
+            this->markpos = head;
+        }
+
+        /**
+         * Repositions this stream to the position at the time the mark method was
+         * last called on this input stream.
+         *
+         * If the method markSupported returns true, then:
+         *   * If the method mark has not been called since the stream was created,
+         *     or the number of bytes read from the stream since mark was last called
+         * 	   is larger than the argument to mark at that last call, then an
+         *     IOException might be thrown.
+         *   * If such an IOException is not thrown, then the stream is reset to a
+         *     state such that all the bytes read since the most recent call to mark
+         *     (or since the start of the file, if mark has not been called) will be
+         *     resupplied to subsequent callers of the read method, followed by any
+         *     bytes that otherwise would have been the next input data as of the
+         *     time of the call to reset.
+         * If the method markSupported returns false, then:
+         *   * The call to reset may throw an IOException.
+         *   * If an IOException is not thrown, then the stream is reset to a fixed
+         *     state that depends on the particular type of the input stream and how
+         *     it was created. The bytes that will be supplied to subsequent callers
+         *     of the read method depend on the particular type of the input stream.
+         * @throws IOException
+         */
+        virtual void reset() throw ( IOException ) {
+            throw IOException(
+                __FILE__, __LINE__,
+                "BufferedInputStream::reset - mark no yet supported." );
+        }
+
+        /**
+         * Determines if this input stream supports the mark and reset methods.
+         * Whether or not mark and reset are supported is an invariant property of
+         * a particular input stream instance.
+         * @returns true if this stream instance supports marks
+         */
+        virtual bool markSupported() const{ return false; }
 
     private:
 

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedOutputStream.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedOutputStream.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedOutputStream.cpp Sun Nov  4 11:59:09 2007
@@ -93,7 +93,7 @@
     }
 
     if( head != tail ){
-        outputStream->write( buffer+head, tail-head );
+        outputStream->write( buffer+head, 0, tail-head );
     }
     head = tail = 0;
 }
@@ -141,29 +141,51 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void BufferedOutputStream::write( const unsigned char* buffer, std::size_t len )
-    throw ( IOException, lang::exceptions::NullPointerException ) {
+void BufferedOutputStream::write( const std::vector<unsigned char>& buffer )
+    throw ( IOException ) {
 
     try{
 
+        if( buffer.empty() ) {
+            return;
+        }
+
         if( isClosed() ){
             throw IOException(
                 __FILE__, __LINE__,
                 "BufferedOutputStream::write - Stream is clsoed" );
         }
 
+        this->write( &buffer[0], 0, buffer.size() );
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
 
-        if( buffer == NULL ) {
-            throw NullPointerException(
-                __FILE__, __LINE__,
-                "BufferedOutputStream::write - Buffer passed is Null.");
-        }
+////////////////////////////////////////////////////////////////////////////////
+void BufferedOutputStream::write( const unsigned char* buffer,
+                                  std::size_t offset, std::size_t len )
+    throw ( IOException, lang::exceptions::NullPointerException ) {
+
+    try{
 
         // Fast exit.
         if( len == 0 ) {
             return;
         }
 
+        if( isClosed() ){
+            throw IOException(
+                __FILE__, __LINE__,
+                "BufferedOutputStream::write - Stream is clsoed" );
+        }
+
+        if( buffer == NULL ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "BufferedOutputStream::write - Buffer passed is Null.");
+        }
+
         // Iterate until all the data is written.
         for( std::size_t pos=0; pos < len; ){
 
@@ -175,7 +197,7 @@
             std::size_t bytesToWrite = min( (int)bufferSize-tail, len-pos );
 
             // Copy the data.
-            memcpy( this->buffer+tail, buffer+pos, bytesToWrite );
+            memcpy( this->buffer+tail, buffer+offset+pos, bytesToWrite );
 
             // Increase the tail position.
             tail += bytesToWrite;

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedOutputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedOutputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/BufferedOutputStream.h Sun Nov  4 11:59:09 2007
@@ -81,12 +81,23 @@
 
         /**
          * Writes an array of bytes to the output stream.
+         * @param buffer The bytes to write.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const std::vector<unsigned char>& buffer )
+            throw ( IOException );
+
+        /**
+         * Writes an array of bytes to the output stream.
          * @param buffer The array of bytes to write.
+         * @param offset, the position to start writing in buffer.
          * @param len The number of bytes from the buffer to be written.
          * @throws IOException thrown if an error occurs.
          * @throws NullPointerException thrown if buffer is Null.
          */
-        virtual void write( const unsigned char* buffer, std::size_t len )
+        virtual void write( const unsigned char* buffer,
+                            std::size_t offset,
+                            std::size_t len )
             throw ( IOException, lang::exceptions::NullPointerException );
 
         /**

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayInputStream.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayInputStream.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayInputStream.cpp Sun Nov  4 11:59:09 2007
@@ -50,8 +50,9 @@
     // We're using the default buffer.
     this->activeBuffer = &buffer;
 
-    // Begin at the Beginning.
-    reset();
+    // Start the stream off at the beginning marking begin as the reset point.
+    this->markpos = this->activeBuffer->begin();
+    this->pos = this->markpos;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -69,18 +70,20 @@
     std::back_insert_iterator< std::vector<unsigned char> > iter( this->defaultBuffer );
     std::copy( buffer, buffer + bufferSize, iter );
 
-    // Begin at the Beginning.
-    reset();
+    // Start the stream off at the beginning marking begin as the reset point.
+    this->markpos = this->activeBuffer->begin();
+    this->pos = this->markpos;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ByteArrayInputStream::reset() throw ( lang::Exception){
+void ByteArrayInputStream::reset() throw ( IOException){
     if( activeBuffer == NULL ){
         throw IOException( __FILE__, __LINE__, "Buffer has not been initialized" );
     }
 
-    // Begin at the Beginning.
-    pos = activeBuffer->begin();
+    // Begin at the Beginning if mark hasn't been called otherwise it
+    // starts at the marked pos.
+    pos = this->markpos;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -103,6 +106,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 int ByteArrayInputStream::read( unsigned char* buffer,
+                                std::size_t offset,
                                 std::size_t bufferSize )
     throw ( IOException, lang::exceptions::NullPointerException ){
 
@@ -134,7 +138,7 @@
         bufferSize = remaining < bufferSize ? remaining : bufferSize;
 
         for( ; ix < bufferSize; ++ix, ++pos) {
-            buffer[ix] = *(pos);
+            buffer[ix + offset] = *(pos);
         }
 
         return ix;

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayInputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayInputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayInputStream.h Sun Nov  4 11:59:09 2007
@@ -56,6 +56,11 @@
          */
         util::concurrent::Mutex mutex;
 
+        /**
+         * The currently marked position or begin() of activeBuffer.
+         */
+        std::vector<unsigned char>::const_iterator markpos;
+
     public:
 
         /**
@@ -124,11 +129,14 @@
         /**
          * Reads an array of bytes from the buffer.
          * @param buffer (out) the target buffer.
+         * @param offset the position in the buffer to start reading from.
          * @param bufferSize the size of the output buffer.
          * @return The number of bytes read.
          * @throws IOException thrown if an error occurs.
          */
-        virtual int read( unsigned char* buffer, std::size_t bufferSize )
+        virtual int read( unsigned char* buffer,
+                          std::size_t offset,
+                          std::size_t bufferSize )
             throw ( IOException, lang::exceptions::NullPointerException );
 
         /**
@@ -138,12 +146,6 @@
         virtual void close() throw( lang::Exception ){ /* do nothing */ }
 
         /**
-         * Resets the read index to the beginning of the byte
-         * array.
-         */
-        virtual void reset() throw ( lang::Exception );
-
-        /**
          * Skips over and discards n bytes of data from this input stream. The
          * skip method may, for a variety of reasons, end up skipping over some
          * smaller number of bytes, possibly 0. This may result from any of a
@@ -161,6 +163,37 @@
          */
         virtual std::size_t skip( std::size_t num )
             throw ( io::IOException, lang::exceptions::UnsupportedOperationException );
+
+        /**
+         * Marks the current position in the stream A subsequent call to the
+         * reset method repositions this stream at the last marked position so
+         * that subsequent reads re-read the same bytes.
+         *
+         * If a stream instance reports that marks are supported then the stream
+         * will ensure that the same bytes can be read again after the reset method
+         * is called so long the readLimit is not reached.
+         * @param readLimit - max bytes read before marked position is invalid.
+         */
+        virtual void mark( int readLimit DECAF_UNUSED ) {
+            // the reset point is now the marked position until a new byte buffer
+            // is set on this stream.
+            this->markpos = pos;
+        }
+
+        /**
+         * Resets the read index to the beginning of the byte array, unless mark
+         * has been called and the markLimit has not been exceeded, in which case
+         * the stream is reset to the marked position.
+         */
+        virtual void reset() throw ( IOException );
+
+        /**
+         * Determines if this input stream supports the mark and reset methods.
+         * Whether or not mark and reset are supported is an invariant property of
+         * a particular input stream instance.
+         * @returns true if this stream instance supports marks
+         */
+        virtual bool markSupported() const{ return true; }
 
     protected:
 

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayOutputStream.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayOutputStream.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayOutputStream.cpp Sun Nov  4 11:59:09 2007
@@ -52,7 +52,24 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void ByteArrayOutputStream::write( const std::vector<unsigned char>& buffer )
+    throw ( IOException ) {
+
+    try{
+
+        if( buffer.empty() ) {
+            return;
+        }
+
+        this->write( &buffer[0], 0, buffer.size() );
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void ByteArrayOutputStream::write( const unsigned char* buffer,
+                                   std::size_t offset,
                                    std::size_t len )
     throw ( IOException, lang::exceptions::NullPointerException ) {
 
@@ -63,7 +80,7 @@
     }
 
     std::back_insert_iterator< std::vector<unsigned char> > iter( *activeBuffer );
-    std::copy( buffer, buffer + len, iter );
+    std::copy( buffer, buffer + offset + len, iter );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -92,7 +109,7 @@
                 "ByteArrayOutputStream::writeTo - Passed stream pointer is null" );
         }
 
-        out->write( this->toByteArray(), this->size() );
+        out->write( this->toByteArray(), 0, this->size() );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCH_RETHROW( NullPointerException )

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayOutputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayOutputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/ByteArrayOutputStream.h Sun Nov  4 11:59:09 2007
@@ -100,12 +100,23 @@
 
         /**
          * Writes an array of bytes to the output stream.
+         * @param buffer The bytes to write.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const std::vector<unsigned char>& buffer )
+            throw ( IOException );
+
+        /**
+         * Writes an array of bytes to the output stream.
          * @param buffer The array of bytes to write.
+         * @param offset, the position to start writing in buffer.
          * @param len The number of bytes from the buffer to be written.
          * @throws IOException thrown if an error occurs.
          * @throws NullPointerException thrown if buffer is Null.
          */
-        virtual void write( const unsigned char* buffer, std::size_t len )
+        virtual void write( const unsigned char* buffer,
+                            std::size_t offset,
+                            std::size_t len )
             throw ( IOException, lang::exceptions::NullPointerException );
 
         /**

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataInputStream.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataInputStream.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataInputStream.cpp Sun Nov  4 11:59:09 2007
@@ -66,7 +66,7 @@
                 "DataInputStream::readFully - Base input stream is null" );
         }
 
-        return inputStream->read( &buffer[offset], length );
+        return inputStream->read( &buffer[offset], 0, length );
     }
     DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
     DECAF_CATCH_RETHROW( NullPointerException )
@@ -245,7 +245,7 @@
 
         while( true ) {
 
-            if( inputStream->read( (unsigned char*)( &buffer[pos] ), 1 ) == -1 ) {
+            if( inputStream->read( (unsigned char*)( &buffer[pos] ), 0, 1 ) == -1 ) {
                 throw EOFException(
                     __FILE__, __LINE__,
                     "DataInputStream::readString - Reached EOF" );
@@ -286,7 +286,7 @@
 
         std::size_t n = 0;
         while( n < length ) {
-            int count = inputStream->read( &buffer[n], (length - n) );
+            int count = inputStream->read( &buffer[n], 0, (length - n) );
             if( count == -1 ) {
                 throw EOFException(
                     __FILE__, __LINE__,
@@ -344,7 +344,7 @@
 
         std::size_t n = 0;
         while( n < length ) {
-            int count = inputStream->read( &buffer[offset + n], (length - n) );
+            int count = inputStream->read( &buffer[offset + n], 0, (length - n) );
             if( count == -1 ) {
                 throw EOFException(
                     __FILE__, __LINE__,

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataInputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataInputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataInputStream.h Sun Nov  4 11:59:09 2007
@@ -357,7 +357,7 @@
 
             std::size_t n = 0;
             do{
-                int count = inputStream->read( &buffer[n], length - n );
+                int count = inputStream->read( &buffer[n], 0, length - n );
                 if( count == -1 ) {
                     throw EOFException(
                         __FILE__, __LINE__,

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.cpp Sun Nov  4 11:59:09 2007
@@ -21,6 +21,7 @@
 using namespace decaf;
 using namespace decaf::io;
 using namespace decaf::util;
+using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
 DataOutputStream::DataOutputStream( OutputStream* outputStream, bool own )
@@ -67,7 +68,7 @@
                 "DataOutputStream::write - Base stream is Null");
         }
 
-        outputStream->write( &buffer[0], buffer.size() );
+        outputStream->write( &buffer[0], 0, buffer.size() );
         written += buffer.size();
     }
     DECAF_CATCH_RETHROW( IOException )
@@ -75,32 +76,10 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void DataOutputStream::write( const unsigned char* buffer, std::size_t len )
-    throw ( IOException ) {
-
-    try {
-
-        if( len == 0 ) {
-            return;
-        }
-
-        if( outputStream == NULL ) {
-            throw IOException(
-                __FILE__, __LINE__,
-                "DataOutputStream::write - Base stream is Null");
-        }
-
-        outputStream->write( buffer, len );
-        written += len;
-    }
-    DECAF_CATCH_RETHROW( IOException )
-    DECAF_CATCHALL_THROW( IOException )
-}
-
-////////////////////////////////////////////////////////////////////////////////
 void DataOutputStream::write( const unsigned char* buffer,
                               std::size_t offset,
-                              std::size_t len ) throw ( IOException )
+                              std::size_t len )
+    throw ( IOException, lang::exceptions::NullPointerException )
 {
 
     try {
@@ -109,16 +88,23 @@
             return;
         }
 
-        if( outputStream == NULL ) {
+        if( isClosed() ) {
             throw IOException(
                 __FILE__, __LINE__,
                 "DataOutputStream::write - Base stream is Null");
         }
 
-        outputStream->write( buffer+offset, len );
+        if( buffer == NULL ) {
+            throw NullPointerException(
+                __FILE__, __LINE__,
+                "DataOutputStream::write - passed buffer is Null" );
+        }
+
+        outputStream->write( buffer+offset, 0, len );
         written += len;
     }
     DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCHALL_THROW( IOException )
 }
 
@@ -190,7 +176,7 @@
         buffer[0] = (value & 0xFF00) >> 8;
         buffer[1] = (value & 0x00FF) >> 0;
 
-        outputStream->write( buffer, sizeof(value) );
+        outputStream->write( buffer, 0, sizeof(value) );
         written += sizeof( value );
     }
     DECAF_CATCH_RETHROW( IOException )
@@ -214,7 +200,7 @@
         buffer[0] = (value & 0xFF00) >> 8;
         buffer[1] = (value & 0x00FF) >> 0;
 
-        outputStream->write( buffer, sizeof(value) );
+        outputStream->write( buffer, 0, sizeof(value) );
         written += sizeof( value );
     }
     DECAF_CATCH_RETHROW( IOException )
@@ -238,7 +224,7 @@
         buffer[2] = (value & 0x0000FF00) >> 8;
         buffer[3] = (value & 0x000000FF) >> 0;
 
-        outputStream->write( buffer, sizeof(value) );
+        outputStream->write( buffer, 0, sizeof(value) );
         written += sizeof( value );
     }
     DECAF_CATCH_RETHROW( IOException )
@@ -266,7 +252,7 @@
         buffer[6] = (unsigned char)((value & 0x000000000000FF00ULL) >> 8);
         buffer[7] = (unsigned char)((value & 0x00000000000000FFULL) >> 0);
 
-        outputStream->write( buffer, sizeof(value) );
+        outputStream->write( buffer, 0, sizeof(value) );
         written += sizeof( value );
     }
     DECAF_CATCH_RETHROW( IOException )
@@ -304,7 +290,7 @@
         }
 
         // do not add one so that we don't write the NULL
-        this->write( (const unsigned char*)value.c_str(), value.length() );
+        this->write( (const unsigned char*)value.c_str(), 0, value.length() );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
@@ -319,7 +305,7 @@
         }
 
         // add one so that we write the NULL
-        this->write( (const unsigned char*)value.c_str(), value.length() + 1 );
+        this->write( (const unsigned char*)value.c_str(), 0, value.length() + 1 );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
@@ -334,7 +320,7 @@
         }
 
         this->writeUnsignedShort( (unsigned short)value.length() );
-        this->write( (const unsigned char*)value.c_str(), value.length() );
+        this->write( (const unsigned char*)value.c_str(), 0, value.length() );
     }
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.h Sun Nov  4 11:59:09 2007
@@ -69,22 +69,15 @@
          * Writes an array of bytes to the output stream.  the counter
          * written is incremented by len.
          * @param buffer The array of bytes to write.
+         * @param offset the position in buffer to start writing from.
          * @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, std::size_t len )
-            throw ( IOException );
-
-        /**
-         * Writes an array of bytes to the output stream.  the counter
-         * written is incremented by len.
-         * @param buffer The array of bytes to write.
-         * @param len The number of bytes from the buffer to be written.
-         * @throws IOException thrown if an error occurs.
+         * @throws NullPointerException if buffer is Null
          */
         virtual void write( const unsigned char* buffer,
                             std::size_t offset,
-                            std::size_t len ) throw ( IOException );
+                            std::size_t len )
+            throw ( IOException, lang::exceptions::NullPointerException );
 
         /**
          * Writes an array of bytes to the output stream.

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/FilterInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/FilterInputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/FilterInputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/FilterInputStream.h Sun Nov  4 11:59:09 2007
@@ -124,12 +124,15 @@
          * of bytes. This method blocks until some input is available.
          * This method simply performs in.read(b, len) and returns the result.
          * @param buffer (out) the target buffer.
+         * @param offset the position to start reading in the passed buffer.
          * @param bufferSize the size of the output buffer.
          * @return The number of bytes read or -1 if EOF is detected
          * @throws IOException thrown if an error occurs.
          * @throws NullPointerException
          */
-        virtual int read( unsigned char* buffer, std::size_t bufferSize )
+        virtual int read( unsigned char* buffer,
+                          std::size_t offset,
+                          std::size_t bufferSize )
             throw ( IOException,
                     lang::exceptions::NullPointerException )
         {
@@ -141,7 +144,7 @@
                         "FilterInputStream::read - Stream is closed" );
                 }
 
-                return inputStream->read( buffer, bufferSize );
+                return inputStream->read( buffer, offset, bufferSize );
             }
             DECAF_CATCH_RETHROW( IOException )
             DECAF_CATCH_RETHROW( lang::exceptions::NullPointerException )
@@ -200,6 +203,80 @@
             DECAF_CATCHALL_THROW( IOException )
         }
 
+        /**
+         * Marks the current position in the stream A subsequent call to the
+         * reset method repositions this stream at the last marked position so
+         * that subsequent reads re-read the same bytes.
+         *
+         * If a stream instance reports that marks are supported then the stream
+         * will ensure that the same bytes can be read again after the reset method
+         * is called so long the readLimit is not reached.
+         * @param readLimit - max bytes read before marked position is invalid.
+         */
+        virtual void mark( int readLimit ) {
+            try {
+
+                if( !isClosed() ) {
+                    inputStream->mark( readLimit );
+                }
+            }
+            DECAF_CATCHALL_NOTHROW()
+        }
+
+        /**
+         * Repositions this stream to the position at the time the mark method was
+         * last called on this input stream.
+         *
+         * If the method markSupported returns true, then:
+         *   * If the method mark has not been called since the stream was created,
+         *     or the number of bytes read from the stream since mark was last called
+         * 	   is larger than the argument to mark at that last call, then an
+         *     IOException might be thrown.
+         *   * If such an IOException is not thrown, then the stream is reset to a
+         *     state such that all the bytes read since the most recent call to mark
+         *     (or since the start of the file, if mark has not been called) will be
+         *     resupplied to subsequent callers of the read method, followed by any
+         *     bytes that otherwise would have been the next input data as of the
+         *     time of the call to reset.
+         * If the method markSupported returns false, then:
+         *   * The call to reset may throw an IOException.
+         *   * If an IOException is not thrown, then the stream is reset to a fixed
+         *     state that depends on the particular type of the input stream and how
+         *     it was created. The bytes that will be supplied to subsequent callers
+         *     of the read method depend on the particular type of the input stream.
+         * @throws IOException
+         */
+        virtual void reset() throw ( IOException ) {
+            try {
+
+                if( isClosed() ) {
+                    throw IOException(
+                        __FILE__, __LINE__,
+                        "FilterInputStream::skip - Stream is closed" );
+                }
+
+                return inputStream->reset();
+            }
+            DECAF_CATCH_RETHROW( IOException )
+            DECAF_CATCHALL_THROW( IOException )
+        }
+
+        /**
+         * Determines if this input stream supports the mark and reset methods.
+         * Whether or not mark and reset are supported is an invariant property of
+         * a particular input stream instance.
+         * @returns true if this stream instance supports marks
+         */
+        virtual bool markSupported() const {
+            try {
+                if( !isClosed() ) {
+                    return inputStream->markSupported();
+                }
+            }
+            DECAF_CATCHALL_NOTHROW()
+            return false;
+        }
+
     public:  // Synchronizable
 
         /**
@@ -268,7 +345,7 @@
          * @returns true if this stream has been closed.
          */
         virtual bool isClosed() const {
-            return this->closed;
+            return this->closed || inputStream == NULL;
         }
 
     };

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/FilterOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/FilterOutputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/FilterOutputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/FilterOutputStream.h Sun Nov  4 11:59:09 2007
@@ -106,15 +106,42 @@
         }
 
         /**
+         * Writes an array of bytes to the output stream.
+         * @param buffer The bytes to write.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const std::vector<unsigned char>& buffer )
+            throw ( IOException ) {
+
+            try {
+
+                if( isClosed() ) {
+                    throw IOException(
+                        __FILE__, __LINE__,
+                        "FilterOutputStream::write - Stream is closed" );
+                }
+
+                for( std::size_t ix = 0; ix < buffer.size(); ++ix ) {
+                    outputStream->write( buffer[ix] );
+                }
+            }
+            DECAF_CATCH_RETHROW( IOException )
+            DECAF_CATCHALL_THROW( IOException )
+        }
+
+        /**
          * Writes an array of bytes to the output stream.  The write method of
          * FilterOutputStream calls the write method of one argument on each
          * byte to output.
          * @param buffer The array of bytes to write.
+         * @param offset, the position to start writing in buffer.
          * @param len The number of bytes from the buffer to be written.
          * @throws IOException thrown if an error occurs.
          * @throws NullPointerException thrown if buffer is Null.
          */
-        virtual void write( const unsigned char* buffer, std::size_t len )
+        virtual void write( const unsigned char* buffer,
+                            std::size_t offset DECAF_UNUSED,
+                            std::size_t len )
             throw ( IOException,
                     lang::exceptions::NullPointerException ) {
             try {
@@ -250,7 +277,7 @@
          * @returns true if this stream has been closed.
          */
         virtual bool isClosed() const {
-            return this->closed;
+            return this->closed || this->outputStream == NULL;
         }
 
     };

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/InputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/InputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/InputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/InputStream.h Sun Nov  4 11:59:09 2007
@@ -39,6 +39,51 @@
         virtual ~InputStream(){}
 
         /**
+         * Marks the current position in the stream A subsequent call to the
+         * reset method repositions this stream at the last marked position so
+         * that subsequent reads re-read the same bytes.
+         *
+         * If a stream instance reports that marks are supported then the stream
+         * will ensure that the same bytes can be read again after the reset method
+         * is called so long the readLimit is not reached.
+         * @param readLimit - max bytes read before marked position is invalid.
+         */
+        virtual void mark( int readLimit ) = 0;
+
+        /**
+         * Repositions this stream to the position at the time the mark method was
+         * last called on this input stream.
+         *
+         * If the method markSupported returns true, then:
+         *   * If the method mark has not been called since the stream was created,
+         *     or the number of bytes read from the stream since mark was last called
+         * 	   is larger than the argument to mark at that last call, then an
+         *     IOException might be thrown.
+         *   * If such an IOException is not thrown, then the stream is reset to a
+         *     state such that all the bytes read since the most recent call to mark
+         *     (or since the start of the file, if mark has not been called) will be
+         *     resupplied to subsequent callers of the read method, followed by any
+         *     bytes that otherwise would have been the next input data as of the
+         *     time of the call to reset.
+         * If the method markSupported returns false, then:
+         *   * The call to reset may throw an IOException.
+         *   * If an IOException is not thrown, then the stream is reset to a fixed
+         *     state that depends on the particular type of the input stream and how
+         *     it was created. The bytes that will be supplied to subsequent callers
+         *     of the read method depend on the particular type of the input stream.
+         * @throws IOException
+         */
+        virtual void reset() throw ( IOException ) = 0;
+
+        /**
+         * Determines if this input stream supports the mark and reset methods.
+         * Whether or not mark and reset are supported is an invariant property of
+         * a particular input stream instance.
+         * @returns true if this stream instance supports marks
+         */
+        virtual bool markSupported() const = 0;
+
+        /**
          * Indcates the number of bytes avaialable.
          * @return the number of bytes available on this input stream.
          * @throws IOException if an error occurs.
@@ -57,11 +102,15 @@
          * Reads an array of bytes from the buffer.  Blocks until
          * the requested number of bytes are available.
          * @param buffer (out) the target buffer.
+         * @param offset the position in the buffer to start reading from.
          * @param bufferSize the size of the output buffer.
          * @return The number of bytes read or -1 if EOF is detected
          * @throws IOException thrown if an error occurs.
+         * @throws NullPointerException if buffer is null
          */
-        virtual int read( unsigned char* buffer, std::size_t bufferSize )
+        virtual int read( unsigned char* buffer,
+                          std::size_t offset,
+                          std::size_t bufferSize )
             throw ( IOException,
                     lang::exceptions::NullPointerException ) = 0;
 

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/OutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/OutputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/OutputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/OutputStream.h Sun Nov  4 11:59:09 2007
@@ -46,12 +46,23 @@
 
         /**
          * Writes an array of bytes to the output stream.
+         * @param buffer The bytes to write.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const std::vector<unsigned char>& buffer )
+            throw ( IOException ) = 0;
+
+        /**
+         * Writes an array of bytes to the output stream.
          * @param buffer The array of bytes to write.
+         * @param offset, the position to start writing in buffer.
          * @param len The number of bytes from the buffer to be written.
          * @throws IOException thrown if an error occurs.
          * @throws NullPointerException thrown if buffer is Null.
          */
-        virtual void write( const unsigned char* buffer, std::size_t len )
+        virtual void write( const unsigned char* buffer,
+                            std::size_t offset,
+                            std::size_t len )
             throw ( IOException, lang::exceptions::NullPointerException ) = 0;
 
         /**
@@ -59,6 +70,7 @@
          * @throws IOException
          */
         virtual void flush() throw ( IOException ) = 0;
+
     };
 
 }}

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/StandardErrorOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/StandardErrorOutputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/StandardErrorOutputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/StandardErrorOutputStream.h Sun Nov  4 11:59:09 2007
@@ -54,12 +54,30 @@
 
         /**
          * Writes an array of bytes to the output stream.
+         * @param buffer The bytes to write.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const std::vector<unsigned char>& buffer )
+            throw ( IOException ) {
+
+            if( buffer.empty() ){
+                return;
+            }
+
+            this->write( &buffer[0], 0, buffer.size() );
+        }
+
+        /**
+         * Writes an array of bytes to the output stream.
          * @param buffer The array of bytes to write.
+         * @param offset, the position to start writing in buffer.
          * @param len The number of bytes from the buffer to be written.
          * @throws IOException thrown if an error occurs.
          * @throws NullPointerException if buffer is null.
          */
-        virtual void write( const unsigned char* buffer, int len )
+        virtual void write( const unsigned char* buffer,
+                            std::size_t offset,
+                            std::size_t len )
             throw ( IOException, lang::exceptions::NullPointerException ) {
 
             if( buffer == NULL ) {
@@ -69,7 +87,7 @@
             }
 
             for( int i = 0; i < len; ++i ) {
-                std::cerr << buffer[i];
+                std::cerr << buffer[i+offset];
             }
         }
 

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketInputStream.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketInputStream.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketInputStream.cpp Sun Nov  4 11:59:09 2007
@@ -145,14 +145,16 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 int SocketInputStream::read( unsigned char* buffer,
-                             std::size_t bufferSize ) throw ( IOException )
-{
+                             std::size_t offset,
+                             std::size_t bufferSize )
+    throw ( IOException, lang::exceptions::NullPointerException ) {
+
     apr_size_t size = (apr_size_t)bufferSize;
     apr_status_t result = APR_SUCCESS;
 
     // Read data from the socket, size on input is size of buffer, when done
     // size is the number of bytes actually read, can be <= bufferSize.
-    result = apr_socket_recv( socket, (char*)buffer, &size );
+    result = apr_socket_recv( socket, (char*)buffer + offset, &size );
 
     // Check for EOF, on windows we only get size==0 so check that to, if we
     // were closed though then we throw an IOException so the caller knows we

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketInputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketInputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketInputStream.h Sun Nov  4 11:59:09 2007
@@ -22,6 +22,7 @@
 #include <decaf/net/Socket.h>
 #include <decaf/util/concurrent/Mutex.h>
 #include <decaf/lang/Exception.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
 
 namespace decaf{
 namespace net{
@@ -52,6 +53,105 @@
         virtual ~SocketInputStream();
 
         /**
+         * Returns the number of bytes available on the socket to
+         * be read right now.
+         * @return The number of bytes currently available to
+         * be read on the socket.
+         */
+        virtual std::size_t available() const throw ( io::IOException );
+
+        /**
+         * Reads a single byte from the buffer.  If no data
+         * is available, blocks until their is.
+         * @return The next byte.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual unsigned char read() throw ( io::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.
+         * @param buffer (out) the target buffer
+         * @param offset the position in the buffer to start from.
+         * @param bufferSize the size of the output buffer.
+         * @return the number of bytes read. or -1 if EOF
+         * @throws IOException f an error occurs.
+         */
+        virtual int read( unsigned char* buffer,
+                          std::size_t offset,
+                          std::size_t bufferSize )
+            throw ( io::IOException, lang::exceptions::NullPointerException );
+
+        /**
+         * Close - does nothing.  It is the responsibility of the owner
+         * of the socket object to close it.
+         * @throws CMSException
+         */
+        virtual void close() throw( lang::Exception );
+
+        /**
+         * Not supported.
+         * @throws an UnsupportedOperationException.
+         */
+        virtual std::size_t skip( std::size_t num )
+            throw ( io::IOException,
+                    lang::exceptions::UnsupportedOperationException );
+
+        /**
+         * Marks the current position in the stream A subsequent call to the
+         * reset method repositions this stream at the last marked position so
+         * that subsequent reads re-read the same bytes.
+         *
+         * If a stream instance reports that marks are supported then the stream
+         * will ensure that the same bytes can be read again after the reset method
+         * is called so long the readLimit is not reached.
+         * @param readLimit - max bytes read before marked position is invalid.
+         */
+        virtual void mark( int readLimit DECAF_UNUSED ) {}
+
+        /**
+         * Repositions this stream to the position at the time the mark method was
+         * last called on this input stream.
+         *
+         * If the method markSupported returns true, then:
+         *   * If the method mark has not been called since the stream was created,
+         *     or the number of bytes read from the stream since mark was last called
+         * 	   is larger than the argument to mark at that last call, then an
+         *     IOException might be thrown.
+         *   * If such an IOException is not thrown, then the stream is reset to a
+         *     state such that all the bytes read since the most recent call to mark
+         *     (or since the start of the file, if mark has not been called) will be
+         *     resupplied to subsequent callers of the read method, followed by any
+         *     bytes that otherwise would have been the next input data as of the
+         *     time of the call to reset.
+         * If the method markSupported returns false, then:
+         *   * The call to reset may throw an IOException.
+         *   * If an IOException is not thrown, then the stream is reset to a fixed
+         *     state that depends on the particular type of the input stream and how
+         *     it was created. The bytes that will be supplied to subsequent callers
+         *     of the read method depend on the particular type of the input stream.
+         * @throws IOException
+         */
+        virtual void reset() throw ( io::IOException ) {
+            throw io::IOException(
+                __FILE__, __LINE__,
+                "SocketInputStream::reset - Mark is not supported" );
+        }
+
+        /**
+         * Determines if this input stream supports the mark and reset methods.
+         * Whether or not mark and reset are supported is an invariant property of
+         * a particular input stream instance.
+         * @returns true if this stream instance supports marks
+         */
+        virtual bool markSupported() const {
+            return false;
+        }
+
+    public:
+
+        /**
          * Locks the object.
          * @throws Exception
          */
@@ -110,49 +210,6 @@
         virtual void notifyAll() throw( lang::Exception ){
             mutex.notifyAll();
         }
-
-        /**
-         * Returns the number of bytes available on the socket to
-         * be read right now.
-         * @return The number of bytes currently available to
-         * be read on the socket.
-         */
-        virtual std::size_t available() const throw ( io::IOException );
-
-        /**
-         * Reads a single byte from the buffer.  If no data
-         * is available, blocks until their is.
-         * @return The next byte.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual unsigned char read() throw ( io::IOException );
-
-        /**
-         * Reads an array of bytes from the buffer.  If no data
-         * is available, blocks until there is.
-         * @param buffer (out) the target buffer.
-         * @param bufferSize the size of the output buffer.
-         * @return The number of bytes read.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual int read( unsigned char* buffer,
-                          std::size_t bufferSize )
-            throw ( io::IOException );
-
-        /**
-         * Close - does nothing.  It is the responsibility of the owner
-         * of the socket object to close it.
-         * @throws CMSException
-         */
-        virtual void close() throw( lang::Exception );
-
-        /**
-         * Not supported.
-         * @throws an UnsupportedOperationException.
-         */
-        virtual std::size_t skip( std::size_t num )
-            throw ( io::IOException,
-                    lang::exceptions::UnsupportedOperationException );
 
     };
 

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketOutputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketOutputStream.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketOutputStream.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketOutputStream.cpp Sun Nov  4 11:59:09 2007
@@ -24,6 +24,7 @@
 using namespace decaf::net;
 using namespace decaf::io;
 using namespace decaf::util;
+using namespace decaf::lang::exceptions;
 using namespace std;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -44,20 +45,49 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 void SocketOutputStream::write( unsigned char c ) throw ( IOException ) {
-    write( &c, 1 );
+    write( &c, 0, 1 );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void SocketOutputStream::write( const unsigned char* buffer, std::size_t len )
+void SocketOutputStream::write( const std::vector<unsigned char>& buffer )
     throw ( IOException ) {
 
+    try{
+
+        if( buffer.empty() ) {
+            return;
+        }
+
+        this->write( &buffer[0], 0, buffer.size() );
+    }
+    DECAF_CATCH_RETHROW( IOException )
+    DECAF_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SocketOutputStream::write( const unsigned char* buffer,
+                                std::size_t offset, std::size_t len )
+    throw ( IOException, lang::exceptions::NullPointerException ) {
+
+    if( len == 0 ) {
+        return;
+    }
+
+    if( buffer == NULL ) {
+        throw NullPointerException(
+            __FILE__, __LINE__,
+            "SocketOutputStream::write - passed buffer is null" );
+    }
+
     apr_size_t remaining = (apr_size_t)len;
     apr_status_t result = APR_SUCCESS;
 
+    const unsigned char* lbuffer = buffer + offset;
+
     while( remaining > 0 && !closed ) {
         // On input remaining is the bytes to send, after return remaining
         // is the amount actually sent.
-        result = apr_socket_send( socket, (const char*)buffer, &remaining );
+        result = apr_socket_send( socket, (const char*)lbuffer, &remaining );
 
         if( result != APR_SUCCESS || closed ) {
             throw IOException(
@@ -67,7 +97,7 @@
         }
 
         // move us to next position to write, or maybe end.
-        buffer += remaining;
+        lbuffer += remaining;
         remaining = len - remaining;
     }
 }

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketOutputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketOutputStream.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketOutputStream.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/net/SocketOutputStream.h Sun Nov  4 11:59:09 2007
@@ -48,6 +48,49 @@
         virtual ~SocketOutputStream();
 
         /**
+         * Writes a single byte to the output stream.
+         * @param c the byte.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( unsigned char c ) throw ( io::IOException );
+
+        /**
+         * Writes an array of bytes to the output stream.
+         * @param buffer The bytes to write.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const std::vector<unsigned char>& buffer )
+            throw ( io::IOException );
+
+        /**
+         * Writes an array of bytes to the output stream.
+         * @param buffer The array of bytes to write.
+         * @param offset, the position to start writing in buffer.
+         * @param len The number of bytes from the buffer to be written.
+         * @throws IOException thrown if an error occurs.
+         * @throws NullPointerException thrown if buffer is Null.
+         */
+        virtual void write( const unsigned char* buffer,
+                            std::size_t offset,
+                            std::size_t len )
+            throw ( io::IOException, lang::exceptions::NullPointerException );
+
+        /**
+         * Flush - does nothing.
+         * @throws IOException
+         */
+        virtual void flush() throw ( io::IOException ){};
+
+        /**
+         * Close - does nothing.  It is the responsibility of the owner
+         * of the socket object to close it.
+         * @throws CMSException
+         */
+        virtual void close() throw( lang::Exception );
+
+    public:
+
+        /**
          * Locks the object.
          * @throws Exception
          */
@@ -105,35 +148,6 @@
         virtual void notifyAll() throw( lang::Exception ){
             mutex.notifyAll();
          }
-
-        /**
-         * Writes a single byte to the output stream.
-         * @param c the byte.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual void write( unsigned char c ) throw ( io::IOException );
-
-        /**
-         * Writes an array of bytes to the output stream.
-         * @param buffer The array of bytes to write.
-         * @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,
-                            std::size_t len ) throw ( io::IOException );
-
-        /**
-         * Flush - does nothing.
-         * @throws IOException
-         */
-        virtual void flush() throw ( io::IOException ){};
-
-        /**
-         * Close - does nothing.  It is the responsibility of the owner
-         * of the socket object to close it.
-         * @throws CMSException
-         */
-        virtual void close() throw( lang::Exception );
 
     };
 

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedInputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedInputStreamTest.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedInputStreamTest.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedInputStreamTest.cpp Sun Nov  4 11:59:09 2007
@@ -152,7 +152,7 @@
         CPPUNIT_ASSERT_MESSAGE( "Wrong initial byte", 0 == is.read() );
         // Fill the buffer
         unsigned char buf[14];
-        is.read( &buf[0], (std::size_t)14 );
+        is.read( &buf[0], 0, (std::size_t)14 );
 
         // Read greater than the buffer
         CPPUNIT_ASSERT_MESSAGE( "Wrong block read data",
@@ -181,7 +181,7 @@
     unsigned char buf1[100];
     try {
         is.skip( 3000 );
-        is.read( buf1, 100 );
+        is.read( buf1, 0, 100 );
         CPPUNIT_ASSERT_MESSAGE(
             "Failed to read correct data",
             string( (const char*)&buf1[0], 100 ) == testStr.substr( 3000, 100 ) );
@@ -197,15 +197,15 @@
     BufferedInputStream bis( NULL );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "should throw NullPointerException",
-        bis.read( NULL, -1 ),
-        NullPointerException );
+        "should throw IOException",
+        bis.read( NULL, 0, -1 ),
+        IOException );
 
     bis.close();
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw IOException",
-        bis.read( NULL, 1 ),
+        bis.read( NULL, 0, 1 ),
         IOException );
 }
 
@@ -242,7 +242,7 @@
 
     unsigned char dummyBuf[20];
     memset( dummyBuf, 0, 20 );
-    std::size_t numRead = bufStream.read( dummyBuf, 10 );
+    std::size_t numRead = bufStream.read( dummyBuf, 0, 10 );
     CPPUNIT_ASSERT( numRead == 10 );
     CPPUNIT_ASSERT( strcmp( (char*)dummyBuf, "1234567891" ) == 0 );
 
@@ -283,7 +283,7 @@
 
     unsigned char dummyBuf[20];
     memset( dummyBuf, 0, 20 );
-    std::size_t numRead = bufStream.read( dummyBuf, 10 );
+    std::size_t numRead = bufStream.read( dummyBuf, 0, 10 );
     CPPUNIT_ASSERT( numRead == 10 );
     CPPUNIT_ASSERT( strcmp( (char*)dummyBuf, "1234567891" ) == 0 );
 

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedInputStreamTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedInputStreamTest.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedInputStreamTest.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedInputStreamTest.h Sun Nov  4 11:59:09 2007
@@ -110,7 +110,11 @@
                 return data.c_str()[pos++];
             }
 
-            virtual int read( unsigned char* buffer, std::size_t bufferSize ) throw (IOException){
+            virtual int read( unsigned char* buffer,
+                              std::size_t offset,
+                              std::size_t bufferSize )
+                throw (IOException){
+
                 std::size_t numToRead = std::min( bufferSize, available() );
 
                 if( this->isThrowOnRead() ) {
@@ -126,7 +130,7 @@
 
                 const char* str = data.c_str();
                 for( std::size_t ix=0; ix<numToRead; ++ix ){
-                    buffer[ix] = str[pos+ix];
+                    buffer[ix+offset] = str[pos+ix];
                 }
 
                 pos += numToRead;
@@ -141,6 +145,18 @@
                 return ( pos += std::min( num, available() ) );
             }
 
+            virtual void mark( int readLimit DECAF_UNUSED ) {
+
+            }
+
+            virtual void reset() throw ( IOException ) {
+                throw IOException(
+                    __FILE__, __LINE__,
+                    "BufferedInputStream::reset - mark no yet supported." );
+            }
+
+            virtual bool markSupported() const{ return false; }
+
             virtual void lock() throw(lang::Exception){
             }
             virtual void unlock() throw(lang::Exception){
@@ -154,6 +170,7 @@
             virtual void notifyAll() throw(lang::Exception){
             }
         };
+
     };
 
 }}

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedOutputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedOutputStreamTest.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedOutputStreamTest.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedOutputStreamTest.cpp Sun Nov  4 11:59:09 2007
@@ -32,7 +32,7 @@
     try {
         MyOutputStream myStream;
         BufferedOutputStream os( &myStream );
-        os.write( (unsigned char*)&testString[0], 500 );
+        os.write( (unsigned char*)&testString[0], 0, 500 );
     } catch( IOException& e ) {
         CPPUNIT_FAIL("Constrcutor test failed");
     }
@@ -44,7 +44,7 @@
     try {
         MyOutputStream myStream;
         BufferedOutputStream os( &myStream, (std::size_t)1024 );
-        os.write( (unsigned char*)&testString[0], 500 );
+        os.write( (unsigned char*)&testString[0], 0, 500 );
     } catch( IOException& e) {
         CPPUNIT_FAIL("IOException during Constrcutor test");
     }
@@ -57,7 +57,7 @@
 
         ByteArrayOutputStream myStream;
         BufferedOutputStream os( &myStream, (std::size_t)600 );
-        os.write( (unsigned char*)&testString[0], 500 );
+        os.write( (unsigned char*)&testString[0], 0, 500 );
         os.flush();
         CPPUNIT_ASSERT_MESSAGE("Bytes not written after flush",
                 500 == myStream.size() );
@@ -73,19 +73,19 @@
 
         ByteArrayOutputStream baos;
         BufferedOutputStream os( &baos, (std::size_t)512 );
-        os.write( (unsigned char*)&testString[0], 500 );
+        os.write( (unsigned char*)&testString[0], 0, 500 );
 
         ByteArrayInputStream bais1( baos.toByteArray(), baos.size() );
         CPPUNIT_ASSERT_MESSAGE( "Bytes written, not buffered", 0 == bais1.available());
         os.flush();
         ByteArrayInputStream bais2( baos.toByteArray(), baos.size() );
         CPPUNIT_ASSERT_MESSAGE( "Bytes not written after flush", 500 == bais2.available() );
-        os.write( (unsigned char*)&testString[500], 514 );
+        os.write( (unsigned char*)&testString[500], 0, 514 );
         ByteArrayInputStream bais3( baos.toByteArray(), baos.size() );
         CPPUNIT_ASSERT_MESSAGE( "Bytes not written when buffer full",
                                 bais3.available() >= 1000);
         unsigned char wbytes[1014] = {0};
-        bais3.read( wbytes, 1013 );
+        bais3.read( wbytes, 0, 1013 );
 
         CPPUNIT_ASSERT_MESSAGE(
             "Incorrect bytes written",
@@ -105,17 +105,17 @@
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw NullPointerException",
-        bos.write( nullByteArray, (std::size_t)1 ),
+        bos.write( nullByteArray, 0, (std::size_t)1 ),
         NullPointerException );
 
-    bos.write( byteArray, 0 );
-    bos.write( byteArray, 1 );
-    bos.write( byteArray, 10 );
+    bos.write( byteArray, 0, 0 );
+    bos.write( byteArray, 0, 1 );
+    bos.write( byteArray, 0, 10 );
     bos.close();
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw IOException",
-        bos.write( nullByteArray, (std::size_t)1 ),
+        bos.write( nullByteArray, 0, (std::size_t)1 ),
         IOException );
 }
 
@@ -127,13 +127,12 @@
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw NullPointerException",
-        bos.write( nullByteArray, (std::size_t)1 ),
-        NullPointerException );
+        bos.write( nullByteArray, 0, (std::size_t)1 ),
+        IOException );
 
-    CPPUNIT_ASSERT_THROW_MESSAGE(
-        "should throw NullPointerException",
-        bos.write( nullByteArray, (std::size_t)0 ),
-        NullPointerException );
+    CPPUNIT_ASSERT_NO_THROW_MESSAGE(
+        "should not throw NullPointerException",
+        bos.write( nullByteArray, 0, (std::size_t)0 ) );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -143,14 +142,13 @@
     unsigned char* nullByteArray = NULL;
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
-        "should throw NullPointerException",
-        bos.write( nullByteArray, (std::size_t)1 ),
-        NullPointerException );
+        "should throw IOException",
+        bos.write( nullByteArray, 0, (std::size_t)1 ),
+        IOException );
 
-    CPPUNIT_ASSERT_THROW_MESSAGE(
-        "should throw NullPointerException",
-        bos.write( nullByteArray, (std::size_t)0 ),
-        NullPointerException );
+    CPPUNIT_ASSERT_NO_THROW_MESSAGE(
+        "should not throw NullPointerException",
+        bos.write( nullByteArray, 0, (std::size_t)0 ) );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -159,9 +157,19 @@
     BufferedOutputStream bos( NULL );
     unsigned char byteArray[10];
 
-    bos.write(byteArray, 0 );
-    bos.write(byteArray, 1 );
-    bos.write(byteArray, 10 );
+    CPPUNIT_ASSERT_NO_THROW_MESSAGE(
+        "should not throw IOException",
+        bos.write( byteArray, 0, (std::size_t)0 ) );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "should throw IOException",
+        bos.write( byteArray, 0, (std::size_t)1 ),
+        IOException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "should throw IOException",
+        bos.write( byteArray, 0, (std::size_t)10 ),
+        IOException );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -170,16 +178,16 @@
     BufferedOutputStream bos( NULL, (std::size_t)1 );
     unsigned char byteArray[10];
 
-    bos.write( byteArray, 0 );
+    bos.write( byteArray, 0, 0 );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw NullPointerException",
-        bos.write( byteArray, 2 ),
+        bos.write( byteArray, 0, 2 ),
         IOException );
 
     CPPUNIT_ASSERT_THROW_MESSAGE(
         "should throw NullPointerException",
-        bos.write( byteArray, 10 ),
+        bos.write( byteArray, 0, 10 ),
         IOException );
 }
 
@@ -198,7 +206,7 @@
         ByteArrayInputStream bais2( baos.toByteArray(), baos.size() );
         CPPUNIT_ASSERT_MESSAGE( "Byte not written after flush", 1 == bais2.available() );
         unsigned char wbytes[10];
-        bais2.read( wbytes, 1 );
+        bais2.read( wbytes, 0, 1 );
         CPPUNIT_ASSERT_MESSAGE( "Incorrect byte written", 't' == wbytes[0] );
 
     } catch( IOException& e) {
@@ -222,7 +230,7 @@
     // This time the T should have been written.
     CPPUNIT_ASSERT( strcmp( buffer, "T" ) == 0 );
 
-    bufStream.write( (unsigned char*)"ST", 2 );
+    bufStream.write( (unsigned char*)"ST", 0, 2 );
     // This time the ES should have been written.
     CPPUNIT_ASSERT( strcmp( buffer, "TES" ) == 0 );
 
@@ -238,7 +246,7 @@
 
     const char* buffer = myStream.getBuffer();
 
-    bufStream.write( (unsigned char*)"TEST", 4 );
+    bufStream.write( (unsigned char*)"TEST", 0, 4 );
 
     // Should not be written yet.
     CPPUNIT_ASSERT( strcmp( buffer, "" ) == 0 );
@@ -246,8 +254,8 @@
     bufStream.flush();
     CPPUNIT_ASSERT( strcmp( buffer, "TEST" ) == 0 );
 
-    bufStream.write( (unsigned char*)"TEST", 4 );
-    bufStream.write( (unsigned char*)"12345678910", 11);
+    bufStream.write( (unsigned char*)"TEST", 0, 4 );
+    bufStream.write( (unsigned char*)"12345678910", 0, 11);
 
     CPPUNIT_ASSERT( strcmp( buffer, "TESTTEST123456" ) == 0 );
 

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedOutputStreamTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedOutputStreamTest.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedOutputStreamTest.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/BufferedOutputStreamTest.h Sun Nov  4 11:59:09 2007
@@ -92,13 +92,25 @@
                 buffer[pos++] = c;
             }
 
-            virtual void write( const unsigned char* buffer, std::size_t len ) throw (IOException){
+            virtual void write( const std::vector<unsigned char>& buffer )
+                throw ( IOException ) {
+
+                if( buffer.empty() ){
+                    return;
+                }
+
+                this->write( &buffer[0], 0, buffer.size() );
+            }
+
+            virtual void write( const unsigned char* buffer,
+                                std::size_t offset,
+                                std::size_t len ) throw (IOException){
 
                 if( (pos + len) > 100 ){
                     throw IOException();
                 }
 
-                memcpy( this->buffer + pos, buffer, len );
+                memcpy( this->buffer + pos, buffer+offset, len );
 
                 pos += len;
             }

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/ByteArrayInputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/ByteArrayInputStreamTest.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/ByteArrayInputStreamTest.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/ByteArrayInputStreamTest.cpp Sun Nov  4 11:59:09 2007
@@ -149,7 +149,7 @@
 
     unsigned char buf1[20];
     is.skip(50);
-    is.read( buf1, 20 );
+    is.read( buf1, 0, 20 );
     CPPUNIT_ASSERT_MESSAGE(
         "Failed to read correct data",
         string( (const char*)buf1, 20 ) == string( (const char*)&testBuffer[50], 20) );
@@ -167,7 +167,7 @@
 
     unsigned char buf1[10];
     is.skip(100);
-    is.read( buf1, 10 );
+    is.read( buf1, 0, 10 );
 
     CPPUNIT_ASSERT_MESSAGE(
         "Failed to skip to correct position",
@@ -206,7 +206,7 @@
 
     buffer[5] = '\0';
 
-    CPPUNIT_ASSERT( stream_a.read(buffer, 5) == 5 );
+    CPPUNIT_ASSERT( stream_a.read(buffer, 0, 5) == 5 );
     CPPUNIT_ASSERT( std::string((const char*)buffer) == std::string("teste") );
     CPPUNIT_ASSERT( stream_a.available() == 0 );
 
@@ -214,8 +214,8 @@
 
     memset(buffer, 0, 6);
 
-    CPPUNIT_ASSERT( stream_a.read(buffer, 3) == 3 );
-    CPPUNIT_ASSERT( stream_a.read(&buffer[3], 2) == 2 );
+    CPPUNIT_ASSERT( stream_a.read(buffer, 0, 3) == 3 );
+    CPPUNIT_ASSERT( stream_a.read(&buffer[3], 0, 2) == 2 );
     CPPUNIT_ASSERT( std::string((const char*)buffer) == std::string("teste") );
 
     stream_a.close();

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/ByteArrayOutputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/ByteArrayOutputStreamTest.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/ByteArrayOutputStreamTest.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/ByteArrayOutputStreamTest.cpp Sun Nov  4 11:59:09 2007
@@ -47,7 +47,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 void ByteArrayOutputStreamTest::testReset() {
     ByteArrayOutputStream baos;
-    baos.write( (unsigned char*)&testString[0], 100 );
+    baos.write( (unsigned char*)&testString[0], 0, 100 );
     baos.reset();
     CPPUNIT_ASSERT_MESSAGE("reset failed", 0 == baos.size() );
 }
@@ -55,7 +55,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 void ByteArrayOutputStreamTest::testSize() {
     ByteArrayOutputStream baos;
-    baos.write( (unsigned char*)&testString[0], 100 );
+    baos.write( (unsigned char*)&testString[0], 0, 100 );
     CPPUNIT_ASSERT_MESSAGE("size test failed", 100 == baos.size());
     baos.reset();
     CPPUNIT_ASSERT_MESSAGE("size test failed", 0 == baos.size());
@@ -65,7 +65,7 @@
 void ByteArrayOutputStreamTest::testToByteArray() {
     const unsigned char* bytes = NULL;
     ByteArrayOutputStream baos;
-    baos.write( (unsigned char*)&testString[0], testString.length() );
+    baos.write( (unsigned char*)&testString[0], 0, testString.length() );
     bytes = baos.toByteArray();
     for( std::size_t i = 0; i < testString.length(); i++) {
         CPPUNIT_ASSERT_MESSAGE("Error in byte array", bytes[i] == testString.at(i) );
@@ -76,7 +76,7 @@
 void ByteArrayOutputStreamTest::testToString() {
 
     ByteArrayOutputStream baos;
-    baos.write( (unsigned char*)&testString[0], testString.length() );
+    baos.write( (unsigned char*)&testString[0], 0, testString.length() );
     CPPUNIT_ASSERT_MESSAGE( "Returned incorrect String",
                             baos.toString() == testString );
 }
@@ -94,7 +94,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 void ByteArrayOutputStreamTest::testWrite2() {
     ByteArrayOutputStream baos;
-    baos.write( (unsigned char*)&testString[0], 100 );
+    baos.write( (unsigned char*)&testString[0], 0, 100 );
     const unsigned char* bytes = baos.toByteArray();
     CPPUNIT_ASSERT_MESSAGE("Wrote incorrect bytes",
             string((const char*)bytes, baos.size() ) == testString.substr(0, 100) );
@@ -104,7 +104,7 @@
 void ByteArrayOutputStreamTest::testWriteToDecaf_io_OutputStream() {
     ByteArrayOutputStream baos1;
     ByteArrayOutputStream baos2;
-    baos1.write( (unsigned char*)&testString[0], 100 );
+    baos1.write( (unsigned char*)&testString[0], 0, 100 );
     baos1.writeTo( &baos2 );
     CPPUNIT_ASSERT_MESSAGE( "Returned incorrect String",
                             baos2.toString() == testString.substr(0, 100) );
@@ -125,7 +125,7 @@
 
     CPPUNIT_ASSERT( stream_a.size() == 0 );
 
-    stream_a.write((const unsigned char*)("abc"), 3);
+    stream_a.write((const unsigned char*)("abc"), 0, 3);
 
     CPPUNIT_ASSERT( stream_a.size() == 3 );
 
@@ -133,7 +133,7 @@
 
     CPPUNIT_ASSERT( stream_a.size() == 0 );
 
-    stream_a.write((const unsigned char*)("abc"), 3);
+    stream_a.write((const unsigned char*)("abc"), 0, 3);
 
     unsigned char buffer[4];
 

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/DataOutputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/DataOutputStreamTest.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/DataOutputStreamTest.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/DataOutputStreamTest.cpp Sun Nov  4 11:59:09 2007
@@ -272,7 +272,7 @@
     writer.writeLong( longVal );
     writer.writeFloat( floatVal );
     writer.writeDouble( doubleVal );
-    writer.write( arrayVal, 3 );
+    writer.write( arrayVal, 0, 3 );
 
     const unsigned char* buffer = myStream.toByteArray();
     int ix = 0;

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/FilterInputStreamTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/FilterInputStreamTest.cpp?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/FilterInputStreamTest.cpp (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/FilterInputStreamTest.cpp Sun Nov  4 11:59:09 2007
@@ -77,7 +77,7 @@
     FilterInputStream is( &myStream );
 
     unsigned char buf[30];
-    is.read( buf, 30 );
+    is.read( buf, 0, 30 );
     CPPUNIT_ASSERT_MESSAGE( "Failed to read correct data",
         string( (const char*)buf, 30 ) == testStr.substr(0, 30) );
 }
@@ -94,7 +94,7 @@
 
     unsigned char buf[100];
     is.skip(3000);
-    is.read( buf, 100 );
+    is.read( buf, 0, 100 );
     CPPUNIT_ASSERT_MESSAGE( "Failed to read correct data",
         string( (const char*)buf, 100 ) == testStr.substr( 3000, 100 ) );
 }
@@ -111,7 +111,7 @@
 
     unsigned char buf[100];
     is.skip( 1000 );
-    is.read( buf, 100 );
+    is.read( buf, 0, 100 );
     CPPUNIT_ASSERT_MESSAGE( "Failed to skip to correct position",
             string( (const char*)buf, 100 ) == testStr.substr( 1000, 100 ) );
 }

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/FilterInputStreamTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/FilterInputStreamTest.h?rev=591825&r1=591824&r2=591825&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/FilterInputStreamTest.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/io/FilterInputStreamTest.h Sun Nov  4 11:59:09 2007
@@ -105,7 +105,11 @@
                 return data.c_str()[pos++];
             }
 
-            virtual int read( unsigned char* buffer, std::size_t bufferSize ) throw (IOException){
+            virtual int read( unsigned char* buffer,
+                              std::size_t offset,
+                              std::size_t bufferSize )
+                throw (IOException){
+
                 std::size_t numToRead = std::min( bufferSize, available() );
 
                 if( this->isThrowOnRead() ) {
@@ -121,7 +125,7 @@
 
                 const char* str = data.c_str();
                 for( std::size_t ix=0; ix<numToRead; ++ix ){
-                    buffer[ix] = str[pos+ix];
+                    buffer[ix+offset] = str[pos+ix];
                 }
 
                 pos += numToRead;
@@ -135,6 +139,18 @@
             virtual std::size_t skip( std::size_t num ) throw ( io::IOException, lang::exceptions::UnsupportedOperationException ) {
                 return ( pos += std::min( num, available() ) );
             }
+
+            virtual void mark( int readLimit DECAF_UNUSED ) {
+
+            }
+
+            virtual void reset() throw ( IOException ) {
+                throw IOException(
+                    __FILE__, __LINE__,
+                    "BufferedInputStream::reset - mark no yet supported." );
+            }
+
+            virtual bool markSupported() const{ return false; }
 
             virtual void lock() throw(lang::Exception){
             }



Mime
View raw message