Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B12E3182DB for ; Wed, 5 Aug 2015 22:48:10 +0000 (UTC) Received: (qmail 41699 invoked by uid 500); 5 Aug 2015 22:48:10 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 41566 invoked by uid 500); 5 Aug 2015 22:48:10 -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 41443 invoked by uid 99); 5 Aug 2015 22:48:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Aug 2015 22:48:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 57299E0414; Wed, 5 Aug 2015 22:48:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tabish@apache.org To: commits@activemq.apache.org Date: Wed, 05 Aug 2015 22:48:11 -0000 Message-Id: <2954c50e25634279801ccc91b2933764@git.apache.org> In-Reply-To: <596d32782cbb47ba941b1a9875b837d6@git.apache.org> References: <596d32782cbb47ba941b1a9875b837d6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/9] activemq-cpp git commit: Formatting cleanup. Formatting cleanup. Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/e058de24 Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/e058de24 Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/e058de24 Branch: refs/heads/master Commit: e058de247aa7535faa977812c67a21e58dbfc2b7 Parents: f0b1ff9 Author: Timothy Bish Authored: Wed Aug 5 18:42:58 2015 -0400 Committer: Timothy Bish Committed: Wed Aug 5 18:42:58 2015 -0400 ---------------------------------------------------------------------- activemq-cpp/src/main/decaf/util/Arrays.h | 4 +- .../src/main/decaf/util/zip/Adler32.cpp | 34 +-- activemq-cpp/src/main/decaf/util/zip/Adler32.h | 8 +- activemq-cpp/src/main/decaf/util/zip/CRC32.cpp | 29 +-- activemq-cpp/src/main/decaf/util/zip/CRC32.h | 8 +- .../main/decaf/util/zip/CheckedInputStream.cpp | 94 +++---- .../main/decaf/util/zip/CheckedInputStream.h | 10 +- .../main/decaf/util/zip/CheckedOutputStream.cpp | 61 +++-- .../main/decaf/util/zip/CheckedOutputStream.h | 10 +- activemq-cpp/src/main/decaf/util/zip/Checksum.h | 8 +- .../src/main/decaf/util/zip/Deflater.cpp | 247 +++++++++---------- activemq-cpp/src/main/decaf/util/zip/Deflater.h | 28 +-- .../decaf/util/zip/DeflaterOutputStream.cpp | 135 +++++----- .../main/decaf/util/zip/DeflaterOutputStream.h | 19 +- .../src/main/decaf/util/zip/Inflater.cpp | 229 +++++++++-------- activemq-cpp/src/main/decaf/util/zip/Inflater.h | 24 +- .../main/decaf/util/zip/InflaterInputStream.cpp | 162 ++++++------ .../main/decaf/util/zip/InflaterInputStream.h | 20 +- 18 files changed, 558 insertions(+), 572 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/Arrays.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/Arrays.h b/activemq-cpp/src/main/decaf/util/Arrays.h index 5a7a941..d428921 100644 --- a/activemq-cpp/src/main/decaf/util/Arrays.h +++ b/activemq-cpp/src/main/decaf/util/Arrays.h @@ -28,8 +28,8 @@ namespace util { class Arrays { private: - Arrays( const Arrays& source ); - Arrays& operator= ( const Arrays& source ); + Arrays(const Arrays& source); + Arrays& operator=(const Arrays& source); private: http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/Adler32.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/Adler32.cpp b/activemq-cpp/src/main/decaf/util/zip/Adler32.cpp index 517fbb4..761a0a8 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Adler32.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/Adler32.cpp @@ -36,7 +36,7 @@ Adler32::~Adler32() { //////////////////////////////////////////////////////////////////////////////// void Adler32::reset() { - this->value = adler32( (uLong)this->value, NULL, 0 ); + this->value = adler32((uLong) this->value, NULL, 0); } //////////////////////////////////////////////////////////////////////////////// @@ -45,42 +45,42 @@ long long Adler32::getValue() const { } //////////////////////////////////////////////////////////////////////////////// -void Adler32::update( const std::vector& buffer ) { - this->update( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() ); +void Adler32::update(const std::vector& buffer) { + this->update(&buffer[0], (int) buffer.size(), 0, (int) buffer.size()); } //////////////////////////////////////////////////////////////////////////////// -void Adler32::update( const std::vector& buffer, int offset, int length ) { - this->update( &buffer[0], (int)buffer.size(), offset, length ); +void Adler32::update(const std::vector& buffer, int offset, int length) { + this->update(&buffer[0], (int) buffer.size(), offset, length); } //////////////////////////////////////////////////////////////////////////////// -void Adler32::update( int byte ) { - this->value = adler32( (uLong)this->value, (const Bytef*)&byte, 1 ); +void Adler32::update(int byte) { + this->value = adler32((uLong) this->value, (const Bytef*) &byte, 1); } //////////////////////////////////////////////////////////////////////////////// -void Adler32::update( const unsigned char* buffer, int size, int offset, int length ) { +void Adler32::update(const unsigned char* buffer, int size, int offset, int length) { - 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( buffer == NULL ) { + if (buffer == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Buffer pointer passed was NULL." ); + __FILE__, __LINE__, "Buffer pointer passed was NULL."); } - this->value = adler32( (uLong)this->value, (const Bytef*)( buffer + offset ), (uInt)length ); + this->value = adler32((uLong) this->value, (const Bytef*) (buffer + offset), (uInt) length); } http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/Adler32.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/Adler32.h b/activemq-cpp/src/main/decaf/util/zip/Adler32.h index 0ed9580..1d8d2fe 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Adler32.h +++ b/activemq-cpp/src/main/decaf/util/zip/Adler32.h @@ -58,7 +58,7 @@ namespace zip { * @param buffer * The buffer to read the updated bytes from. */ - virtual void update( const std::vector& buffer ); + virtual void update(const std::vector& buffer); /** * Updates the current checksum with the specified array of bytes. @@ -72,7 +72,7 @@ namespace zip { * * @throw IndexOutOfBoundsException if offset + length > size of the buffer. */ - virtual void update( const std::vector& buffer, int offset, int length ); + virtual void update(const std::vector& buffer, int offset, int length); /** * Updates the current checksum with the specified array of bytes. @@ -89,7 +89,7 @@ namespace zip { * @throw NullPointerException if the passed buffer is NULL. * @throw IndexOutOfBoundsException if offset + length > size of the buffer. */ - virtual void update( const unsigned char* buffer, int size, int offset, int length ); + virtual void update(const unsigned char* buffer, int size, int offset, int length); /** * Updates the current checksum with the specified byte value. @@ -97,7 +97,7 @@ namespace zip { * @param byte * The byte value to update the current Checksum with (0..255). */ - virtual void update( int byte ); + virtual void update(int byte); }; http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/CRC32.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/CRC32.cpp b/activemq-cpp/src/main/decaf/util/zip/CRC32.cpp index 5d3b308..6b4c3dd 100644 --- a/activemq-cpp/src/main/decaf/util/zip/CRC32.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/CRC32.cpp @@ -36,7 +36,7 @@ CRC32::~CRC32() { //////////////////////////////////////////////////////////////////////////////// void CRC32::reset() { - this->value = crc32( (uLong)this->value, NULL, 0 ); + this->value = crc32((uLong) this->value, NULL, 0); } //////////////////////////////////////////////////////////////////////////////// @@ -45,36 +45,33 @@ long long CRC32::getValue() const { } //////////////////////////////////////////////////////////////////////////////// -void CRC32::update( const std::vector& buffer ) { - this->update( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() ); +void CRC32::update(const std::vector& buffer) { + this->update(&buffer[0], (int) buffer.size(), 0, (int) buffer.size()); } //////////////////////////////////////////////////////////////////////////////// -void CRC32::update( const std::vector& buffer, int offset, int length ) { +void CRC32::update(const std::vector& buffer, int offset, int length) { - if( offset + length > (int)buffer.size() ) { + if (offset + length > (int) buffer.size()) { throw IndexOutOfBoundsException( - __FILE__, __LINE__, "Given offset + length exceeds the length of the buffer." ); + __FILE__, __LINE__, "Given offset + length exceeds the length of the buffer."); } - this->update( &buffer[0], (int)buffer.size(), offset, length ); + this->update(&buffer[0], (int) buffer.size(), offset, length); } //////////////////////////////////////////////////////////////////////////////// -void CRC32::update( int byte ) { - this->value = crc32( (uLong)this->value, (const Bytef*)&byte, 1 ); +void CRC32::update(int byte) { + this->value = crc32((uLong) this->value, (const Bytef*) &byte, 1); } //////////////////////////////////////////////////////////////////////////////// -void CRC32::update( const unsigned char* buffer, int size, int offset, int length ) { +void CRC32::update(const unsigned char* buffer, int size, int offset, int length) { - if( offset + length > size ) { + if (offset + length > size) { throw IndexOutOfBoundsException( - __FILE__, __LINE__, "Given offset + length exceeds the length of the buffer." ); + __FILE__, __LINE__, "Given offset + length exceeds the length of the buffer."); } - this->value = crc32( (uLong)this->value, (const Bytef*)( buffer + offset ), (uInt)length ); + this->value = crc32((uLong) this->value, (const Bytef*) (buffer + offset), (uInt) length); } - - - http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/CRC32.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/CRC32.h b/activemq-cpp/src/main/decaf/util/zip/CRC32.h index 6b6ba0d..221b1cf 100644 --- a/activemq-cpp/src/main/decaf/util/zip/CRC32.h +++ b/activemq-cpp/src/main/decaf/util/zip/CRC32.h @@ -42,7 +42,7 @@ namespace zip { virtual ~CRC32(); /** - * @returns the current checksum value. + * @return the current checksum value. */ virtual long long getValue() const; @@ -57,7 +57,7 @@ namespace zip { * @param buffer * The buffer to read the updated bytes from. */ - virtual void update( const std::vector& buffer ); + virtual void update(const std::vector& buffer); /** * Updates the current checksum with the specified array of bytes. @@ -88,7 +88,7 @@ namespace zip { * @throw NullPointerException if the passed buffer is NULL. * @throw IndexOutOfBoundsException if offset + length > size of the buffer. */ - virtual void update( const unsigned char* buffer, int size, int offset, int length ); + virtual void update(const unsigned char* buffer, int size, int offset, int length); /** * Updates the current checksum with the specified byte value. @@ -96,7 +96,7 @@ namespace zip { * @param byte * The byte value to update the current Checksum with (0..255). */ - virtual void update( int byte ); + virtual void update(int byte); }; http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.cpp b/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.cpp index 241278b..b7dfc46 100644 --- a/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.cpp @@ -27,12 +27,12 @@ using namespace decaf::util; using namespace decaf::util::zip; //////////////////////////////////////////////////////////////////////////////// -CheckedInputStream::CheckedInputStream( InputStream* inputStream, Checksum* sum, bool own ) - : FilterInputStream( inputStream, own ), sum( sum ) { +CheckedInputStream::CheckedInputStream(InputStream* inputStream, Checksum* sum, bool own) : + FilterInputStream(inputStream, own), sum(sum) { - if( sum == NULL ) { + if (sum == NULL) { throw NullPointerException( - __FILE__, __LINE__, "The Checksum instance cannot be NULL." ); + __FILE__, __LINE__, "The Checksum instance cannot be NULL."); } } @@ -41,117 +41,117 @@ CheckedInputStream::~CheckedInputStream() { } //////////////////////////////////////////////////////////////////////////////// -long long CheckedInputStream::skip( long long num ) { +long long CheckedInputStream::skip(long long num) { - try{ + try { - if( num <= 0 ) { + if (num <= 0) { return 0; } - if( isClosed() ) { + if (isClosed()) { throw IOException( - __FILE__, __LINE__, "Stream is Closed." ); + __FILE__, __LINE__, "Stream is Closed."); } // Perform smaller reads then the indicated amount - int remaining = Math::min( (int)num, 2048 ); + int remaining = Math::min((int) num, 2048); long long skipped = 0; - std::vector buffer( remaining ); + std::vector buffer(remaining); - while( skipped < num ) { + while (skipped < num) { - int result = this->inputStream->read( &buffer[0], remaining ); + int result = this->inputStream->read(&buffer[0], remaining); - if( isClosed() ) { + if (isClosed()) { throw IOException( - __FILE__, __LINE__, "Stream is Closed." ); + __FILE__, __LINE__, "Stream is Closed."); } - if( result == -1 ) { + if (result == -1) { return skipped; } - this->sum->update( buffer, 0, remaining ); + this->sum->update(buffer, 0, remaining); skipped += result; - remaining = ( num - skipped ) > (long long)buffer.size() ? (int)buffer.size() : (int)(num - skipped); + remaining = (num - skipped) > (long long) buffer.size() ? (int) buffer.size() : (int) (num - skipped); } return skipped; } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCHALL_THROW(IOException) } //////////////////////////////////////////////////////////////////////////////// int CheckedInputStream::doReadByte() { - try{ + try { - if( isClosed() ) { + if (isClosed()) { throw IOException( - __FILE__, __LINE__, "Stream is Closed." ); + __FILE__, __LINE__, "Stream is Closed."); } int result = this->inputStream->read(); - if( result != -1 ) { - this->sum->update( result ); + if (result != -1) { + this->sum->update(result); } return result; } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCHALL_THROW(IOException) } //////////////////////////////////////////////////////////////////////////////// -int CheckedInputStream::doReadArrayBounded( unsigned char* buffer, int size, int offset, int length ) { +int CheckedInputStream::doReadArrayBounded(unsigned char* buffer, int size, int offset, int length) { - try{ + 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 is Closed." ); + __FILE__, __LINE__, "Stream is Closed."); } - int result = this->inputStream->read( buffer, size, offset, length ); + int result = this->inputStream->read(buffer, size, offset, length); - if( result != -1 ) { + if (result != -1) { // Only add the amount of bytes actually read to the Checksum. - this->sum->update( buffer, size, offset, result ); + this->sum->update(buffer, size, offset, result); } return result; } - 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) } http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.h b/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.h index 7f86f92..05839f2 100644 --- a/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.h +++ b/activemq-cpp/src/main/decaf/util/zip/CheckedInputStream.h @@ -42,8 +42,8 @@ namespace zip { private: - CheckedInputStream( const CheckedInputStream& ); - CheckedInputStream& operator= ( const CheckedInputStream& ); + CheckedInputStream(const CheckedInputStream&); + CheckedInputStream& operator=(const CheckedInputStream&); public: @@ -59,7 +59,7 @@ namespace zip { * * @throws NullPointerException if the Checksum pointer is NULL. */ - CheckedInputStream( InputStream* inputStream, Checksum* sum, bool own = false ); + CheckedInputStream(InputStream* inputStream, Checksum* sum, bool own = false); virtual ~CheckedInputStream(); @@ -77,13 +77,13 @@ namespace zip { * * Adds the skipped bytes into the Checksum. */ - virtual long long skip( long long num ); + virtual long long skip(long long num); protected: 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); }; http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.cpp b/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.cpp index 27519e0..2d6f463 100644 --- a/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.cpp @@ -25,12 +25,12 @@ using namespace decaf::util; using namespace decaf::util::zip; //////////////////////////////////////////////////////////////////////////////// -CheckedOutputStream::CheckedOutputStream( OutputStream* outputStream, Checksum* sum, bool own ) - : FilterOutputStream( outputStream, own ), sum( sum ) { +CheckedOutputStream::CheckedOutputStream(OutputStream* outputStream, Checksum* sum, bool own) : + FilterOutputStream(outputStream, own), sum(sum) { - if( sum == NULL ) { + if (sum == NULL) { throw NullPointerException( - __FILE__, __LINE__, "The Checksum instance cannot be NULL." ); + __FILE__, __LINE__, "The Checksum instance cannot be NULL."); } } @@ -39,58 +39,57 @@ CheckedOutputStream::~CheckedOutputStream() { } //////////////////////////////////////////////////////////////////////////////// -void CheckedOutputStream::doWriteByte( unsigned char value ) { +void CheckedOutputStream::doWriteByte(unsigned char value) { - try{ + try { - if( isClosed() ) { + if (isClosed()) { throw IOException( - __FILE__, __LINE__, "Stream already closed" ); + __FILE__, __LINE__, "Stream already closed"); } - this->outputStream->write( value ); - this->sum->update( value ); + this->outputStream->write(value); + this->sum->update(value); } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCHALL_THROW(IOException) } //////////////////////////////////////////////////////////////////////////////// -void CheckedOutputStream::doWriteArrayBounded( const unsigned char* buffer, int size, - int offset, int length ) { +void CheckedOutputStream::doWriteArrayBounded(const unsigned char* buffer, int size, int offset, int length) { - try{ + try { - if( buffer == NULL ) { + if (buffer == NULL) { throw NullPointerException( - __FILE__, __LINE__, "The buffer passed was NULL." ); + __FILE__, __LINE__, "The 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( isClosed() ) { + if (isClosed()) { throw IOException( - __FILE__, __LINE__, "Stream already closed" ); + __FILE__, __LINE__, "Stream already closed"); } - this->outputStream->write( buffer, size, offset, length ); - this->sum->update( buffer, size, offset, length ); + this->outputStream->write(buffer, size, offset, length); + this->sum->update(buffer, size, offset, length); } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCH_RETHROW( NullPointerException ) - DECAF_CATCH_RETHROW( IndexOutOfBoundsException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCH_RETHROW(NullPointerException) + DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + DECAF_CATCHALL_THROW(IOException) } http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.h b/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.h index f0175af..870ddf8 100644 --- a/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.h +++ b/activemq-cpp/src/main/decaf/util/zip/CheckedOutputStream.h @@ -41,8 +41,8 @@ namespace zip { private: - CheckedOutputStream( const CheckedOutputStream& ); - CheckedOutputStream& operator= ( const CheckedOutputStream& ); + CheckedOutputStream(const CheckedOutputStream&); + CheckedOutputStream& operator=(const CheckedOutputStream&); public: @@ -58,7 +58,7 @@ namespace zip { * * @throws NullPointerException if the Checksum pointer is NULL. */ - CheckedOutputStream( decaf::io::OutputStream* outputStream, Checksum* sum, bool own = false ); + CheckedOutputStream(decaf::io::OutputStream* outputStream, Checksum* sum, bool own = false); virtual ~CheckedOutputStream(); @@ -71,9 +71,9 @@ namespace zip { protected: - virtual void doWriteByte( unsigned char value ); + virtual void doWriteByte(unsigned char value); - virtual void doWriteArrayBounded( const unsigned char* buffer, int size, int offset, int length ); + virtual void doWriteArrayBounded(const unsigned char* buffer, int size, int offset, int length); }; http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/Checksum.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/Checksum.h b/activemq-cpp/src/main/decaf/util/zip/Checksum.h index bb567ac..0cb0d2a 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Checksum.h +++ b/activemq-cpp/src/main/decaf/util/zip/Checksum.h @@ -55,7 +55,7 @@ namespace zip { * @param buffer * The buffer to read the updated bytes from. */ - virtual void update( const std::vector& buffer ) = 0; + virtual void update(const std::vector& buffer) = 0; /** * Updates the current checksum with the specified array of bytes. @@ -69,7 +69,7 @@ namespace zip { * * @throw IndexOutOfBoundsException if offset + length > size of the buffer. */ - virtual void update( const std::vector& buffer, int offset, int length ) = 0; + virtual void update(const std::vector& buffer, int offset, int length) = 0; /** * Updates the current checksum with the specified array of bytes. @@ -86,7 +86,7 @@ namespace zip { * @throw NullPointerException if the passed buffer is NULL. * @throw IndexOutOfBoundsException if offset + length > size of the buffer. */ - virtual void update( const unsigned char* buffer, int size, int offset, int length ) = 0; + virtual void update(const unsigned char* buffer, int size, int offset, int length) = 0; /** * Updates the current checksum with the specified byte value. @@ -94,7 +94,7 @@ namespace zip { * @param byte * The byte value to update the current Checksum with (0..255). */ - virtual void update( int byte ) = 0; + virtual void update(int byte) = 0; }; http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/Deflater.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/Deflater.cpp b/activemq-cpp/src/main/decaf/util/zip/Deflater.cpp index 12f4184..4d27edd 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Deflater.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/Deflater.cpp @@ -30,9 +30,9 @@ using namespace decaf::util; using namespace decaf::util::zip; //////////////////////////////////////////////////////////////////////////////// -namespace decaf{ -namespace util{ -namespace zip{ +namespace decaf { +namespace util { +namespace zip { class DeflaterData { public: @@ -48,8 +48,8 @@ namespace zip{ private: - DeflaterData( const DeflaterData& ); - DeflaterData& operator= ( const DeflaterData& ); + DeflaterData(const DeflaterData&); + DeflaterData& operator=(const DeflaterData&); public: @@ -64,11 +64,11 @@ namespace zip{ public: - static void initZLibDeflate( DeflaterData* handle, int level, bool nowrap = false ) { + static void initZLibDeflate(DeflaterData* handle, int level, bool nowrap = false) { - if( handle == NULL ) { + if (handle == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Error While initializing the Compression Library." ); + __FILE__, __LINE__, "Error While initializing the Compression Library."); } handle->stream = new z_stream; @@ -87,58 +87,58 @@ namespace zip{ handle->stream->next_in = Z_NULL; int result = Z_OK; - if( nowrap == false ) { - result = deflateInit( handle->stream, handle->level ); + if (nowrap == false) { + result = deflateInit(handle->stream, handle->level); } else { // Turn off ZLib header wrapping and encode raw. Attempts // to set all other values to their normal defaults. - result = deflateInit2( handle->stream, - handle->level, - Z_DEFLATED, - -15, 8, - Z_DEFAULT_STRATEGY ); + result = deflateInit2(handle->stream, + handle->level, + Z_DEFLATED, + -15, 8, + Z_DEFAULT_STRATEGY); } - if( result != Z_OK ) { + if (result != Z_OK) { throw RuntimeException( - __FILE__, __LINE__, "Error While initializing the Compression Library." ); + __FILE__, __LINE__, "Error While initializing the Compression Library."); } } - static void finishZlibDeflate( DeflaterData* handle ) { + static void finishZlibDeflate(DeflaterData* handle) { - if( handle == NULL ) { + if (handle == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Error While initializing the Compression Library." ); + __FILE__, __LINE__, "Error While initializing the Compression Library."); } handle->ended = true; - if( handle->stream != NULL ) { + if (handle->stream != NULL) { // Shutdown the ZLib stream - deflateEnd( handle->stream ); + deflateEnd(handle->stream); delete handle->stream; handle->stream = NULL; } } - static void resetZlibStream( DeflaterData* handle ) { + static void resetZlibStream(DeflaterData* handle) { - if( handle == NULL ) { + if (handle == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Error While initializing the Compression Library." ); + __FILE__, __LINE__, "Error While initializing the Compression Library."); } - if( handle->stream != NULL ) { + if (handle->stream != NULL) { handle->finished = false; handle->flush = Z_NO_FLUSH; handle->ended = false; // Ask ZLib to do the reset. - deflateReset( handle->stream ); + deflateReset(handle->stream); // Clear any old data that might still be around. handle->stream->opaque = Z_NULL; @@ -163,102 +163,100 @@ const int Deflater::FILTERED = 1; const int Deflater::HUFFMAN_ONLY = 2; //////////////////////////////////////////////////////////////////////////////// -Deflater::Deflater( int level, bool nowrap ) : data( new DeflaterData() ) { +Deflater::Deflater(int level, bool nowrap) : data(new DeflaterData()) { - if( level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION ) { + if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) { throw IllegalArgumentException( - __FILE__, __LINE__, "Compression level passed was Invalid: %d", level ); + __FILE__, __LINE__, "Compression level passed was Invalid: %d", level); } // Initialize all the ZLib structures. - DeflaterData::initZLibDeflate( this->data, level, nowrap ); + DeflaterData::initZLibDeflate(this->data, level, nowrap); } //////////////////////////////////////////////////////////////////////////////// -Deflater::Deflater() : data( new DeflaterData() ) { +Deflater::Deflater() : data(new DeflaterData()) { // Initialize all the ZLib structures. - DeflaterData::initZLibDeflate( this->data, DEFAULT_COMPRESSION ); + DeflaterData::initZLibDeflate(this->data, DEFAULT_COMPRESSION); } //////////////////////////////////////////////////////////////////////////////// Deflater::~Deflater() { - try{ + try { this->end(); delete this->data; } - DECAF_CATCH_NOTHROW( Exception ) + DECAF_CATCH_NOTHROW(Exception) DECAF_CATCHALL_NOTHROW() } //////////////////////////////////////////////////////////////////////////////// -void Deflater::setInput( const unsigned char* buffer, int size, int offset, int length ) { +void Deflater::setInput(const unsigned char* buffer, int size, int offset, int length) { - try{ + try { - if( buffer == NULL ) { + if (buffer == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Buffer passed cannot be NULL." ); + __FILE__, __LINE__, "Buffer passed cannot be NULL."); } - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Deflator has already been ended." ); + __FILE__, __LINE__, "The Deflator has already been ended."); } - if( offset + length > size ) { + if (offset + length > size) { throw IndexOutOfBoundsException( - __FILE__, __LINE__, "Given offset + length greater than the size of the buffer." ); + __FILE__, __LINE__, "Given offset + length greater than the size of the buffer."); } - // We can only change the level and strategy once an entire block of data is compressed. - if( this->data->stream->next_in == NULL ) { - deflateParams( this->data->stream, this->data->level, this->data->strategy ); + if (this->data->stream->next_in == NULL) { + deflateParams(this->data->stream, this->data->level, this->data->strategy); } - this->data->stream->avail_in = (uInt)length; - this->data->stream->next_in = (Bytef*)( buffer + offset ); + this->data->stream->avail_in = (uInt) length; + this->data->stream->next_in = (Bytef*) (buffer + offset); } - DECAF_CATCH_RETHROW( NullPointerException ) - DECAF_CATCH_RETHROW( IllegalStateException ) - DECAF_CATCH_RETHROW( IndexOutOfBoundsException ) - DECAF_CATCHALL_THROW( IllegalStateException ) + DECAF_CATCH_RETHROW(NullPointerException) + DECAF_CATCH_RETHROW(IllegalStateException) + DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + DECAF_CATCHALL_THROW(IllegalStateException) } //////////////////////////////////////////////////////////////////////////////// -void Deflater::setInput( const std::vector& buffer, int offset, int length ) { - - this->setInput( &buffer[0], (int)buffer.size(), offset, length ); +void Deflater::setInput(const std::vector& buffer, int offset, int length) { + this->setInput(&buffer[0], (int) buffer.size(), offset, length); } //////////////////////////////////////////////////////////////////////////////// -void Deflater::setInput( const std::vector& buffer ) { +void Deflater::setInput(const std::vector& buffer) { - if( buffer.empty() ) { + if (buffer.empty()) { return; } - this->setInput( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() ); + this->setInput(&buffer[0], (int) buffer.size(), 0, (int) buffer.size()); } //////////////////////////////////////////////////////////////////////////////// -void Deflater::setDictionary( const unsigned char* buffer, int size, int offset, int length ) { +void Deflater::setDictionary(const unsigned char* buffer, int size, int offset, int length) { - try{ + try { - if( buffer == NULL ) { + if (buffer == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Buffer passed cannot be NULL." ); + __FILE__, __LINE__, "Buffer passed cannot be NULL."); } - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Deflator has already been ended." ); + __FILE__, __LINE__, "The Deflator has already been ended."); } - if( offset + length > size ) { + if (offset + length > size) { throw IndexOutOfBoundsException( - __FILE__, __LINE__, "Given offset + length greater than the size of the buffer." ); + __FILE__, __LINE__, "Given offset + length greater than the size of the buffer."); } // From the ZLib documentation. @@ -266,60 +264,59 @@ void Deflater::setDictionary( const unsigned char* buffer, int size, int offset, // (such as NULL dictionary) or the stream state is inconsistent (for example if deflate has // already been called for this stream or if the compression method is bsort). // deflateSetDictionary does not perform any compression: this will be done by deflate(). - if( deflateSetDictionary( this->data->stream, buffer + offset, (uInt)length ) != Z_OK ) { + if (deflateSetDictionary(this->data->stream, buffer + offset, (uInt) length) != Z_OK) { throw IllegalStateException( - __FILE__, __LINE__, "Deflator could not accept the dictionary." ); + __FILE__, __LINE__, "Deflator could not accept the dictionary."); } } - DECAF_CATCH_RETHROW( NullPointerException ) - DECAF_CATCH_RETHROW( IllegalStateException ) - DECAF_CATCH_RETHROW( IndexOutOfBoundsException ) - DECAF_CATCHALL_THROW( IllegalStateException ) + DECAF_CATCH_RETHROW(NullPointerException) + DECAF_CATCH_RETHROW(IllegalStateException) + DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + DECAF_CATCHALL_THROW(IllegalStateException) } //////////////////////////////////////////////////////////////////////////////// -void Deflater::setDictionary( const std::vector& buffer, int offset, int length ) { - - this->setDictionary( &buffer[0], (int)buffer.size(), offset, length ); +void Deflater::setDictionary(const std::vector& buffer, int offset, int length) { + this->setDictionary(&buffer[0], (int) buffer.size(), offset, length); } //////////////////////////////////////////////////////////////////////////////// -void Deflater::setDictionary( const std::vector& buffer ) { +void Deflater::setDictionary(const std::vector& buffer) { - if( buffer.empty() ) { + if (buffer.empty()) { return; } - this->setDictionary( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() ); + this->setDictionary(&buffer[0], (int) buffer.size(), 0, (int) buffer.size()); } //////////////////////////////////////////////////////////////////////////////// -void Deflater::setStrategy( int strategy ) { +void Deflater::setStrategy(int strategy) { - if( strategy < DEFAULT_STRATEGY || strategy > HUFFMAN_ONLY ) { + if (strategy < DEFAULT_STRATEGY || strategy > HUFFMAN_ONLY) { throw IllegalArgumentException( - __FILE__, __LINE__, "Strategy value {%d} is not valid.", strategy ); + __FILE__, __LINE__, "Strategy value {%d} is not valid.", strategy); } - if( this->data->stream == NULL && !this->data->ended ) { + if (this->data->stream == NULL && !this->data->ended) { throw IllegalStateException( - __FILE__, __LINE__, "The Deflator is in an invalid state." ); + __FILE__, __LINE__, "The Deflator is in an invalid state."); } this->data->strategy = strategy; } //////////////////////////////////////////////////////////////////////////////// -void Deflater::setLevel( int level ) { +void Deflater::setLevel(int level) { - if( level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION ) { + if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) { throw IllegalArgumentException( - __FILE__, __LINE__, "Strategy value {%d} is not valid.", level ); + __FILE__, __LINE__, "Strategy value {%d} is not valid.", level); } - if( this->data->stream == NULL && !this->data->ended ) { + if (this->data->stream == NULL && !this->data->ended) { throw IllegalStateException( - __FILE__, __LINE__, "The Deflator is in an invalid state." ); + __FILE__, __LINE__, "The Deflator is in an invalid state."); } this->data->level = level; @@ -327,7 +324,7 @@ void Deflater::setLevel( int level ) { //////////////////////////////////////////////////////////////////////////////// bool Deflater::needsInput() const { - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { return false; } @@ -345,72 +342,70 @@ bool Deflater::finished() const { } //////////////////////////////////////////////////////////////////////////////// -int Deflater::deflate( unsigned char* buffer, int size, int offset, int length ) { +int Deflater::deflate(unsigned char* buffer, int size, int offset, int length) { - try{ + try { - if( buffer == NULL ) { + if (buffer == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Buffer passed cannot be NULL." ); + __FILE__, __LINE__, "Buffer passed cannot be NULL."); } - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Deflator has already been ended." ); + __FILE__, __LINE__, "The Deflator has already been ended."); } - 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); } unsigned long outStart = this->data->stream->total_out; this->data->stream->next_out = buffer + offset; - this->data->stream->avail_out = (uInt)length; + this->data->stream->avail_out = (uInt) length; // Call ZLib and then process the resulting data to figure out what happened. - int result = ::deflate( this->data->stream, this->data->flush ); + int result = ::deflate(this->data->stream, this->data->flush); - if( result == Z_STREAM_END ) { + if (result == Z_STREAM_END) { this->data->finished = true; } - return (int)( this->data->stream->total_out - outStart ); + return (int) (this->data->stream->total_out - outStart); } - DECAF_CATCH_RETHROW( NullPointerException ) - DECAF_CATCH_RETHROW( IllegalStateException ) - DECAF_CATCH_RETHROW( IndexOutOfBoundsException ) - DECAF_CATCHALL_THROW( IllegalStateException ) + DECAF_CATCH_RETHROW(NullPointerException) + DECAF_CATCH_RETHROW(IllegalStateException) + DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + DECAF_CATCHALL_THROW(IllegalStateException) } //////////////////////////////////////////////////////////////////////////////// -int Deflater::deflate( std::vector& buffer, int offset, int length ) { - - return this->deflate( &buffer[0], (int)buffer.size(), offset, length ); +int Deflater::deflate(std::vector& buffer, int offset, int length) { + return this->deflate(&buffer[0], (int) buffer.size(), offset, length); } //////////////////////////////////////////////////////////////////////////////// -int Deflater::deflate( std::vector& buffer ) { - - return this->deflate( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() ); +int Deflater::deflate(std::vector& buffer) { + return this->deflate(&buffer[0], (int) buffer.size(), 0, (int) buffer.size()); } //////////////////////////////////////////////////////////////////////////////// long long Deflater::getAdler() const { - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Deflator has already been ended." ); + __FILE__, __LINE__, "The Deflator has already been ended."); } return this->data->stream->adler; @@ -418,9 +413,9 @@ long long Deflater::getAdler() const { //////////////////////////////////////////////////////////////////////////////// long long Deflater::getBytesRead() const { - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Deflator has already been ended." ); + __FILE__, __LINE__, "The Deflator has already been ended."); } return this->data->stream->total_in; @@ -428,9 +423,9 @@ long long Deflater::getBytesRead() const { //////////////////////////////////////////////////////////////////////////////// long long Deflater::getBytesWritten() const { - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Deflator has already been ended." ); + __FILE__, __LINE__, "The Deflator has already been ended."); } return this->data->stream->total_out; @@ -439,18 +434,18 @@ long long Deflater::getBytesWritten() const { //////////////////////////////////////////////////////////////////////////////// void Deflater::reset() { - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Deflator has already been ended." ); + __FILE__, __LINE__, "The Deflator has already been ended."); } - DeflaterData::resetZlibStream( this->data ); + DeflaterData::resetZlibStream(this->data); } //////////////////////////////////////////////////////////////////////////////// void Deflater::end() { - if( this->data ) { - DeflaterData::finishZlibDeflate( this->data ); + if (this->data) { + DeflaterData::finishZlibDeflate(this->data); } } http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/Deflater.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/Deflater.h b/activemq-cpp/src/main/decaf/util/zip/Deflater.h index 06d74e0..6e0b59e 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Deflater.h +++ b/activemq-cpp/src/main/decaf/util/zip/Deflater.h @@ -101,8 +101,8 @@ namespace zip { private: - Deflater( const Deflater& ); - Deflater operator= ( const Deflater& ); + Deflater(const Deflater&); + Deflater operator=(const Deflater&); public: @@ -116,7 +116,7 @@ namespace zip { * @param nowrap * If true uses GZip compatible compression (defaults to false). */ - Deflater( int level, bool nowrap = false ); + Deflater(int level, bool nowrap = false); /** * Creates a new compressor with the default compression level. Compressed data will be @@ -143,7 +143,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 compression. This should be called whenever needsInput() returns @@ -159,7 +159,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& buffer, int offset, int length ); + void setInput(const std::vector& buffer, int offset, int length); /** * Sets input data for compression. This should be called whenever needsInput() returns @@ -170,7 +170,7 @@ namespace zip { * * @throws IllegalStateException if in the end state. */ - void setInput( const std::vector& buffer ); + void setInput(const std::vector& buffer); /** * Sets preset dictionary for compression. A preset dictionary is used when the @@ -191,7 +191,7 @@ namespace zip { * @throws IndexOutOfBoundsException if the offset + length > size of the buffer. * @throws IllegalStateException if in the end state. */ - 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 preset dictionary for compression. A preset dictionary is used when the @@ -209,7 +209,7 @@ namespace zip { * @throws IndexOutOfBoundsException if the offset + length > size of the buffer. * @throws IllegalStateException if in the end state. */ - void setDictionary( const std::vector& buffer, int offset, int length ); + void setDictionary(const std::vector& buffer, int offset, int length); /** * Sets preset dictionary for compression. A preset dictionary is used when the @@ -222,7 +222,7 @@ namespace zip { * * @throws IllegalStateException if in the end state. */ - void setDictionary( const std::vector& buffer ); + void setDictionary(const std::vector& buffer); /** * Sets the compression strategy to the specified value. @@ -233,7 +233,7 @@ namespace zip { * @throws IllegalArgumentException if the strategy value is invalid. * @throws IllegalStateException if in the end state. */ - void setStrategy( int strategy ); + void setStrategy(int strategy); /** * Sets the compression level to the specified value. @@ -244,7 +244,7 @@ namespace zip { * @throws IllegalArgumentException if the level value is invalid. * @throws IllegalStateException if in the end state. */ - void setLevel( int level ); + void setLevel(int level); /** * @return true if the input data buffer is empty and setInput() should be called in @@ -283,7 +283,7 @@ namespace zip { * @throws IndexOutOfBoundsException if the offset + length > size of the buffer. * @throws IllegalStateException if in the end state. */ - int deflate( unsigned char* buffer, int size, int offset, int length ); + int deflate(unsigned char* buffer, int size, int offset, int length); /** * Fills specified buffer with compressed data. Returns actual number of bytes of @@ -302,7 +302,7 @@ namespace zip { * @throws IndexOutOfBoundsException if the offset + length > size of the buffer. * @throws IllegalStateException if in the end state. */ - int deflate( std::vector& buffer, int offset, int length ); + int deflate(std::vector& buffer, int offset, int length); /** * Fills specified buffer with compressed data. Returns actual number of bytes of @@ -316,7 +316,7 @@ namespace zip { * * @throws IllegalStateException if in the end state. */ - int deflate( std::vector& buffer ); + int deflate(std::vector& 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/DeflaterOutputStream.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.cpp b/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.cpp index bf9ccfb..379c542 100644 --- a/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.cpp @@ -28,174 +28,171 @@ using namespace decaf::util::zip; const std::size_t DeflaterOutputStream::DEFAULT_BUFFER_SIZE = 512; //////////////////////////////////////////////////////////////////////////////// -DeflaterOutputStream::DeflaterOutputStream( OutputStream* outputStream, bool own ) : - FilterOutputStream( outputStream, own ), deflater(new Deflater()), buf(), ownDeflater(true), isDone(false) { +DeflaterOutputStream::DeflaterOutputStream(OutputStream* outputStream, bool own) : + FilterOutputStream(outputStream, own), deflater(new Deflater()), buf(), ownDeflater(true), isDone(false) { - this->buf.resize( DEFAULT_BUFFER_SIZE ); + this->buf.resize(DEFAULT_BUFFER_SIZE); } //////////////////////////////////////////////////////////////////////////////// -DeflaterOutputStream::DeflaterOutputStream( OutputStream* outputStream, Deflater* deflater, bool own, bool ownDeflater ) - : FilterOutputStream( outputStream, own ), deflater(deflater), buf(), ownDeflater(ownDeflater), isDone(false) { +DeflaterOutputStream::DeflaterOutputStream(OutputStream* outputStream, Deflater* deflater, bool own, bool ownDeflater) : + FilterOutputStream(outputStream, own), deflater(deflater), buf(), ownDeflater(ownDeflater), isDone(false) { - if( deflater == NULL ) { + if (deflater == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Deflater passed was NULL." ); + __FILE__, __LINE__, "Deflater passed was NULL."); } - this->buf.resize( DEFAULT_BUFFER_SIZE ); + this->buf.resize(DEFAULT_BUFFER_SIZE); } //////////////////////////////////////////////////////////////////////////////// -DeflaterOutputStream::DeflaterOutputStream( OutputStream* outputStream, Deflater* deflater, - int bufferSize, bool own, bool ownDeflater ) - : FilterOutputStream( outputStream, own ), deflater(deflater), buf(), ownDeflater(ownDeflater), isDone(false) { +DeflaterOutputStream::DeflaterOutputStream(OutputStream* outputStream, Deflater* deflater, int bufferSize, bool own, bool ownDeflater) : + FilterOutputStream(outputStream, own), deflater(deflater), buf(), ownDeflater(ownDeflater), isDone(false) { - if( deflater == NULL ) { + if (deflater == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Deflater passed was NULL." ); + __FILE__, __LINE__, "Deflater 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->buf.resize( bufferSize ); + this->buf.resize(bufferSize); } //////////////////////////////////////////////////////////////////////////////// DeflaterOutputStream::~DeflaterOutputStream() { - try{ + try { this->close(); - if( ownDeflater ) { + if (ownDeflater) { delete this->deflater; } } - DECAF_CATCH_NOTHROW( Exception ) - DECAF_CATCHALL_NOTHROW() -} + DECAF_CATCH_NOTHROW(Exception) + DECAF_CATCHALL_NOTHROW()} //////////////////////////////////////////////////////////////////////////////// void DeflaterOutputStream::finish() { - try{ + try { - if( isDone ) { + if (isDone) { return; } int result; this->deflater->finish(); - while( !this->deflater->finished() ) { + while (!this->deflater->finished()) { - if( this->deflater->needsInput() ) { - this->deflater->setInput( buf, 0, 0 ); + if (this->deflater->needsInput()) { + this->deflater->setInput(buf, 0, 0); } - result = this->deflater->deflate( &buf[0], (int)buf.size(), 0, (int)buf.size() ); - this->outputStream->write( &buf[0], (int)buf.size(), 0, result ); + result = this->deflater->deflate(&buf[0], (int) buf.size(), 0, (int) buf.size()); + this->outputStream->write(&buf[0], (int) buf.size(), 0, result); } this->isDone = true; } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCHALL_THROW(IOException) } //////////////////////////////////////////////////////////////////////////////// void DeflaterOutputStream::close() { - try{ + try { - if( !this->deflater->finished() ) { + if (!this->deflater->finished()) { this->finish(); } this->deflater->end(); FilterOutputStream::close(); } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCHALL_THROW(IOException) } //////////////////////////////////////////////////////////////////////////////// -void DeflaterOutputStream::doWriteByte( unsigned char value ) { +void DeflaterOutputStream::doWriteByte(unsigned char value) { - try{ - this->doWriteArrayBounded( &value, 1, 0, 1 ); + try { + this->doWriteArrayBounded(&value, 1, 0, 1); } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCHALL_THROW(IOException) } //////////////////////////////////////////////////////////////////////////////// -void DeflaterOutputStream::doWriteArrayBounded( const unsigned char* buffer, int size, - int offset, int length ) { +void DeflaterOutputStream::doWriteArrayBounded(const unsigned char* buffer, int size, int offset, int length) { - try{ + try { - if( isDone ) { + if (isDone) { throw IOException( - __FILE__, __LINE__, "Finish was already called on this DeflaterOutputStream." ); + __FILE__, __LINE__, "Finish was already called on this DeflaterOutputStream."); } - 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; } - if( isClosed() ) { + if (isClosed()) { throw IOException( - __FILE__, __LINE__, "The stream is already closed." ); + __FILE__, __LINE__, "The stream is already closed."); } - if( !this->deflater->needsInput() ) { + if (!this->deflater->needsInput()) { throw IOException( - __FILE__, __LINE__, "The Deflater is in an Invalid State." ); + __FILE__, __LINE__, "The Deflater is in an Invalid State."); } - this->deflater->setInput( buffer, size, offset, length ); + this->deflater->setInput(buffer, size, offset, length); this->deflate(); } - DECAF_CATCH_RETHROW( IOException ) - DECAF_CATCH_RETHROW( NullPointerException ) - DECAF_CATCH_RETHROW( IndexOutOfBoundsException ) - DECAF_CATCHALL_THROW( IOException ) + DECAF_CATCH_RETHROW(IOException) + DECAF_CATCH_RETHROW(NullPointerException) + DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + DECAF_CATCHALL_THROW(IOException) } //////////////////////////////////////////////////////////////////////////////// void DeflaterOutputStream::deflate() { - try{ + try { int result; - do{ - result = this->deflater->deflate( &buf[0], (int)buf.size(), 0, (int)buf.size() ); - this->outputStream->write( &buf[0], (int)buf.size(), 0, result ); - } while( !this->deflater->needsInput() ); + do { + result = this->deflater->deflate(&buf[0], (int) buf.size(), 0, (int) buf.size()); + this->outputStream->write(&buf[0], (int) buf.size(), 0, result); + } while (!this->deflater->needsInput()); } - 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/DeflaterOutputStream.h ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.h b/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.h index 08f751e..8e953e6 100644 --- a/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.h +++ b/activemq-cpp/src/main/decaf/util/zip/DeflaterOutputStream.h @@ -56,8 +56,8 @@ namespace zip { private: - DeflaterOutputStream( const DeflaterOutputStream& ); - DeflaterOutputStream& operator= ( const DeflaterOutputStream& ); + DeflaterOutputStream(const DeflaterOutputStream&); + DeflaterOutputStream& operator=(const DeflaterOutputStream&); public: @@ -69,7 +69,7 @@ namespace zip { * @param own * Should this filter take ownership of the OutputStream pointer (default is false). */ - DeflaterOutputStream( decaf::io::OutputStream* outputStream, bool own = false ); + DeflaterOutputStream(decaf::io::OutputStream* outputStream, bool own = false); /** * Creates a new DeflateOutputStream with a user supplied Deflater and a default buffer size. @@ -88,8 +88,8 @@ namespace zip { * * @throws NullPointerException if the Deflater given is NULL. */ - DeflaterOutputStream( decaf::io::OutputStream* outputStream, Deflater* deflater, - bool own = false, bool ownDeflater = false ); + DeflaterOutputStream(decaf::io::OutputStream* outputStream, Deflater* deflater, + bool own = false, bool ownDeflater = false); /** * Creates a new DeflateOutputStream with a user supplied Deflater and specified buffer size. @@ -111,8 +111,8 @@ namespace zip { * @throws NullPointerException if the Deflater given is NULL. * @throws IllegalArgumentException if bufferSize is 0. */ - DeflaterOutputStream( decaf::io::OutputStream* outputStream, Deflater* deflater, - int bufferSize, bool own = false, bool ownDeflater = false ); + DeflaterOutputStream(decaf::io::OutputStream* outputStream, Deflater* deflater, + int bufferSize, bool own = false, bool ownDeflater = false); virtual ~DeflaterOutputStream(); @@ -133,10 +133,9 @@ namespace zip { protected: - virtual void doWriteByte( unsigned char value ); + virtual void doWriteByte(unsigned char value); - virtual void doWriteArrayBounded( const unsigned char* buffer, int size, - int offset, int length ); + virtual void doWriteArrayBounded(const unsigned char* buffer, int size, int offset, int length); protected: http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/e058de24/activemq-cpp/src/main/decaf/util/zip/Inflater.cpp ---------------------------------------------------------------------- diff --git a/activemq-cpp/src/main/decaf/util/zip/Inflater.cpp b/activemq-cpp/src/main/decaf/util/zip/Inflater.cpp index bb0923f..48dff4f 100644 --- a/activemq-cpp/src/main/decaf/util/zip/Inflater.cpp +++ b/activemq-cpp/src/main/decaf/util/zip/Inflater.cpp @@ -47,8 +47,8 @@ namespace zip{ private: - InflaterData( const InflaterData& ); - InflaterData& operator= ( const InflaterData& ); + InflaterData(const InflaterData&); + InflaterData& operator=(const InflaterData&); public: @@ -56,11 +56,11 @@ namespace zip{ public: - static void initZlibInflate( InflaterData* handle, bool nowrap = false ) { + static void initZlibInflate(InflaterData* handle, bool nowrap = false) { - if( handle == NULL ) { + if (handle == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Error While initializing the Decompression Library." ); + __FILE__, __LINE__, "Error While initializing the Decompression Library."); } handle->stream = new z_stream; @@ -77,50 +77,50 @@ namespace zip{ handle->stream->next_in = Z_NULL; int result = Z_OK; - if( nowrap == false ) { - result = inflateInit( handle->stream ); + if (nowrap == false) { + result = inflateInit(handle->stream); } else { // Disable the ZLib header. - result = inflateInit2( handle->stream, -15 ); + result = inflateInit2(handle->stream, -15); } - if( result != Z_OK ) { + if (result != Z_OK) { throw RuntimeException( - __FILE__, __LINE__, "Error While initializing the Decompression Library." ); + __FILE__, __LINE__, "Error While initializing the Decompression Library."); } } - static void finishZlibDeflate( InflaterData* handle ) { + static void finishZlibDeflate(InflaterData* handle) { - if( handle == NULL ) { + if (handle == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Error While initializing the Decompression Library." ); + __FILE__, __LINE__, "Error While initializing the Decompression Library."); } - if( handle->stream != NULL ) { + if (handle->stream != NULL) { // Shutdown the ZLib stream - inflateEnd( handle->stream ); + inflateEnd(handle->stream); delete handle->stream; handle->stream = NULL; } } - static void resetZlibStream( InflaterData* handle ) { + static void resetZlibStream(InflaterData* handle) { - if( handle == NULL ) { + if (handle == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Error While initializing the Decompression Library." ); + __FILE__, __LINE__, "Error While initializing the Decompression Library."); } - if( handle->stream != NULL ) { + if (handle->stream != NULL) { handle->finished = false; handle->needDictionary = false; handle->flush = Z_NO_FLUSH; // Ask ZLib to do the reset. - inflateReset( handle->stream ); + inflateReset(handle->stream); // clear any old data handle->stream->opaque = Z_NULL; @@ -133,78 +133,77 @@ namespace zip{ }}} //////////////////////////////////////////////////////////////////////////////// -Inflater::Inflater( bool nowrap ) : data( new InflaterData() ) { - InflaterData::initZlibInflate( this->data, nowrap ); +Inflater::Inflater(bool nowrap) : data(new InflaterData()) { + InflaterData::initZlibInflate(this->data, nowrap); } //////////////////////////////////////////////////////////////////////////////// -Inflater::Inflater() : data( new InflaterData() ) { - InflaterData::initZlibInflate( this->data ); +Inflater::Inflater() : data(new InflaterData()) { + InflaterData::initZlibInflate(this->data); } //////////////////////////////////////////////////////////////////////////////// Inflater::~Inflater() { - try{ + try { this->end(); delete data; } - DECAF_CATCH_NOTHROW( Exception ) - DECAF_CATCHALL_NOTHROW() -} + DECAF_CATCH_NOTHROW(Exception) + DECAF_CATCHALL_NOTHROW()} //////////////////////////////////////////////////////////////////////////////// -void Inflater::setInput( const unsigned char* buffer, int size, int offset, int length ) { +void Inflater::setInput(const unsigned char* buffer, int size, int offset, int length) { - try{ + try { - if( buffer == NULL ) { + if (buffer == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Passed Buffer was NULL." ); + __FILE__, __LINE__, "Passed Buffer was NULL."); } - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Inflater end method has already been called." ); + __FILE__, __LINE__, "The Inflater end method has already been called."); } - if( offset + length > size ) { + if (offset + length > size) { throw IndexOutOfBoundsException( - __FILE__, __LINE__, "The offset + length given is greater than the specified buffer size." ); + __FILE__, __LINE__, "The offset + length given is greater than the specified buffer size."); } - this->data->stream->avail_in = (uInt)length; - this->data->stream->next_in = (Bytef*)( buffer + offset ); + this->data->stream->avail_in = (uInt) length; + this->data->stream->next_in = (Bytef*) (buffer + offset); } - DECAF_CATCH_RETHROW( NullPointerException ) - DECAF_CATCH_RETHROW( IndexOutOfBoundsException ) - DECAF_CATCH_RETHROW( IllegalStateException ) - DECAF_CATCHALL_THROW( IllegalStateException ) + DECAF_CATCH_RETHROW(NullPointerException) + DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + DECAF_CATCH_RETHROW(IllegalStateException) + DECAF_CATCHALL_THROW(IllegalStateException) } //////////////////////////////////////////////////////////////////////////////// -void Inflater::setInput( const std::vector& buffer, int offset, int length ) { +void Inflater::setInput(const std::vector& buffer, int offset, int length) { - if( buffer.empty() ) { + if (buffer.empty()) { return; } - this->setInput( &buffer[0], (int)buffer.size(), offset, length ); + this->setInput(&buffer[0], (int) buffer.size(), offset, length); } //////////////////////////////////////////////////////////////////////////////// -void Inflater::setInput( const std::vector& buffer ) { +void Inflater::setInput(const std::vector& buffer) { - if( buffer.empty() ) { + if (buffer.empty()) { return; } - this->setInput( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() ); + this->setInput(&buffer[0], (int) buffer.size(), 0, (int) buffer.size()); } //////////////////////////////////////////////////////////////////////////////// int Inflater::getRemaining() const { - if( this->data->stream != NULL ) { + if (this->data->stream != NULL) { return this->data->stream->avail_in; } @@ -212,23 +211,23 @@ int Inflater::getRemaining() const { } //////////////////////////////////////////////////////////////////////////////// -void Inflater::setDictionary( const unsigned char* buffer, int size, int offset, int length ) { +void Inflater::setDictionary(const unsigned char* buffer, int size, int offset, int length) { - try{ + try { - if( buffer == NULL ) { + if (buffer == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Passed Buffer was NULL." ); + __FILE__, __LINE__, "Passed Buffer was NULL."); } - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Inflater end method has already been called." ); + __FILE__, __LINE__, "The Inflater end method has already been called."); } - if( offset + length > size ) { + if (offset + length > size) { throw IndexOutOfBoundsException( - __FILE__, __LINE__, "The offset + length given is greater than the specified buffer size." ); + __FILE__, __LINE__, "The offset + length given is greater than the specified buffer size."); } // From the ZLib documentation @@ -236,43 +235,43 @@ void Inflater::setDictionary( const unsigned char* buffer, int size, int offset, // as NULL dictionary) or the stream state is inconsistent, Z_DATA_ERROR if the given dictionary // doesn't match the expected one (incorrect adler32 value). inflateSetDictionary does not // perform any decompression: this will be done by subsequent calls of inflate(). - int result = inflateSetDictionary( this->data->stream, buffer + offset, (uInt)length ); - if( result != Z_OK ) { + int result = inflateSetDictionary(this->data->stream, buffer + offset, (uInt) length); + if (result != Z_OK) { throw IllegalArgumentException( - __FILE__, __LINE__, "Dictionary given does not match required checksum value." ); + __FILE__, __LINE__, "Dictionary given does not match required checksum value."); } } - DECAF_CATCH_RETHROW( NullPointerException ) - DECAF_CATCH_RETHROW( IndexOutOfBoundsException ) - DECAF_CATCH_RETHROW( IllegalStateException ) - DECAF_CATCH_RETHROW( IllegalArgumentException ) - DECAF_CATCHALL_THROW( IllegalStateException ) + DECAF_CATCH_RETHROW(NullPointerException) + DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + DECAF_CATCH_RETHROW(IllegalStateException) + DECAF_CATCH_RETHROW(IllegalArgumentException) + DECAF_CATCHALL_THROW(IllegalStateException) } //////////////////////////////////////////////////////////////////////////////// -void Inflater::setDictionary( const std::vector& buffer, int offset, int length ) { +void Inflater::setDictionary(const std::vector& buffer, int offset, int length) { - if( buffer.empty() ) { + if (buffer.empty()) { return; } - this->setDictionary( &buffer[0], (int)buffer.size(), offset, length ); + this->setDictionary(&buffer[0], (int) buffer.size(), offset, length); } //////////////////////////////////////////////////////////////////////////////// -void Inflater::setDictionary( const std::vector& buffer ) { +void Inflater::setDictionary(const std::vector& buffer) { - if( buffer.empty() ) { + if (buffer.empty()) { return; } - this->setDictionary( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() ); + this->setDictionary(&buffer[0], (int) buffer.size(), 0, (int) buffer.size()); } //////////////////////////////////////////////////////////////////////////////// bool Inflater::needsInput() const { - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { return false; } @@ -295,93 +294,93 @@ bool Inflater::finished() const { } //////////////////////////////////////////////////////////////////////////////// -int Inflater::inflate( unsigned char* buffer, int size, int offset, int length ) { +int Inflater::inflate(unsigned char* buffer, int size, int offset, int length) { - try{ + try { - if( buffer == NULL ) { + if (buffer == NULL) { throw NullPointerException( - __FILE__, __LINE__, "Passed Buffer was NULL." ); + __FILE__, __LINE__, "Passed Buffer was NULL."); } - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Inflater end method has already been called." ); + __FILE__, __LINE__, "The Inflater end method has already been called."); } - 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); } unsigned long outStart = this->data->stream->total_out; this->data->stream->next_out = buffer + offset; - this->data->stream->avail_out = (uInt)length; + this->data->stream->avail_out = (uInt) length; // Call ZLib and then process the resulting data to figure out what happened. - int result = ::inflate( this->data->stream, this->data->flush ); + int result = ::inflate(this->data->stream, this->data->flush); - if( result == Z_STREAM_END ) { + if (result == Z_STREAM_END) { this->data->finished = true; - } else if( result == Z_NEED_DICT ) { + } else if (result == Z_NEED_DICT) { - if( this->needsDictionary() ) { + if (this->needsDictionary()) { throw DataFormatException( - __FILE__, __LINE__, "Inflate cannot proceed until a Dictionary is set." ); + __FILE__, __LINE__, "Inflate cannot proceed until a Dictionary is set."); } this->data->needDictionary = true; - } else if( result == Z_DATA_ERROR ) { + } else if (result == Z_DATA_ERROR) { throw DataFormatException( - __FILE__, __LINE__, "Inflate failed because a block of invalid data was found." ); + __FILE__, __LINE__, "Inflate failed because a block of invalid data was found."); } - return (int)( this->data->stream->total_out - outStart ); + return (int) (this->data->stream->total_out - outStart); } - DECAF_CATCH_RETHROW( NullPointerException ) - DECAF_CATCH_RETHROW( IndexOutOfBoundsException ) - DECAF_CATCH_RETHROW( DataFormatException ) - DECAF_CATCH_RETHROW( IllegalStateException ) - DECAF_CATCHALL_THROW( IllegalStateException ) + DECAF_CATCH_RETHROW(NullPointerException) + DECAF_CATCH_RETHROW(IndexOutOfBoundsException) + DECAF_CATCH_RETHROW(DataFormatException) + DECAF_CATCH_RETHROW(IllegalStateException) + DECAF_CATCHALL_THROW(IllegalStateException) } //////////////////////////////////////////////////////////////////////////////// -int Inflater::inflate( std::vector& buffer, int offset, int length ) { +int Inflater::inflate(std::vector& buffer, int offset, int length) { - if( buffer.empty() ) { + if (buffer.empty()) { return 0; } - return this->inflate( &buffer[0], (int)buffer.size(), offset, length ); + return this->inflate(&buffer[0], (int) buffer.size(), offset, length); } //////////////////////////////////////////////////////////////////////////////// -int Inflater::inflate( std::vector& buffer ) { +int Inflater::inflate(std::vector& buffer) { - if( buffer.empty() ) { + if (buffer.empty()) { return 0; } - return this->inflate( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() ); + return this->inflate(&buffer[0], (int) buffer.size(), 0, (int) buffer.size()); } //////////////////////////////////////////////////////////////////////////////// long long Inflater::getAdler() const { - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Inflater has already been ended." ); + __FILE__, __LINE__, "The Inflater has already been ended."); } return this->data->stream->adler; @@ -390,9 +389,9 @@ long long Inflater::getAdler() const { //////////////////////////////////////////////////////////////////////////////// long long Inflater::getBytesRead() const { - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Inflater has already been ended." ); + __FILE__, __LINE__, "The Inflater has already been ended."); } return this->data->stream->total_in; @@ -401,9 +400,9 @@ long long Inflater::getBytesRead() const { //////////////////////////////////////////////////////////////////////////////// long long Inflater::getBytesWritten() const { - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Inflater has already been ended." ); + __FILE__, __LINE__, "The Inflater has already been ended."); } return this->data->stream->total_out; @@ -412,18 +411,18 @@ long long Inflater::getBytesWritten() const { //////////////////////////////////////////////////////////////////////////////// void Inflater::reset() { - if( this->data->stream == NULL ) { + if (this->data->stream == NULL) { throw IllegalStateException( - __FILE__, __LINE__, "The Inflater has already been ended." ); + __FILE__, __LINE__, "The Inflater has already been ended."); } - InflaterData::resetZlibStream( this->data ); + InflaterData::resetZlibStream(this->data); } //////////////////////////////////////////////////////////////////////////////// void Inflater::end() { - if( this->data ) { - InflaterData::finishZlibDeflate( this->data ); + if (this->data) { + InflaterData::finishZlibDeflate(this->data); } }