You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2007/06/27 13:41:09 UTC
svn commit: r551127 - in /activemq/activemq-cpp/trunk/src/main/activemq/io:
DataInputStream.cpp DataInputStream.h
Author: tabish
Date: Wed Jun 27 04:41:09 2007
New Revision: 551127
URL: http://svn.apache.org/viewvc?view=rev&rev=551127
Log:
Cleaning up the header comments, and adding some missing RETHROW blocks to the code for EOFExceptions etc.
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/io/DataInputStream.cpp
activemq/activemq-cpp/trunk/src/main/activemq/io/DataInputStream.h
Modified: activemq/activemq-cpp/trunk/src/main/activemq/io/DataInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/io/DataInputStream.cpp?view=diff&rev=551127&r1=551126&r2=551127
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/io/DataInputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/io/DataInputStream.cpp Wed Jun 27 04:41:09 2007
@@ -72,6 +72,7 @@
return read;
}
+ AMQ_CATCH_RETHROW( IndexOutOfBoundsException )
AMQ_CATCH_RETHROW( NullPointerException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
@@ -86,6 +87,7 @@
this->readFully( ( unsigned char* )&value, 0, sizeof( char ) );
return (char)( value != 0 );
}
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -99,6 +101,7 @@
this->readFully( ( unsigned char* )&value, 0, sizeof( char ) );
return (char)( value );
}
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -112,6 +115,7 @@
this->readFully( ( unsigned char* )&value, 0, sizeof( unsigned char ) );
return (char)( value );
}
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -124,6 +128,7 @@
this->readFully( ( unsigned char* )&value, 0, sizeof( char ) );
return (char)( value );
}
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -141,6 +146,7 @@
return value;
}
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -159,6 +165,7 @@
return value;
}
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -178,6 +185,7 @@
return value;
}
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -191,6 +199,7 @@
memcpy( &value, &lvalue, sizeof( unsigned long long ) );
return value;
}
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -204,6 +213,7 @@
memcpy( &value, &lvalue, sizeof( unsigned int ) );
return value;
}
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -229,6 +239,7 @@
return value;
}
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -255,6 +266,7 @@
return retVal;
}
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -270,6 +282,7 @@
readFully( (unsigned char*)buffer.c_str(), 0, len );
return buffer;
}
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -280,6 +293,7 @@
try {
this->readFully( &buffer[0], 0, buffer.size() );
}
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -312,7 +326,9 @@
n += count;
}
}
+ AMQ_CATCH_RETHROW( IndexOutOfBoundsException )
AMQ_CATCH_RETHROW( NullPointerException )
+ AMQ_CATCH_RETHROW( EOFException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
@@ -332,6 +348,7 @@
return total;
}
+ AMQ_CATCH_RETHROW( UnsupportedOperationException )
AMQ_CATCH_RETHROW( IOException )
AMQ_CATCHALL_THROW( IOException )
}
Modified: activemq/activemq-cpp/trunk/src/main/activemq/io/DataInputStream.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/io/DataInputStream.h?view=diff&rev=551127&r1=551126&r2=551127
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/io/DataInputStream.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/io/DataInputStream.h Wed Jun 27 04:41:09 2007
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
#ifndef _ACTIVEMQ_IO_DATAINPUTSTREAM_H_
#define _ACTIVEMQ_IO_DATAINPUTSTREAM_H_
@@ -28,55 +28,55 @@
namespace io{
/**
- * A data input stream lets an application read primitive Java data
- * types from an underlying input stream in a machine-independent way.
- * An application uses a data output stream to write data that can
+ * A data input stream lets an application read primitive Java data
+ * types from an underlying input stream in a machine-independent way.
+ * An application uses a data output stream to write data that can
* later be read by a data input stream.
- *
- * Due to the lack of garbage collection in C++ a design decision was
+ *
+ * Due to the lack of garbage collection in C++ a design decision was
* made to add a boolean parameter to the constructor indicating if the
* wrapped <code>InputStream</code> is owned by this object. That way
* creation of the underlying stream can occur in a Java like way. Ex:
- *
+ *
* DataInputStream os = new DataInputStream( new InputStream(), true )
*/
class DataInputStream : public FilterInputStream
{
public:
-
+
/**
- * Creates a DataInputStream that uses the specified underlying
+ * Creates a DataInputStream that uses the specified underlying
* InputStream.
* @param inputStream the InputStream instance to wrap.
* @param own, indicates if this class owns the wrapped string
* defaults to false.
*/
DataInputStream( InputStream* inputStream, bool own = false );
-
+
virtual ~DataInputStream();
/**
- * Reads some number of bytes from the contained input stream and
+ * Reads some number of bytes from the contained input stream and
* stores them into the buffer array b. The number of bytes actually
- * read is returned as an integer. This method blocks until input
- * data is available, end of file is detected, or an exception is
+ * read is returned as an integer. This method blocks until input
+ * data is available, end of file is detected, or an exception is
* thrown.
* <p>
- * If the length of buffer is zero, then no bytes are read and 0 is
- * returned; otherwise, there is an attempt to read at least one
- * byte. If no byte is available because the stream is at end of
- * file, the value -1 is returned; otherwise, at least one byte is
+ * If the length of buffer is zero, then no bytes are read and 0 is
+ * returned; otherwise, there is an attempt to read at least one
+ * byte. If no byte is available because the stream is at end of
+ * file, the value -1 is returned; otherwise, at least one byte is
* read and stored into buffer.
* <p>
- * The first byte read is stored into element buffer[0], the next one
- * into buffer[1], and so on. The number of bytes read is, at most,
- * equal to the length of buffer. Let k be the number of bytes actually
+ * The first byte read is stored into element buffer[0], the next one
+ * into buffer[1], and so on. The number of bytes read is, at most,
+ * equal to the length of buffer. Let k be the number of bytes actually
* read; these bytes will be stored in elements b[0] through b[k-1],
- * leaving elements buffer[k] through buffer[buffer.length-1]
+ * leaving elements buffer[k] through buffer[buffer.length-1]
* unaffected.
* <p>
- * If the first byte cannot be read for any reason other than end
- * of file, then an IOException is thrown. In particular, an
+ * If the first byte cannot be read for any reason other than end
+ * of file, then an IOException is thrown. In particular, an
* IOException is thrown if the input stream has been closed.
* <p>
* The read( buffer ) method has the same effect as:
@@ -84,15 +84,15 @@
* @param buffer - byte array to insert read data into
* @returns the total number of bytes read, or -1 if there is no
* more data because the stream is EOF.
- * @throws IOException
- */
- virtual std::size_t read( std::vector< unsigned char >& buffer )
+ * @throws IOException if an I/O error occurs.
+ */
+ virtual std::size_t read( std::vector< unsigned char >& buffer )
throw ( io::IOException );
/**
- * Reads up to len bytes of data from the contained input stream
- * into an array of bytes. An attempt is made to read as many as
- * len bytes, but a smaller number may be read, possibly zero. The
+ * Reads up to len bytes of data from the contained input stream
+ * into an array of bytes. An attempt is made to read as many as
+ * len bytes, but a smaller number may be read, possibly zero. The
* number of bytes actually read is returned as an integer.
* <p>
* This method blocks until input data is available, end of file is
@@ -100,123 +100,124 @@
* <p>
* If buffer is null, a NullPointerException is thrown.
* <p>
- * If off is negative, or len is negative then an
+ * If off is negative, or len is negative then an
* IndexOutOfBoundsException is thrown, if off + len is greater that
* the allocated length of the array, an IOException will result
* depending on the platform and compiler settings.
* <p>
- * If len is zero, then no bytes are read and 0 is returned;
- * otherwise, there is an attempt to read at least one byte. If no
- * byte is available because the stream is at end of file, the
- * value -1 is returned; otherwise, at least one byte is read and
+ * If len is zero, then no bytes are read and 0 is returned;
+ * otherwise, there is an attempt to read at least one byte. If no
+ * byte is available because the stream is at end of file, the
+ * value -1 is returned; otherwise, at least one byte is read and
* stored into buffer.
* <p>
- * The first byte read is stored into element b[off], the next one
- * into buffer[off+1], and so on. The number of bytes read is, at most,
- * equal to len. Let k be the number of bytes actually read; these
- * bytes will be stored in elements buffer[off] through buffer[off+k-1],
+ * The first byte read is stored into element b[off], the next one
+ * into buffer[off+1], and so on. The number of bytes read is, at most,
+ * equal to len. Let k be the number of bytes actually read; these
+ * bytes will be stored in elements buffer[off] through buffer[off+k-1],
* leaving elements buffer[off+k] through buffer[off+len-1] unaffected.
* <p>
- * In every case, elements buffer[0] through buffer[off] and elements
+ * In every case, elements buffer[0] through buffer[off] and elements
* buffer[off+len] through buffer[buffer.length-1] are unaffected.
* <p>
- * If the first byte cannot be read for any reason other than end of
- * file, then an IOException is thrown. In particular, an IOException
+ * If the first byte cannot be read for any reason other than end of
+ * file, then an IOException is thrown. In particular, an IOException
* is thrown if the input stream has been closed.
* @param buffer - byte array to insert read data into
* @param offset - location in buffer to start writing
- * @param length - number of bytes to read
+ * @param length - number of bytes to read
* @returns the total number of bytes read, or -1 if there is no
* more data because the stream is EOF.
- * @throws IOException
+ * @throws IOException if an I/O error occurs.
*/
- virtual std::size_t read( unsigned char* buffer,
- std::size_t offset,
- std::size_t length )
- throw ( io::IOException,
- exceptions::IndexOutOfBoundsException,
+ virtual std::size_t read( unsigned char* buffer,
+ std::size_t offset,
+ std::size_t length )
+ throw ( io::IOException,
+ exceptions::IndexOutOfBoundsException,
exceptions::NullPointerException );
-
+
/**
- * Reads one input byte and returns true if that byte is nonzero,
+ * Reads one input byte and returns true if that byte is nonzero,
* false if that byte is zero.
* @returns the boolean value read.
- * @throws IOException
+ * @throws IOException if an I/O error occurs.
* @throws EOFException
*/
- virtual bool readBoolean()
+ virtual bool readBoolean()
throw( io::IOException, io::EOFException );
-
+
/**
- * Reads and returns one input byte. The byte is treated as a
+ * Reads and returns one input byte. The byte is treated as a
* signed value in the range -128 through 127, inclusive.
* @returns the 8-bit value read.
- * @throws IOException
+ * @throws IOException if an I/O error occurs.
* @throws EOFException
*/
- virtual char readByte()
- throw ( io::IOException, io::EOFException );
+ virtual char readByte()
+ throw ( io::IOException, io::EOFException );
/**
- * Reads one input byte, zero-extends it to type int, and returns
- * the result, which is therefore in the range 0 through 255.
+ * Reads one input byte, zero-extends it to type int, and returns
+ * the result, which is therefore in the range 0 through 255.
* @returns the 8 bit unsigned value read
- * @throws IOException
+ * @throws IOException if an I/O error occurs.
* @throws EOFException
*/
- virtual unsigned char readUnsignedByte()
+ virtual unsigned char readUnsignedByte()
throw ( io::IOException, io::EOFException );
-
+
/**
- * Reads an input char and returns the char value. A ascii char
- * is made up of one bytes. This returns the same result as
+ * Reads an input char and returns the char value. A ascii char
+ * is made up of one bytes. This returns the same result as
* <code>readByte</code>
* @returns the 8 bit char read
- * @throws IOException
+ * @throws IOException if an I/O error occurs.
* @throws EOFException
*/
virtual char readChar() throw ( io::IOException, io::EOFException );
-
+
/**
* Reads eight input bytes and returns a double value. It does this
- * by first constructing a long long value in exactly the manner of
+ * by first constructing a long long value in exactly the manner of
* the readlong method, then converting this long value to a double
* in exactly the manner of the method Double.longBitsToDouble.
* @returns the double value read
- * @throws IOException
+ * @throws IOException if an I/O error occurs.
* @throws EOFException
*/
- virtual double readDouble()
+ virtual double readDouble()
throw ( io::IOException, io::EOFException );
-
+
/**
- * Reads four input bytes and returns a float value. It does this
- * by first constructing an int value in exactly the manner of the
- * readInt method, then converting this int value to a float in
+ * Reads four input bytes and returns a float value. It does this
+ * by first constructing an int value in exactly the manner of the
+ * readInt method, then converting this int value to a float in
* exactly the manner of the method Float.intBitsToFloat.
* @returns the float value read
- * @throws IOException
+ * @throws IOException if an I/O error occurs.
* @throws EOFException
*/
virtual float readFloat() throw ( io::IOException, io::EOFException );
/**
- * Reads four input bytes and returns an int value. Let a be the
- * first byte read, b be the second byte, c be the third byte, and
+ * Reads four input bytes and returns an int value. Let a be the
+ * first byte read, b be the second byte, c be the third byte, and
* d be the fourth byte. The value returned is: <p>
* (((a & 0xff) << 24) | ((b & 0xff) << 16) |
* ((c & 0xff) << 8) | (d & 0xff))
* @returns the int value read
- * @throws IOException
- * @throws EOFException
+ * @throws IOException if an I/O error occurs.
+ * @throws EOFException if this stream reaches the end before reading all
+ * the bytes.
*/
virtual int readInt() throw ( io::IOException, io::EOFException );
-
+
/**
- * Reads eight input bytes and returns a long value. Let a be the
- * first byte read, b be the second byte, c be the third byte, d
- * be the fourth byte, e be the fifth byte, f be the sixth byte,
- * g be the seventh byte, and h be the eighth byte. The value
+ * Reads eight input bytes and returns a long value. Let a be the
+ * first byte read, b be the second byte, c be the third byte, d
+ * be the fourth byte, e be the fifth byte, f be the sixth byte,
+ * g be the seventh byte, and h be the eighth byte. The value
* returned is:
* (((long)(a & 0xff) << 56) |
* ((long)(b & 0xff) << 48) |
@@ -227,124 +228,132 @@
* ((long)(g & 0xff) << 8) |
* ((long)(h & 0xff)))
* @returns the 64 bit long long read
- * @throws IOException
- * @throws EOFException
+ * @throws IOException if an I/O error occurs.
+ * @throws EOFException if this stream reaches the end before reading all
+ * the bytes.
*/
- virtual long long readLong()
+ virtual long long readLong()
throw ( io::IOException, io::EOFException );
/**
- * Reads two input bytes and returns a short value. Let a be the
+ * Reads two input bytes and returns a short value. Let a be the
* first byte read and b be the second byte. The value returned is:
* (short)((a << 8) | (b & 0xff))
* @returns the 16 bit short value read
- * @throws IOException
+ * @throws IOException if an I/O error occurs.
* @throws EOFException
*/
virtual short readShort() throw ( io::IOException, io::EOFException );
/**
- * Reads two input bytes and returns an int value in the range 0
- * through 65535. Let a be the first byte read and b be the
+ * Reads two input bytes and returns an int value in the range 0
+ * through 65535. Let a be the first byte read and b be the
* second byte. The value returned is:
* (((a & 0xff) << 8) | (b & 0xff))
* @returns the 16 bit unsigned short read
- * @throws IOException
- * @throws EOFException
+ * @throws IOException if an I/O error occurs.
+ * @throws EOFException if this stream reaches the end before reading all
+ * the bytes.
*/
- virtual unsigned short readUnsignedShort()
+ virtual unsigned short readUnsignedShort()
throw ( io::IOException, io::EOFException );
-
+
/**
* Reads an null terminated ASCII string to the stream and returns the
- * string to the caller.
+ * string to the caller.
* @returns string object containing the string read.
- * @throws IOException
- * @throws EOFException
+ * @throws IOException if an I/O error occurs.
+ * @throws EOFException if this stream reaches the end before reading all
+ * the bytes.
*/
- virtual std::string readString()
+ virtual std::string readString()
throw ( io::IOException, io::EOFException );
-
+
/**
* Reads a UTF8 encoded string in ASCII format and returns it, this is
* only useful if you know for sure that the string that is to be read
* was a string that contained all ascii values, and not uncide chars.
* @returns string read from stream.
- * @throws IOException
- * @throws EOFException
+ * @throws IOException if an I/O error occurs.
+ * @throws EOFException if this stream reaches the end before reading all
+ * the bytes.
*/
- virtual std::string readUTF()
+ virtual std::string readUTF()
throw ( io::IOException, io::EOFException );
/**
- * Reads some bytes from an input stream and stores them into the
- * buffer array buffer. The number of bytes read is equal to the length
+ * Reads some bytes from an input stream and stores them into the
+ * buffer array buffer. The number of bytes read is equal to the length
* of buffer.<p>
* This method blocks until one of the following conditions occurs:
- * * buffer.size() bytes of input data are available, in which case
+ * * buffer.size() bytes of input data are available, in which case
* a normal return is made.
- * * End of file is detected, in which case an EOFException is
+ * * End of file is detected, in which case an EOFException is
* thrown.
- * * An I/O error occurs, in which case an IOException other than
- * EOFException is thrown.
+ * * An I/O error occurs, in which case an IOException other than
+ * EOFException is thrown.
* <p>
- * If buffer.size() is zero, then no bytes are read. Otherwise, the
- * first byte read is stored into element b[0], the next one into
- * buffer[1], and so on. If an exception is thrown from this method,
- * then it may be that some but not all bytes of buffer have been
- * updated with data from the input stream.
+ * If buffer.size() is zero, then no bytes are read. Otherwise, the
+ * first byte read is stored into element b[0], the next one into
+ * buffer[1], and so on. If an exception is thrown from this method,
+ * then it may be that some but not all bytes of buffer have been
+ * updated with data from the input stream.
* @param buffer - vector of char that is read to its size()
- * @throws IOException
- * @throws EOFException
+ * @throws IOException if an I/O error occurs.
+ * @throws EOFException if this stream reaches the end before reading all
+ * the bytes.
*/
- virtual void readFully( std::vector< unsigned char >& buffer )
+ virtual void readFully( std::vector< unsigned char >& buffer )
throw ( io::IOException, io::EOFException );
-
+
/**
* Reads length bytes from an input stream.
* <p>
* This method blocks until one of the following conditions occurs:
- * * length bytes of input data are available, in which case a
+ * * length bytes of input data are available, in which case a
* normal return is made.
- * * End of file is detected, in which case an EOFException is
+ * * End of file is detected, in which case an EOFException is
* thrown.
- * * An I/O error occurs, in which case an IOException other
- * than EOFException is thrown.
+ * * An I/O error occurs, in which case an IOException other
+ * than EOFException is thrown.
* <p>
- * If buffer is null, a NullPointerException is thrown. If offset is
- * negative, or len is negative, or offset+length is greater than the
- * length of the array buffer, then an IndexOutOfBoundsException is
- * thrown. If len is zero, then no bytes are read. Otherwise, the
- * first byte read is stored into element buffer[off], the next one into
- * buffer[offset+1], and so on. The number of bytes read is, at most,
- * equal to len.
+ * If buffer is null, a NullPointerException is thrown. If offset is
+ * negative, or len is negative, or offset+length is greater than the
+ * length of the array buffer, then an IndexOutOfBoundsException is
+ * thrown. If len is zero, then no bytes are read. Otherwise, the
+ * first byte read is stored into element buffer[off], the next one into
+ * buffer[offset+1], and so on. The number of bytes read is, at most,
+ * equal to len.
* @param buffer - byte array to insert read data into
* @param offset - location in buffer to start writing
- * @param length - number of bytes to read
- * @throws IOException
- * @throws EOFException
- */
- virtual void readFully( unsigned char* buffer,
- std::size_t offset,
- std::size_t length )
- throw ( io::IOException,
- io::EOFException,
- exceptions::IndexOutOfBoundsException,
+ * @param length - number of bytes to read
+ * @throws IOException if an I/O error occurs.
+ * @throws EOFException if this stream reaches the end before reading all
+ * the bytes.
+ */
+ virtual void readFully( unsigned char* buffer,
+ std::size_t offset,
+ std::size_t length )
+ throw ( io::IOException,
+ io::EOFException,
+ exceptions::IndexOutOfBoundsException,
exceptions::NullPointerException );
/**
- * Makes an attempt to skip over n bytes of data from the input
- * stream, discarding the skipped bytes. However, it may skip over
+ * Makes an attempt to skip over n bytes of data from the input
+ * stream, discarding the skipped bytes. However, it may skip over
* some smaller number of bytes, possibly zero. This may result from
- * any of a number of conditions; reaching end of file before n
- * bytes have been skipped is only one possibility. This method
+ * any of a number of conditions; reaching end of file before n
+ * bytes have been skipped is only one possibility. This method
* never throws an EOFException. The actual number of bytes skipped
* is returned.
* @param num - number of bytes to skip
* @return the total number of bytes skipped
+ * @throws IOException if an I/O error occurs.
+ * @throws UnsupportedOperationException if skipping is not supported
*/
- virtual std::size_t skip( std::size_t num )
- throw( io::IOException,
+ virtual std::size_t skip( std::size_t num )
+ throw( io::IOException,
exceptions::UnsupportedOperationException );
};