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.
+ * <p>
+ * 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.
- * <p>
- * 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 <string>
#include <decaf/io/IOException.h>
#include <decaf/io/InputStream.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
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 <string>
#include <decaf/io/IOException.h>
#include <decaf/io/OutputStream.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
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.