Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 21298 invoked from network); 4 Nov 2007 03:15:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Nov 2007 03:15:19 -0000 Received: (qmail 49724 invoked by uid 500); 4 Nov 2007 03:15:07 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 49697 invoked by uid 500); 4 Nov 2007 03:15:07 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 49687 invoked by uid 99); 4 Nov 2007 03:15:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Nov 2007 20:15:07 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Nov 2007 03:15:19 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D5F861A9832; Sat, 3 Nov 2007 20:14:58 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r591731 - in /activemq/activemq-cpp/decaf/trunk/src/main/decaf/io: BlockingByteArrayInputStream.cpp BlockingByteArrayInputStream.h Reader.h Writer.h Date: Sun, 04 Nov 2007 03:14:57 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071104031458.D5F861A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Sat Nov 3 20:14:57 2007 New Revision: 591731 URL: http://svn.apache.org/viewvc?rev=591731&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/Reader.h activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/Writer.h 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=591731&r1=591730&r2=591731&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 Sat Nov 3 20:14:57 2007 @@ -22,6 +22,7 @@ using namespace decaf; using namespace decaf::io; using namespace decaf::lang; +using namespace decaf::lang::exceptions; //////////////////////////////////////////////////////////////////////////////// BlockingByteArrayInputStream::BlockingByteArrayInputStream(){ @@ -105,6 +106,16 @@ std::size_t bufferSize ) throw ( IOException, lang::exceptions::NullPointerException ){ + if( bufferSize == 0 ) { + return 0; + } + + if( buffer == NULL ) { + throw NullPointerException( + __FILE__, __LINE__, + "BlockingByteArrayInputStream::read - Passed buffer is Null" ); + } + synchronized( this ){ std::size_t ix = 0; @@ -124,7 +135,8 @@ if( closing ){ throw IOException( - __FILE__, __LINE__, "close occurred during read" ); + __FILE__, __LINE__, + "BlockingByteArrayInputStream::read - close occurred during read" ); } return ix; 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=591731&r1=591730&r2=591731&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 Sat Nov 3 20:14:57 2007 @@ -30,8 +30,7 @@ * block until the requested data becomes available in the internal * buffer via a call to setByteArray. */ - class DECAF_API BlockingByteArrayInputStream : public InputStream - { + class DECAF_API BlockingByteArrayInputStream : public InputStream { private: /** @@ -83,7 +82,66 @@ * @param bufferSize The size of the new buffer. */ virtual void setByteArray( const unsigned char* buffer, - std::size_t bufferSize ); + std::size_t bufferSize ); + + /** + * Indicates the number of bytes available to be read without + * blocking. + * @return the data available in the internal buffer. + * @throws IOException if an error occurs. + */ + virtual std::size_t available() const throw ( IOException ){ + return std::distance( pos, buffer.end() ); + } + + /** + * Reads a single byte from the buffer. This operation will + * block until data has been added to the buffer via a call + * to setByteArray. + * @return the next byte. + * @throws IOException if an error occurs. + */ + virtual unsigned char read() throw ( IOException ); + + /** + * Reads an array of bytes from the buffer. If the desired amount + * of data is not currently available, this operation + * will block until the appropriate amount of data is available + * in the buffer via a call to setByteArray. + * @param buffer (out) the target buffer + * @param bufferSize the size of the output buffer. + * @return the number of bytes read. or -1 if EOF + * @throws IOException f an error occurs. + */ + virtual int read( unsigned char* buffer, std::size_t bufferSize ) + throw ( IOException, lang::exceptions::NullPointerException ); + + /** + * Closes the target input stream. + * @throws IOException if an error occurs. + */ + virtual void close() 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 + * number of conditions; reaching end of file before n bytes have been + * skipped is only one possibility. The actual number of bytes skipped + * is returned. If n is negative, no bytes are skipped. + *

