-#include <deal.II/base/config.h>
-#ifndef DEAL_II_WITH_BZIP2
-# error "You cannot use this header file since your system does not have a complete installation of libbz2"
-#endif
-
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
// (C) Copyright 2003-2007 Jonathan Turkanis
// Distributed under the Boost Software License, Version 1.0. (See accompanying
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
-
-#include <cassert>
+
+#include <cassert>
#include <memory> // allocator.
#include <new> // bad_alloc.
#include <boost/config.hpp> // MSVC, STATIC_CONSTANT, DEDUCED_TYPENAME, DINKUM.
#include <boost/iostreams/detail/config/dyn_link.hpp>
#include <boost/iostreams/detail/config/wide_streams.hpp>
#include <boost/iostreams/detail/ios.hpp> // failure, streamsize.
-#include <boost/iostreams/filter/symmetric.hpp>
-#include <boost/iostreams/pipeline.hpp>
-#include <boost/type_traits/is_same.hpp>
+#include <boost/iostreams/filter/symmetric.hpp>
+#include <boost/iostreams/pipeline.hpp>
+#include <boost/type_traits/is_same.hpp>
// Must come last.
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable:4251 4231 4660)
#endif
-#include <boost/config/abi_prefix.hpp>
+#include <boost/config/abi_prefix.hpp>
// Temporary fix.
#undef small
BOOST_IOSTREAMS_DECL extern const int run_ok;
BOOST_IOSTREAMS_DECL extern const int flush_ok;
BOOST_IOSTREAMS_DECL extern const int finish_ok;
-BOOST_IOSTREAMS_DECL extern const int stream_end;
+BOOST_IOSTREAMS_DECL extern const int stream_end;
BOOST_IOSTREAMS_DECL extern const int sequence_error;
BOOST_IOSTREAMS_DECL extern const int param_error;
BOOST_IOSTREAMS_DECL extern const int mem_error;
const int default_work_factor = 30;
const bool default_small = false;
-} // End namespace bzip2.
+} // End namespace bzip2.
//
// Class name: bzip2_params.
private:
typedef typename Base::size_type size_type;
public:
- BOOST_STATIC_CONSTANT(bool, custom =
+ BOOST_STATIC_CONSTANT(bool, custom =
(!is_same<std::allocator<char>, Base>::value));
typedef typename bzip2_allocator_traits<Alloc>::type allocator_type;
static void* allocate(void* self, int items, int size);
static void deallocate(void* self, void* address);
};
-class BOOST_IOSTREAMS_DECL bzip2_base {
+class BOOST_IOSTREAMS_DECL bzip2_base {
public:
typedef char char_type;
protected:
~bzip2_base();
bzip2_params& params() { return params_; }
bool& ready() { return ready_; }
- template<typename Alloc>
+ template<typename Alloc>
void init( bool compress,
bzip2_allocator<Alloc>& alloc )
{
int decompress();
void end(bool compress);
private:
- void do_init( bool compress,
+ void do_init( bool compress,
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
- bzip2::alloc_func,
- bzip2::free_func,
+ bzip2::alloc_func,
+ bzip2::free_func,
#endif
void* derived );
bzip2_params params_;
// delegating to the libbzip2 function BZ_bzCompress.
//
template<typename Alloc = std::allocator<char> >
-class bzip2_compressor_impl
- : public bzip2_base,
+class bzip2_compressor_impl
+ : public bzip2_base,
#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
public
#endif
- bzip2_allocator<Alloc>
+ bzip2_allocator<Alloc>
{
-public:
+public:
bzip2_compressor_impl(const bzip2_params&);
bool filter( const char*& src_begin, const char* src_end,
char*& dest_begin, char* dest_end, bool flush );
// delegating to the libbzip2 function BZ_bzDecompress.
//
template<typename Alloc = std::allocator<char> >
-class bzip2_decompressor_impl
- : public bzip2_base,
+class bzip2_decompressor_impl
+ : public bzip2_base,
#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
public
#endif
- bzip2_allocator<Alloc>
-{
+ bzip2_allocator<Alloc>
+{
public:
bzip2_decompressor_impl(bool small = bzip2::default_small);
bool filter( const char*& begin_in, const char* end_in,
// compression using libbzip2.
//
template<typename Alloc = std::allocator<char> >
-struct basic_bzip2_compressor
- : symmetric_filter<detail::bzip2_compressor_impl<Alloc>, Alloc>
+struct basic_bzip2_compressor
+ : symmetric_filter<detail::bzip2_compressor_impl<Alloc>, Alloc>
{
private:
typedef detail::bzip2_compressor_impl<Alloc> impl_type;
public:
typedef typename base_type::char_type char_type;
typedef typename base_type::category category;
- basic_bzip2_compressor( const bzip2_params& = bzip2::default_block_size,
+ basic_bzip2_compressor( const bzip2_params& = bzip2::default_block_size,
int buffer_size = default_device_buffer_size );
};
BOOST_IOSTREAMS_PIPABLE(basic_bzip2_compressor, 1)
// decompression using libbzip2.
//
template<typename Alloc = std::allocator<char> >
-struct basic_bzip2_decompressor
- : symmetric_filter<detail::bzip2_decompressor_impl<Alloc>, Alloc>
+struct basic_bzip2_decompressor
+ : symmetric_filter<detail::bzip2_decompressor_impl<Alloc>, Alloc>
{
private:
typedef detail::bzip2_decompressor_impl<Alloc> impl_type;
template<typename Alloc, typename Base>
void* bzip2_allocator<Alloc, Base>::allocate(void* self, int items, int size)
-{
+{
size_type len = items * size;
- char* ptr =
+ char* ptr =
static_cast<allocator_type*>(self)->allocate
(len + sizeof(size_type)
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
template<typename Alloc, typename Base>
void bzip2_allocator<Alloc, Base>::deallocate(void* self, void* address)
-{
+{
char* ptr = reinterpret_cast<char*>(address) - sizeof(size_type);
size_type len = *reinterpret_cast<size_type*>(ptr) + sizeof(size_type);
- static_cast<allocator_type*>(self)->deallocate(ptr, len);
+ static_cast<allocator_type*>(self)->deallocate(ptr, len);
}
//------------------Implementation of bzip2_compressor_impl-------------------//
}
template<typename Alloc>
-void bzip2_compressor_impl<Alloc>::close()
-{
+void bzip2_compressor_impl<Alloc>::close()
+{
try {
end(true);
- } catch (...) {
- eof_ = false;
+ } catch (...) {
+ eof_ = false;
throw;
}
eof_ = false;
}
template<typename Alloc>
-inline void bzip2_compressor_impl<Alloc>::init()
+inline void bzip2_compressor_impl<Alloc>::init()
{ bzip2_base::init(true, static_cast<bzip2_allocator<Alloc>&>(*this)); }
//------------------Implementation of bzip2_decompressor_impl-----------------//
else
close();
}
- if (!ready())
+ if (!ready())
init();
before(src_begin, src_end, dest_begin, dest_end);
int result = decompress();
after(src_begin, dest_begin);
bzip2_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(result);
eof_ = result == bzip2::stream_end;
- return true;
+ return true;
}
template<typename Alloc>
-void bzip2_decompressor_impl<Alloc>::close()
-{
+void bzip2_decompressor_impl<Alloc>::close()
+{
try {
end(false);
- } catch (...) {
- eof_ = false;
+ } catch (...) {
+ eof_ = false;
throw;
}
eof_ = false;
template<typename Alloc>
basic_bzip2_compressor<Alloc>::basic_bzip2_compressor
- (const bzip2_params& p, int buffer_size)
- : base_type(buffer_size, p)
+ (const bzip2_params& p, int buffer_size)
+ : base_type(buffer_size, p)
{ }
//------------------Implementation of bzip2_decompressor----------------------//
template<typename Alloc>
basic_bzip2_decompressor<Alloc>::basic_bzip2_decompressor
- (bool small, int buffer_size)
+ (bool small, int buffer_size)
: base_type(buffer_size, small)
{ }
-#include <deal.II/base/config.h>
-#ifndef DEAL_II_WITH_ZLIB
-# error "You cannot use this header file since your system does not have a complete installation of zlib"
-#endif
-
-
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
// (C) Copyright 2003-2007 Jonathan Turkanis
// Distributed under the Boost Software License, Version 1.0. (See accompanying
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
-#endif
+#endif
-#include <cassert>
-#include <iosfwd> // streamsize.
+#include <cassert>
+#include <iosfwd> // streamsize.
#include <memory> // allocator, bad_alloc.
-#include <new>
+#include <new>
#include <boost/config.hpp> // MSVC, STATIC_CONSTANT, DEDUCED_TYPENAME, DINKUM.
#include <boost/cstdint.hpp> // uint*_t
#include <boost/detail/workaround.hpp>
#include <boost/iostreams/detail/config/wide_streams.hpp>
#include <boost/iostreams/detail/config/zlib.hpp>
#include <boost/iostreams/detail/ios.hpp> // failure, streamsize.
-#include <boost/iostreams/filter/symmetric.hpp>
-#include <boost/iostreams/pipeline.hpp>
+#include <boost/iostreams/filter/symmetric.hpp>
+#include <boost/iostreams/pipeline.hpp>
#include <boost/type_traits/is_same.hpp>
// Must come last.
# pragma warning(push)
# pragma warning(disable:4251 4231 4660) // Dependencies not exported.
#endif
-#include <boost/config/abi_prefix.hpp>
+#include <boost/config/abi_prefix.hpp>
namespace boost { namespace iostreams {
const bool default_crc = false;
const bool default_noheader = false;
-} // End namespace zlib.
+} // End namespace zlib.
//
// Class name: zlib_params.
// Non-explicit constructor.
zlib_params( int level = zlib::default_compression,
int method = zlib::deflated,
- int window_bits = zlib::default_window_bits,
- int mem_level = zlib::default_mem_level,
+ int window_bits = zlib::default_window_bits,
+ int mem_level = zlib::default_mem_level,
int strategy = zlib::default_strategy,
bool noheader = zlib::default_noheader,
bool calculate_crc = zlib::default_crc )
: level(level), method(method), window_bits(window_bits),
- mem_level(mem_level), strategy(strategy),
+ mem_level(mem_level), strategy(strategy),
noheader(noheader), calculate_crc(calculate_crc)
{ }
int level;
private:
typedef typename Base::size_type size_type;
public:
- BOOST_STATIC_CONSTANT(bool, custom =
+ BOOST_STATIC_CONSTANT(bool, custom =
(!is_same<std::allocator<char>, Base>::value));
typedef typename zlib_allocator_traits<Alloc>::type allocator_type;
static void* allocate(void* self, zlib::uint items, zlib::uint size);
static void deallocate(void* self, void* address);
};
-class BOOST_IOSTREAMS_DECL zlib_base {
+class BOOST_IOSTREAMS_DECL zlib_base {
public:
typedef char char_type;
protected:
zlib_base();
~zlib_base();
void* stream() { return stream_; }
- template<typename Alloc>
- void init( const zlib_params& p,
+ template<typename Alloc>
+ void init( const zlib_params& p,
bool compress,
zlib_allocator<Alloc>& zalloc )
{
}
void before( const char*& src_begin, const char* src_end,
char*& dest_begin, char* dest_end );
- void after( const char*& src_begin, char*& dest_begin,
+ void after( const char*& src_begin, char*& dest_begin,
bool compress );
- int xdeflate(int flush); // Prefix 'x' prevents symbols from being
+ int xdeflate(int flush); // Prefix 'x' prevents symbols from being
int xinflate(int flush); // redefined when Z_PREFIX is defined
void reset(bool compress, bool realloc);
public:
int total_in() const { return total_in_; }
int total_out() const { return total_out_; }
private:
- void do_init( const zlib_params& p, bool compress,
+ void do_init( const zlib_params& p, bool compress,
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
- zlib::xalloc_func,
- zlib::xfree_func,
+ zlib::xalloc_func,
+ zlib::xfree_func,
#endif
void* derived );
void* stream_; // Actual type: z_stream*.
// delegating to the zlib function deflate.
//
template<typename Alloc = std::allocator<char> >
-class zlib_compressor_impl : public zlib_base, public zlib_allocator<Alloc> {
-public:
+class zlib_compressor_impl : public zlib_base, public zlib_allocator<Alloc> {
+public:
zlib_compressor_impl(const zlib_params& = zlib::default_compression);
~zlib_compressor_impl();
bool filter( const char*& src_begin, const char* src_end,
// compression using zlib.
//
template<typename Alloc = std::allocator<char> >
-struct basic_zlib_compressor
- : symmetric_filter<detail::zlib_compressor_impl<Alloc>, Alloc>
+struct basic_zlib_compressor
+ : symmetric_filter<detail::zlib_compressor_impl<Alloc>, Alloc>
{
private:
typedef detail::zlib_compressor_impl<Alloc> impl_type;
public:
typedef typename base_type::char_type char_type;
typedef typename base_type::category category;
- basic_zlib_compressor( const zlib_params& = zlib::default_compression,
+ basic_zlib_compressor( const zlib_params& = zlib::default_compression,
int buffer_size = default_device_buffer_size );
zlib::ulong crc() { return this->filter().crc(); }
int total_in() { return this->filter().total_in(); }
// decompression using zlib.
//
template<typename Alloc = std::allocator<char> >
-struct basic_zlib_decompressor
- : symmetric_filter<detail::zlib_decompressor_impl<Alloc>, Alloc>
+struct basic_zlib_decompressor
+ : symmetric_filter<detail::zlib_decompressor_impl<Alloc>, Alloc>
{
private:
typedef detail::zlib_decompressor_impl<Alloc> impl_type;
template<typename Alloc, typename Base>
void* zlib_allocator<Alloc, Base>::allocate
(void* self, zlib::uint items, zlib::uint size)
-{
+{
size_type len = items * size;
- char* ptr =
+ char* ptr =
static_cast<allocator_type*>(self)->allocate
(len + sizeof(size_type)
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
template<typename Alloc, typename Base>
void zlib_allocator<Alloc, Base>::deallocate(void* self, void* address)
-{
+{
char* ptr = reinterpret_cast<char*>(address) - sizeof(size_type);
size_type len = *reinterpret_cast<size_type*>(ptr) + sizeof(size_type);
- static_cast<allocator_type*>(self)->deallocate(ptr, len);
+ static_cast<allocator_type*>(self)->deallocate(ptr, len);
}
//------------------Implementation of zlib_compressor_impl--------------------//
int result = xdeflate(flush ? zlib::finish : zlib::no_flush);
after(src_begin, dest_begin, true);
zlib_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(result);
- return result != zlib::stream_end;
+ return result != zlib::stream_end;
}
template<typename Alloc>
template<typename Alloc>
zlib_decompressor_impl<Alloc>::zlib_decompressor_impl(int window_bits)
-{
+{
zlib_params p;
p.window_bits = window_bits;
- init(p, false, static_cast<zlib_allocator<Alloc>&>(*this));
+ init(p, false, static_cast<zlib_allocator<Alloc>&>(*this));
}
template<typename Alloc>
template<typename Alloc>
basic_zlib_compressor<Alloc>::basic_zlib_compressor
- (const zlib_params& p, int buffer_size)
+ (const zlib_params& p, int buffer_size)
: base_type(buffer_size, p) { }
//------------------Implementation of zlib_decompressor-----------------------//
template<typename Alloc>
basic_zlib_decompressor<Alloc>::basic_zlib_decompressor
- (int window_bits, int buffer_size)
+ (int window_bits, int buffer_size)
: base_type(buffer_size, window_bits) { }
template<typename Alloc>
basic_zlib_decompressor<Alloc>::basic_zlib_decompressor
- (const zlib_params& p, int buffer_size)
+ (const zlib_params& p, int buffer_size)
: base_type(buffer_size, p) { }
//----------------------------------------------------------------------------//