Repository: activemq-cpp Updated Branches: refs/heads/master f0b1ff965 -> cb372c077
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/Inflater.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/Inflater.h b/activemq-cpp/src/main/decaf/util/zip/Inflater.h index b99627f..31e0262 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Inflater.h +++ b/activemq-cpp/src/main/decaf/util/zip/Inflater.h @@ -58,8 +58,8 @@ namespace zip { private: - Inflater( const Inflater& ); - Inflater& operator=( const Inflater& ); + Inflater(const Inflater&); + Inflater& operator=(const Inflater&); public: @@ -78,7 +78,7 @@ namespace zip { * byte as input. This is required by the ZLIB native library in order to support * certain optimizations. */ - Inflater( bool nowrap ); + Inflater(bool nowrap); virtual ~Inflater(); @@ -99,7 +99,7 @@ namespace zip { * @throws IndexOutOfBoundsException if the offset + length > size of the buffer. * @throws IllegalStateException if in the end state. */ - void setInput( const unsigned char* buffer, int size, int offset, int length ); + void setInput(const unsigned char* buffer, int size, int offset, int length); /** * Sets input data for decompression. This should be called whenever needsInput() returns @@ -115,7 +115,7 @@ namespace zip { * @throws IndexOutOfBoundsException if the offset + length > size of the buffer. * @throws IllegalStateException if in the end state. */ - void setInput( const std::vector<unsigned char>& buffer, int offset, int length ); + void setInput(const std::vector<unsigned char>& buffer, int offset, int length); /** * Sets input data for decompression. This should be called whenever needsInput() returns @@ -126,7 +126,7 @@ namespace zip { * * @throws IllegalStateException if in the end state. */ - void setInput( const std::vector<unsigned char>& buffer ); + void setInput(const std::vector<unsigned char>& buffer); /** * Returns the total number of bytes remaining in the input buffer. This can be used to @@ -157,7 +157,7 @@ namespace zip { * @throws IllegalArgumentException if the given dictionary doesn't match thre required * dictionaries checksum value. */ - void setDictionary( const unsigned char* buffer, int size, int offset, int length ); + void setDictionary(const unsigned char* buffer, int size, int offset, int length); /** * Sets the preset dictionary to the given array of bytes. Should be called when inflate() @@ -177,7 +177,7 @@ namespace zip { * @throws IllegalArgumentException if the given dictionary doesn't match thre required * dictionaries checksum value. */ - void setDictionary( const std::vector<unsigned char>& buffer, int offset, int length ); + void setDictionary(const std::vector<unsigned char>& buffer, int offset, int length); /** * Sets the preset dictionary to the given array of bytes. Should be called when inflate() @@ -192,7 +192,7 @@ namespace zip { * @throws IllegalArgumentException if the given dictionary doesn't match the required * dictionaries checksum value. */ - void setDictionary( const std::vector<unsigned char>& buffer ); + void setDictionary(const std::vector<unsigned char>& buffer); /** * @return true if the input data buffer is empty and setInput() should be called in @@ -236,7 +236,7 @@ namespace zip { * @throws IndexOutOfBoundsException if the offset + length > size of the buffer. * @throws DataFormatException if the compressed data format is invalid. */ - int inflate( unsigned char* buffer, int size, int offset, int length ); + int inflate(unsigned char* buffer, int size, int offset, int length); /** * Uncompresses bytes into specified buffer. Returns actual number of bytes uncompressed. @@ -255,7 +255,7 @@ namespace zip { * @throws IndexOutOfBoundsException if the offset + length > size of the buffer. * @throws DataFormatException if the compressed data format is invalid. */ - int inflate( std::vector<unsigned char>& buffer, int offset, int length ); + int inflate(std::vector<unsigned char>& buffer, int offset, int length); /** * Uncompresses bytes into specified buffer. Returns actual number of bytes uncompressed. @@ -269,7 +269,7 @@ namespace zip { * @throws IllegalStateException if in the end state. * @throws DataFormatException if the compressed data format is invalid. */ - int inflate( std::vector<unsigned char>& buffer ); + int inflate(std::vector<unsigned char>& buffer); /** * @returns the ADLER-32 value of the uncompressed data. http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp b/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp index 9ccd3ac..b158188 100644 --- a/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.cpp @@ -31,55 +31,55 @@ using namespace decaf::util::zip; const int InflaterInputStream::DEFAULT_BUFFER_SIZE = 512; //////////////////////////////////////////////////////////////////////////////// -InflaterInputStream::InflaterInputStream( InputStream* inputStream, bool own ) : - FilterInputStream( inputStream, own ), +InflaterInputStream::InflaterInputStream(InputStream* inputStream, bool own ) : + FilterInputStream(inputStream, own), inflater(new Inflater()), buff(), length(0), ownInflater(true), atEOF(false) { this->buff.resize( DEFAULT_BUFFER_SIZE ); } //////////////////////////////////////////////////////////////////////////////// -InflaterInputStream::InflaterInputStream( InputStream* inputStream, Inflater* inflater, bool own, bool ownInflater ) - : FilterInputStream( inputStream, own ), - inflater(inflater), buff(), length(0), ownInflater(ownInflater), atEOF(false) { +InflaterInputStream::InflaterInputStream(InputStream* inputStream, Inflater* inflater, bool own, bool ownInflater) : + FilterInputStream(inputStream, own), + inflater(inflater), buff(), length(0), ownInflater(ownInflater), atEOF(false) { - if( inflater == NULL ) { + if (inflater == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Inflater passed was NULL." ); + __FILE__, __LINE__, "Inflater passed was NULL."); } this->buff.resize( DEFAULT_BUFFER_SIZE ); } //////////////////////////////////////////////////////////////////////////////// -InflaterInputStream::InflaterInputStream( InputStream* inputStream, Inflater* inflater, - int bufferSize, bool own, bool ownInflater ) - : FilterInputStream( inputStream, own ), +InflaterInputStream::InflaterInputStream(InputStream* inputStream, Inflater* inflater, + int bufferSize, bool own, bool ownInflater) : + FilterInputStream(inputStream, own), inflater(inflater), buff(), length(0), ownInflater(ownInflater), atEOF(false) { - if( inflater == NULL ) { + if (inflater == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Inflater passed was NULL." ); + __FILE__, __LINE__, "Inflater passed was NULL."); } - if( bufferSize <= 0 ) { + if (bufferSize <= 0) { throw IllegalArgumentException( - __FILE__, __LINE__, "Cannot create a zero sized buffer." ); + __FILE__, __LINE__, "Cannot create a zero sized buffer."); } - this->buff.resize( bufferSize ); + this->buff.resize(bufferSize); } //////////////////////////////////////////////////////////////////////////////// InflaterInputStream::~InflaterInputStream() { - try{ + try { this->close(); - if( ownInflater ) { + if (ownInflater) { delete inflater; } } - DECAF_CATCH_NOTHROW( Exception ) + DECAF_CATCH_NOTHROW(Exception) DECAF_CATCHALL_NOTHROW() } @@ -91,135 +91,135 @@ bool InflaterInputStream::markSupported() const { //////////////////////////////////////////////////////////////////////////////// void InflaterInputStream::reset() { throw IOException( - __FILE__, __LINE__, "Not Supported for this class." ); + __FILE__, __LINE__, "Not Supported for this class."); } //////////////////////////////////////////////////////////////////////////////// -void InflaterInputStream::mark( int readLimit DECAF_UNUSED ) { +void InflaterInputStream::mark(int readLimit DECAF_UNUSED) { // No-op } //////////////////////////////////////////////////////////////////////////////// -long long InflaterInputStream::skip( long long num ) { +long long InflaterInputStream::skip(long long num) { - try{ + try { - if( num <= 0 ) { + if (num <= 0) { return 0; } long long count = 0; - long long remaining = (std::size_t)Math::min( num, (long long)buff.size() ); + long long remaining = (std::size_t) Math::min(num, (long long) buff.size()); - std::vector<unsigned char> buffer( (std::size_t)remaining ); + std::vector<unsigned char> buffer((std::size_t) remaining); - while( count < num ) { - int x = read( &buffer[0], (int)buffer.size() , 0, (int)remaining ); - if( x == -1 ) { + while (count < num) { + int x = read(&buffer[0], (int) buffer.size(), 0, (int) remaining); + if (x == -1) { return count; } count += x; - remaining = ( num - count ) < (long long)buffer.size() ? num - count : buffer.size(); + remaining = (num - count) < (long long) buffer.size() ? num - count : buffer.size(); } return count; } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCHALL_THROW(IOException) } //////////////////////////////////////////////////////////////////////////////// void InflaterInputStream::close() { - try{ + try { - if( !isClosed() ) { + if (!isClosed()) { inflater->end(); this->atEOF = true; FilterInputStream::close(); } } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCHALL_THROW(IOException) } //////////////////////////////////////////////////////////////////////////////// int InflaterInputStream::available() const { - try{ + try { - if( isClosed() ) { + if (isClosed()) { throw IOException( - __FILE__, __LINE__, "Stream already closed." ); + __FILE__, __LINE__, "Stream already closed."); } - if( atEOF ) { + if (atEOF) { return 0; } return 1; } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCHALL_THROW(IOException) } //////////////////////////////////////////////////////////////////////////////// int InflaterInputStream::doReadByte() { - try{ + try { unsigned char buffer[1]; - if( doReadArrayBounded( buffer, 1, 0, 1 ) < 0 ) { + if (doReadArrayBounded(buffer, 1, 0, 1) < 0) { return -1; } - return (int)buffer[0]; + return (int) buffer[0]; } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCHALL_THROW(IOException) } //////////////////////////////////////////////////////////////////////////////// -int InflaterInputStream::doReadArrayBounded( unsigned char* buffer, int size, int offset, int length ) { +int InflaterInputStream::doReadArrayBounded(unsigned char* buffer, int size, int offset, int length) { try{ - if( buffer == NULL ) { + if (buffer == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Buffer passed was NULL." ); + __FILE__, __LINE__, "Buffer passed was NULL."); } - if( size < 0 ) { + if (size < 0) { throw IndexOutOfBoundsException( - __FILE__, __LINE__, "size parameter out of Bounds: %d.", size ); + __FILE__, __LINE__, "size parameter out of Bounds: %d.", size); } - if( offset > size || offset < 0 ) { + if (offset > size || offset < 0) { throw IndexOutOfBoundsException( - __FILE__, __LINE__, "offset parameter out of Bounds: %d.", offset ); + __FILE__, __LINE__, "offset parameter out of Bounds: %d.", offset); } - if( length < 0 || length > size - offset ) { + if (length < 0 || length > size - offset) { throw IndexOutOfBoundsException( - __FILE__, __LINE__, "length parameter out of Bounds: %d.", length ); + __FILE__, __LINE__, "length parameter out of Bounds: %d.", length); } - if( length == 0 ) { + if (length == 0) { return 0; } - if( isClosed() ) { + if (isClosed()) { throw IOException( - __FILE__, __LINE__, "Stream already closed." ); + __FILE__, __LINE__, "Stream already closed."); } - if( atEOF ) { + if (atEOF) { return -1; } do { - if( inflater->needsInput() ) { + if (inflater->needsInput()) { this->fill(); } @@ -227,42 +227,42 @@ int InflaterInputStream::doReadArrayBounded( unsigned char* buffer, int size, in // It may also be true if the next read() should return -1. try { - int result = inflater->inflate( buffer, size, offset, length ); + int result = inflater->inflate(buffer, size, offset, length); atEOF = inflater->finished(); - if( result > 0 ) { + if (result > 0) { return result; - } else if( atEOF ) { + } else if (atEOF) { return -1; - } else if( inflater->needsDictionary() ) { + } else if (inflater->needsDictionary()) { atEOF = true; return -1; - } else if( this->length == -1 ) { + } else if (this->length == -1) { atEOF = true; throw EOFException( - __FILE__, __LINE__, "Reached end of Input." ); + __FILE__, __LINE__, "Reached end of Input."); } - } catch( DataFormatException& e ) { + } catch (DataFormatException& e) { atEOF = true; - if( this->length == -1 ) { + if (this->length == -1) { throw EOFException( __FILE__, __LINE__, "Reached end of Input." ); } - IOException ex( __FILE__, __LINE__, "Error from Inflater" ); + IOException ex(__FILE__, __LINE__, "Error from Inflater"); ex.initCause(e.clone()); throw ex; } - } while(true); + } while (true); } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCH_RETHROW( IndexOutOfBoundsException ) - DECAF_CATCH_RETHROW( NullPointerException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + DECAF_CATCH_RETHROW(NullPointerException) + DECAF_CATCHALL_THROW(IOException) } //////////////////////////////////////////////////////////////////////////////// @@ -270,18 +270,18 @@ void InflaterInputStream::fill() { try{ - if( isClosed() ) { + if (isClosed()) { throw IOException( - __FILE__, __LINE__, "Stream already closed." ); + __FILE__, __LINE__, "Stream already closed."); } // Try and fill the input buffer, whatever we get goes into the inflater. - length = inputStream->read( &buff[0], (int)buff.size(), 0, (int)buff.size() ); + length = inputStream->read(&buff[0], (int) buff.size(), 0, (int) buff.size()); - if( length > 0 ) { - inflater->setInput( &buff[0], (int)buff.size(), 0, length ); + if (length > 0) { + inflater->setInput(&buff[0], (int) buff.size(), 0, length); } } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCHALL_THROW(IOException) } http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h b/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h index bce992b..c34df41 100644 --- a/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h +++ b/activemq-cpp/src/main/decaf/util/zip/InflaterInputStream.h @@ -60,8 +60,8 @@ namespace zip { private: - InflaterInputStream( const InflaterInputStream& ); - InflaterInputStream& operator= ( const InflaterInputStream& ); + InflaterInputStream(const InflaterInputStream&); + InflaterInputStream& operator=(const InflaterInputStream&); public: @@ -73,7 +73,7 @@ namespace zip { * @param own * Should this Filter take ownership of the InputStream pointer (defaults to false). */ - InflaterInputStream( decaf::io::InputStream* inputStream, bool own = false ); + InflaterInputStream(decaf::io::InputStream* inputStream, bool own = false); /** * Creates a new InflaterInputStream with a user supplied Inflater and a default buffer size. @@ -92,8 +92,8 @@ namespace zip { * * @throws NullPointerException if the Inflater given is NULL. */ - InflaterInputStream( decaf::io::InputStream* inputStream, Inflater* inflater, - bool own = false, bool ownInflater = false ); + InflaterInputStream(decaf::io::InputStream* inputStream, Inflater* inflater, + bool own = false, bool ownInflater = false); /** * Creates a new DeflateOutputStream with a user supplied Inflater and specified buffer size. @@ -115,8 +115,8 @@ namespace zip { * @throws NullPointerException if the Inflater given is NULL. * @throws IllegalArgumentException if the bufferSize value is zero. */ - InflaterInputStream( decaf::io::InputStream* inputStream, Inflater* inflater, - int bufferSize, bool own = false, bool ownInflater = false ); + InflaterInputStream(decaf::io::InputStream* inputStream, Inflater* inflater, + int bufferSize, bool own = false, bool ownInflater = false); virtual ~InflaterInputStream(); @@ -139,14 +139,14 @@ namespace zip { * * Skips the specified amount of uncompressed input data. */ - virtual long long skip( long long num ); + virtual long long skip(long long num); /** * {@inheritDoc} * * Does nothing. */ - virtual void mark( int readLimit ); + virtual void mark(int readLimit); /** * {@inheritDoc} @@ -175,7 +175,7 @@ namespace zip { virtual int doReadByte(); - virtual int doReadArrayBounded( unsigned char* buffer, int size, int offset, int length ); + virtual int doReadArrayBounded(unsigned char* buffer, int size, int offset, int length); };