+ * The skip method of InputStream creates a byte array and then + * repeatedly reads into it until n bytes have been read or the end + * of the stream has been reached. Subclasses are encouraged to + * provide a more efficient implementation of this method. + * @param num - the number of bytes to skip + * @returns total butes skipped + * @throws IOException if an error occurs + */ + virtual std::size_t skip( std::size_t num ) + throw ( io::IOException, lang::exceptions::UnsupportedOperationException ); + + public: /** * Waits on a signal from this object, which is generated @@ -145,64 +203,7 @@ mutex.notifyAll(); } - /** - * Indicates the number of bytes available to be read without - * blocking. - * @return the data available in the internal buffer. - * @throws IOException if an error occurs. - */ - virtual std::size_t available() const throw ( IOException ){ - return std::distance( pos, buffer.end() ); - } - - /** - * Reads a single byte from the buffer. This operation will - * block until data has been added to the buffer via a call - * to setByteArray. - * @return the next byte. - * @throws IOException if an error occurs. - */ - virtual unsigned char read() throw ( IOException ); - - /** - * Reads an array of bytes from the buffer. If the desired amount - * of data is not currently available, this operation - * will block until the appropriate amount of data is available - * in the buffer via a call to setByteArray. - * @param buffer (out) the target buffer - * @param bufferSize the size of the output buffer. - * @return the number of bytes read. or -1 if EOF - * @throws IOException f an error occurs. - */ - virtual int read( unsigned char* buffer, std::size_t bufferSize ) - throw ( IOException, lang::exceptions::NullPointerException ); - - /** - * Closes the target input stream. - * @throws IOException if an error occurs. - */ - virtual void close() 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 - * number of conditions; reaching end of file before n bytes have been - * skipped is only one possibility. The actual number of bytes skipped - * is returned. If n is negative, no bytes are skipped. - *

- * The skip method of InputStream creates a byte array and then - * repeatedly reads into it until n bytes have been read or the end - * of the stream has been reached. Subclasses are encouraged to - * provide a more efficient implementation of this method. - * @param num - the number of bytes to skip - * @returns total butes skipped - * @throws IOException if an error occurs - */ - virtual std::size_t skip( std::size_t num ) - throw ( io::IOException, lang::exceptions::UnsupportedOperationException ); - - }; + }; }} Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/Reader.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/Reader.h?rev=591731&r1=591730&r2=591731&view=diff ============================================================================== --- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/Reader.h (original) +++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/Reader.h Sat Nov 3 20:14:57 2007 @@ -20,6 +20,7 @@ #include #include #include +#include namespace decaf{ namespace io{ @@ -28,11 +29,10 @@ * Reader interface that wraps around an input stream and provides * an interface for extracting the data from the input stream. */ - class DECAF_API Reader - { + class DECAF_API Reader { public: - virtual ~Reader(){}; + virtual ~Reader(){} /** * Sets the target input stream. @@ -52,7 +52,7 @@ * @throws IOException thrown if an error occurs. */ virtual std::size_t read( unsigned char* buffer, std::size_t count ) - throw( IOException ) = 0; + throw( IOException, lang::exceptions::NullPointerException ) = 0; /** * Attempts to read a byte from the input stream Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/Writer.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/Writer.h?rev=591731&r1=591730&r2=591731&view=diff ============================================================================== --- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/Writer.h (original) +++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/Writer.h Sat Nov 3 20:14:57 2007 @@ -20,6 +20,7 @@ #include #include #include +#include namespace decaf{ namespace io{ @@ -28,8 +29,7 @@ * Writer interface for an object that wraps around an output * stream */ - class DECAF_API Writer - { + class DECAF_API Writer { public: virtual ~Writer(){}; @@ -53,7 +53,8 @@ * @throws IOException thrown if an error occurs. */ virtual void write( const unsigned char* buffer, - std::size_t count ) throw( IOException ) = 0; + std::size_t count ) + throw( IOException, lang::exceptions::NullPointerException ) = 0; /** * Writes a byte to the output stream.