Formatting cleanup.
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 @@
class Arrays {
private:
- Arrays( const Arrays& source );
- Arrays& operator= ( const Arrays& source );
+ Arrays(const Arrays& source);
+ Arrays& operator=(const Arrays& source);
private:
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 @@
////////////////////////////////////////////////////////////////////////////////
void Adler32::reset() {
- this->value = adler32( (uLong)this->value, NULL, 0 );
+ this->value = adler32((uLong) this->value, NULL, 0);
}
////////////////////////////////////////////////////////////////////////////////
@@ -45,42 +45,42 @@
}
////////////////////////////////////////////////////////////////////////////////
-void Adler32::update( const std::vector<unsigned char>& buffer ) {
- this->update( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() );
+void Adler32::update(const std::vector<unsigned char>& buffer) {
+ this->update(&buffer[0], (int) buffer.size(), 0, (int) buffer.size());
}
////////////////////////////////////////////////////////////////////////////////
-void Adler32::update( const std::vector<unsigned char>& buffer, int offset, int length ) {
- this->update( &buffer[0], (int)buffer.size(), offset, length );
+void Adler32::update(const std::vector<unsigned char>& 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);
}
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 @@
* @param buffer
* The buffer to read the updated bytes from.
*/
- virtual void update( const std::vector<unsigned char>& buffer );
+ virtual void update(const std::vector<unsigned char>& buffer);
/**
* Updates the current checksum with the specified array of bytes.
@@ -72,7 +72,7 @@
*
* @throw IndexOutOfBoundsException if offset + length > size of the buffer.
*/
- virtual void update( const std::vector<unsigned char>& buffer, int offset, int length );
+ virtual void update(const std::vector<unsigned char>& buffer, int offset, int length);
/**
* Updates the current checksum with the specified array of bytes.
@@ -89,7 +89,7 @@
* @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 @@
* @param byte
* The byte value to update the current Checksum with (0..255).
*/
- virtual void update( int byte );
+ virtual void update(int byte);
};
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 @@
////////////////////////////////////////////////////////////////////////////////
void CRC32::reset() {
- this->value = crc32( (uLong)this->value, NULL, 0 );
+ this->value = crc32((uLong) this->value, NULL, 0);
}
////////////////////////////////////////////////////////////////////////////////
@@ -45,36 +45,33 @@
}
////////////////////////////////////////////////////////////////////////////////
-void CRC32::update( const std::vector<unsigned char>& buffer ) {
- this->update( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() );
+void CRC32::update(const std::vector<unsigned char>& buffer) {
+ this->update(&buffer[0], (int) buffer.size(), 0, (int) buffer.size());
}
////////////////////////////////////////////////////////////////////////////////
-void CRC32::update( const std::vector<unsigned char>& buffer, int offset, int length ) {
+void CRC32::update(const std::vector<unsigned char>& 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);
}
-
-
-
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 @@
virtual ~CRC32();
/**
- * @returns the current checksum value.
+ * @return the current checksum value.
*/
virtual long long getValue() const;
@@ -57,7 +57,7 @@
* @param buffer
* The buffer to read the updated bytes from.
*/
- virtual void update( const std::vector<unsigned char>& buffer );
+ virtual void update(const std::vector<unsigned char>& buffer);
/**
* Updates the current checksum with the specified array of bytes.
@@ -88,7 +88,7 @@
* @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 @@
* @param byte
* The byte value to update the current Checksum with (0..255).
*/
- virtual void update( int byte );
+ virtual void update(int byte);
};
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::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 @@
}
////////////////////////////////////////////////////////////////////////////////
-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<unsigned char> buffer( remaining );
+ std::vector<unsigned char> 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)
}
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 @@
private:
- CheckedInputStream( const CheckedInputStream& );
- CheckedInputStream& operator= ( const CheckedInputStream& );
+ CheckedInputStream(const CheckedInputStream&);
+ CheckedInputStream& operator=(const CheckedInputStream&);
public:
@@ -59,7 +59,7 @@
*
* @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 @@
*
* 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);
};
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::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 @@
}
////////////////////////////////////////////////////////////////////////////////
-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)
}
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 @@
private:
- CheckedOutputStream( const CheckedOutputStream& );
- CheckedOutputStream& operator= ( const CheckedOutputStream& );
+ CheckedOutputStream(const CheckedOutputStream&);
+ CheckedOutputStream& operator=(const CheckedOutputStream&);
public:
@@ -58,7 +58,7 @@
*
* @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 @@
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);
};
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 @@
* @param buffer
* The buffer to read the updated bytes from.
*/
- virtual void update( const std::vector<unsigned char>& buffer ) = 0;
+ virtual void update(const std::vector<unsigned char>& buffer) = 0;
/**
* Updates the current checksum with the specified array of bytes.
@@ -69,7 +69,7 @@
*
* @throw IndexOutOfBoundsException if offset + length > size of the buffer.
*/
- virtual void update( const std::vector<unsigned char>& buffer, int offset, int length ) = 0;
+ virtual void update(const std::vector<unsigned char>& buffer, int offset, int length) = 0;
/**
* Updates the current checksum with the specified array of bytes.
@@ -86,7 +86,7 @@
* @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 @@
* @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;
};
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::zip;
////////////////////////////////////////////////////////////////////////////////
-namespace decaf{
-namespace util{
-namespace zip{
+namespace decaf {
+namespace util {
+namespace zip {
class DeflaterData {
public:
@@ -48,8 +48,8 @@
private:
- DeflaterData( const DeflaterData& );
- DeflaterData& operator= ( const DeflaterData& );
+ DeflaterData(const DeflaterData&);
+ DeflaterData& operator=(const DeflaterData&);
public:
@@ -64,11 +64,11 @@
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 @@
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::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<unsigned char>& buffer, int offset, int length ) {
-
- this->setInput( &buffer[0], (int)buffer.size(), offset, length );
+void Deflater::setInput(const std::vector<unsigned char>& buffer, int offset, int length) {
+ this->setInput(&buffer[0], (int) buffer.size(), offset, length);
}
////////////////////////////////////////////////////////////////////////////////
-void Deflater::setInput( const std::vector<unsigned char>& buffer ) {
+void Deflater::setInput(const std::vector<unsigned char>& 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 @@
// (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<unsigned char>& buffer, int offset, int length ) {
-
- this->setDictionary( &buffer[0], (int)buffer.size(), offset, length );
+void Deflater::setDictionary(const std::vector<unsigned char>& buffer, int offset, int length) {
+ this->setDictionary(&buffer[0], (int) buffer.size(), offset, length);
}
////////////////////////////////////////////////////////////////////////////////
-void Deflater::setDictionary( const std::vector<unsigned char>& buffer ) {
+void Deflater::setDictionary(const std::vector<unsigned char>& 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 @@
////////////////////////////////////////////////////////////////////////////////
bool Deflater::needsInput() const {
- if( this->data->stream == NULL ) {
+ if (this->data->stream == NULL) {
return false;
}
@@ -345,72 +342,70 @@
}
////////////////////////////////////////////////////////////////////////////////
-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<unsigned char>& buffer, int offset, int length ) {
-
- return this->deflate( &buffer[0], (int)buffer.size(), offset, length );
+int Deflater::deflate(std::vector<unsigned char>& buffer, int offset, int length) {
+ return this->deflate(&buffer[0], (int) buffer.size(), offset, length);
}
////////////////////////////////////////////////////////////////////////////////
-int Deflater::deflate( std::vector<unsigned char>& buffer ) {
-
- return this->deflate( &buffer[0], (int)buffer.size(), 0, (int)buffer.size() );
+int Deflater::deflate(std::vector<unsigned char>& 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::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::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 @@
////////////////////////////////////////////////////////////////////////////////
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);
}
}
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 @@
private:
- Deflater( const Deflater& );
- Deflater operator= ( const Deflater& );
+ Deflater(const Deflater&);
+ Deflater operator=(const Deflater&);
public:
@@ -116,7 +116,7 @@
* @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 @@
* @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 @@
* @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 compression. This should be called whenever needsInput() returns
@@ -170,7 +170,7 @@
*
* @throws IllegalStateException if in the end state.
*/
- void setInput( const std::vector<unsigned char>& buffer );
+ void setInput(const std::vector<unsigned char>& buffer);
/**
* Sets preset dictionary for compression. A preset dictionary is used when the
@@ -191,7 +191,7 @@
* @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 @@
* @throws IndexOutOfBoundsException if the offset + length > size of the buffer.
* @throws IllegalStateException if in the end state.
*/
- 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 preset dictionary for compression. A preset dictionary is used when the
@@ -222,7 +222,7 @@
*
* @throws IllegalStateException if in the end state.
*/
- void setDictionary( const std::vector<unsigned char>& buffer );
+ void setDictionary(const std::vector<unsigned char>& buffer);
/**
* Sets the compression strategy to the specified value.
@@ -233,7 +233,7 @@
* @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 @@
* @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 @@
* @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 @@
* @throws IndexOutOfBoundsException if the offset + length > size of the buffer.
* @throws IllegalStateException if in the end state.
*/
- int deflate( std::vector<unsigned char>& buffer, int offset, int length );
+ int deflate(std::vector<unsigned char>& buffer, int offset, int length);
/**
* Fills specified buffer with compressed data. Returns actual number of bytes of
@@ -316,7 +316,7 @@
*
* @throws IllegalStateException if in the end state.
*/
- int deflate( std::vector<unsigned char>& buffer );
+ int deflate(std::vector<unsigned char>& buffer);
/**
* @returns the ADLER-32 value of the uncompressed data.
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 @@
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)
}
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 @@
private:
- DeflaterOutputStream( const DeflaterOutputStream& );
- DeflaterOutputStream& operator= ( const DeflaterOutputStream& );
+ DeflaterOutputStream(const DeflaterOutputStream&);
+ DeflaterOutputStream& operator=(const DeflaterOutputStream&);
public:
@@ -69,7 +69,7 @@
* @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 @@
*
* @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 @@
* @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 @@
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:
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 @@
private:
- InflaterData( const InflaterData& );
- InflaterData& operator= ( const InflaterData& );
+ InflaterData(const InflaterData&);
+ InflaterData& operator=(const InflaterData&);
public:
@@ -56,11 +56,11 @@
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 @@
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 @@
}}}
////////////////////////////////////////////////////////////////////////////////
-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<unsigned char>& buffer, int offset, int length ) {
+void Inflater::setInput(const std::vector<unsigned char>& 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<unsigned char>& buffer ) {
+void Inflater::setInput(const std::vector<unsigned char>& 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 @@
}
////////////////////////////////////////////////////////////////////////////////
-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 @@
// 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<unsigned char>& buffer, int offset, int length ) {
+void Inflater::setDictionary(const std::vector<unsigned char>& 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<unsigned char>& buffer ) {
+void Inflater::setDictionary(const std::vector<unsigned char>& 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 @@
}
////////////////////////////////////////////////////////////////////////////////
-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<unsigned char>& buffer, int offset, int length ) {
+int Inflater::inflate(std::vector<unsigned char>& 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<unsigned char>& buffer ) {
+int Inflater::inflate(std::vector<unsigned char>& 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::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::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 @@
////////////////////////////////////////////////////////////////////////////////
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);
}
}
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 @@
private:
- Inflater( const Inflater& );
- Inflater& operator=( const Inflater& );
+ Inflater(const Inflater&);
+ Inflater& operator=(const Inflater&);
public:
@@ -78,7 +78,7 @@
* 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 @@
* @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 @@
* @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 @@
*
* @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 @@
* @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 @@
* @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 @@
* @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 @@
* @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 @@
* @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 @@
* @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.
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 @@
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 @@
////////////////////////////////////////////////////////////////////////////////
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 @@
// 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 @@
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)
}
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 @@
private:
- InflaterInputStream( const InflaterInputStream& );
- InflaterInputStream& operator= ( const InflaterInputStream& );
+ InflaterInputStream(const InflaterInputStream&);
+ InflaterInputStream& operator=(const InflaterInputStream&);
public:
@@ -73,7 +73,7 @@
* @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 @@
*
* @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 @@
* @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 @@
*
* 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 @@
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);
};