update boost on linux
This commit is contained in:
@@ -17,11 +17,11 @@
|
||||
#include <iterator> // advance.
|
||||
#include <list>
|
||||
#include <memory> // allocator, auto_ptr or unique_ptr.
|
||||
#include <typeinfo>
|
||||
#include <stdexcept> // logic_error, out_of_range.
|
||||
#include <boost/checked_delete.hpp>
|
||||
#include <boost/config.hpp> // BOOST_MSVC, template friends,
|
||||
#include <boost/detail/workaround.hpp> // BOOST_NESTED_TEMPLATE
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/iostreams/constants.hpp>
|
||||
#include <boost/iostreams/detail/access_control.hpp>
|
||||
#include <boost/iostreams/detail/char_traits.hpp>
|
||||
@@ -164,7 +164,7 @@ public:
|
||||
|
||||
//----------Direct component access---------------------------------------//
|
||||
|
||||
const std::type_info& component_type(int n) const
|
||||
const boost::core::typeinfo& component_type(int n) const
|
||||
{
|
||||
if (static_cast<size_type>(n) >= size())
|
||||
boost::throw_exception(std::out_of_range("bad chain offset"));
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
|
||||
// Deprecated.
|
||||
template<int N>
|
||||
const std::type_info& component_type() const { return component_type(N); }
|
||||
const boost::core::typeinfo& component_type() const { return component_type(N); }
|
||||
|
||||
template<typename T>
|
||||
T* component(int n) const { return component(n, boost::type<T>()); }
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
if (static_cast<size_type>(n) >= size())
|
||||
boost::throw_exception(std::out_of_range("bad chain offset"));
|
||||
streambuf_type* link = *boost::next(list().begin(), n);
|
||||
if (BOOST_IOSTREAMS_COMPARE_TYPE_ID(link->component_type(), typeid(T)))
|
||||
if (BOOST_IOSTREAMS_COMPARE_TYPE_ID(link->component_type(), BOOST_CORE_TYPEID(T)))
|
||||
return static_cast<T*>(link->component_impl());
|
||||
else
|
||||
return 0;
|
||||
@@ -455,12 +455,12 @@ public:
|
||||
chain_client(chain_client* client) : chain_(client->chain_) { }
|
||||
virtual ~chain_client() { }
|
||||
|
||||
const std::type_info& component_type(int n) const
|
||||
const boost::core::typeinfo& component_type(int n) const
|
||||
{ return chain_->component_type(n); }
|
||||
|
||||
// Deprecated.
|
||||
template<int N>
|
||||
const std::type_info& component_type() const
|
||||
const boost::core::typeinfo& component_type() const
|
||||
{ return chain_->BOOST_NESTED_TEMPLATE component_type<N>(); }
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -58,6 +58,7 @@ protected:
|
||||
explicit direct_adapter_base(const Direct& d);
|
||||
typedef is_convertible<category, two_sequence> is_double;
|
||||
struct pointers {
|
||||
pointers() : beg(0), ptr(0), end(0) { }
|
||||
char_type *beg, *ptr, *end;
|
||||
};
|
||||
void init_input(mpl::true_);
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
{
|
||||
std::streamsize result = 0;
|
||||
while (result < n) {
|
||||
std::streamsize amt = iostreams::read(device_, s, n);
|
||||
std::streamsize amt = iostreams::read(device_, s + result, n - result);
|
||||
if (amt == -1)
|
||||
break;
|
||||
result += amt;
|
||||
@@ -41,6 +41,9 @@ public:
|
||||
while (result < n) {
|
||||
std::streamsize amt =
|
||||
iostreams::write(device_, s + result, n - result);
|
||||
// write errors, like EOF on read, need to be handled.
|
||||
if (amt == -1)
|
||||
break;
|
||||
result += amt;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -39,10 +39,16 @@ template< typename Ch,
|
||||
class basic_buffer {
|
||||
private:
|
||||
#ifndef BOOST_NO_STD_ALLOCATOR
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef typename Alloc::template rebind<Ch>::other allocator_type;
|
||||
#else
|
||||
typedef typename std::allocator_traits<Alloc>::template rebind_alloc<Ch> allocator_type;
|
||||
typedef std::allocator_traits<allocator_type> allocator_traits;
|
||||
#endif
|
||||
#else
|
||||
typedef std::allocator<Ch> allocator_type;
|
||||
#endif
|
||||
static Ch* allocate(std::streamsize buffer_size);
|
||||
public:
|
||||
basic_buffer();
|
||||
basic_buffer(std::streamsize buffer_size);
|
||||
@@ -144,10 +150,22 @@ void swap(buffer<Ch, Alloc>& lhs, buffer<Ch, Alloc>& rhs)
|
||||
template<typename Ch, typename Alloc>
|
||||
basic_buffer<Ch, Alloc>::basic_buffer() : buf_(0), size_(0) { }
|
||||
|
||||
template<typename Ch, typename Alloc>
|
||||
inline Ch* basic_buffer<Ch, Alloc>::allocate(std::streamsize buffer_size)
|
||||
{
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_NO_STD_ALLOCATOR)
|
||||
return static_cast<Ch*>(allocator_type().allocate(
|
||||
static_cast<BOOST_DEDUCED_TYPENAME Alloc::size_type>(buffer_size), 0));
|
||||
#else
|
||||
allocator_type alloc;
|
||||
return static_cast<Ch*>(allocator_traits::allocate(alloc,
|
||||
static_cast<BOOST_DEDUCED_TYPENAME allocator_traits::size_type>(buffer_size)));
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename Ch, typename Alloc>
|
||||
basic_buffer<Ch, Alloc>::basic_buffer(std::streamsize buffer_size)
|
||||
: buf_(static_cast<Ch*>(allocator_type().allocate(
|
||||
static_cast<BOOST_DEDUCED_TYPENAME Alloc::size_type>(buffer_size), 0))),
|
||||
: buf_(allocate(buffer_size)),
|
||||
size_(buffer_size) // Cast for SunPro 5.3.
|
||||
{ }
|
||||
|
||||
@@ -155,8 +173,14 @@ template<typename Ch, typename Alloc>
|
||||
inline basic_buffer<Ch, Alloc>::~basic_buffer()
|
||||
{
|
||||
if (buf_) {
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_NO_STD_ALLOCATOR)
|
||||
allocator_type().deallocate(buf_,
|
||||
static_cast<BOOST_DEDUCED_TYPENAME Alloc::size_type>(size_));
|
||||
#else
|
||||
allocator_type alloc;
|
||||
allocator_traits::deallocate(alloc, buf_,
|
||||
static_cast<BOOST_DEDUCED_TYPENAME allocator_traits::size_type>(size_));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +205,7 @@ void basic_buffer<Ch, Alloc>::swap(basic_buffer& rhs)
|
||||
|
||||
template<typename Ch, typename Alloc>
|
||||
buffer<Ch, Alloc>::buffer(std::streamsize buffer_size)
|
||||
: basic_buffer<Ch, Alloc>(buffer_size) { }
|
||||
: basic_buffer<Ch, Alloc>(buffer_size), ptr_(data()), eptr_(data() + buffer_size) { }
|
||||
|
||||
template<typename Ch, typename Alloc>
|
||||
inline void buffer<Ch, Alloc>::set(std::streamsize ptr, std::streamsize end)
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
//------------------Normalize codecvt::length---------------------------------//
|
||||
|
||||
#if !defined(__MSL_CPP__) && !defined(__LIBCOMO__) && \
|
||||
#if !defined(__MSL_CPP__) && !defined(__LIBCOMO__) && !defined(__clang__) && \
|
||||
(!defined(BOOST_RWSTD_VER) || BOOST_RWSTD_VER < 0x04010300) && \
|
||||
(!defined(__MACH__) || !defined(__INTEL_COMPILER))
|
||||
/**/
|
||||
|
||||
@@ -27,7 +27,16 @@
|
||||
# else
|
||||
# define BOOST_IOSTREAMS_DECL __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
//--------------Enable dynamic linking for non-windows---------------------//
|
||||
#else // BOOST_HAS_DECLSPEC
|
||||
# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_IOSTREAMS_DYN_LINK)
|
||||
# ifdef BOOST_IOSTREAMS_SOURCE
|
||||
# define BOOST_IOSTREAMS_DECL BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define BOOST_IOSTREAMS_DECL BOOST_SYMBOL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_DECL
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Distributed under the Boost Software License, Version 1.0.(See accompanying
|
||||
* Distributed under the Boost Software License, Version 1.0.(See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
|
||||
*
|
||||
*
|
||||
* See http://www.boost.org/libs/iostreams for documentation.
|
||||
|
||||
* File: boost/iostreams/detail/execute.hpp
|
||||
@@ -11,7 +11,7 @@
|
||||
* Contact: turkanis at coderage dot com
|
||||
*
|
||||
* Defines the preprocessor symbol BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS for
|
||||
* platforms that use the implementation of std::fpos from the Dinkumware
|
||||
* platforms that use the implementation of std::fpos from the Dinkumware
|
||||
* Standard Library.
|
||||
*/
|
||||
|
||||
@@ -25,9 +25,10 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
# if (defined(_YVALS) || defined(_CPPLIB_VER)) && !defined(__SGI_STL_PORT) && \
|
||||
!defined(_STLPORT_VERSION) && !defined(__QNX__) && !defined(_VX_CPU)
|
||||
!defined(_STLPORT_VERSION) && !defined(__QNX__) && !defined(_VX_CPU) && !defined(__VXWORKS__) \
|
||||
&& !((defined(BOOST_MSVC) || defined(BOOST_CLANG)) && _MSVC_STL_VERSION >= 141)
|
||||
/**/
|
||||
|
||||
|
||||
#include <boost/iostreams/detail/ios.hpp>
|
||||
|
||||
# define BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
|
||||
|
||||
@@ -44,8 +44,7 @@
|
||||
//------------------Locale support--------------------------------------------//
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_NO_LOCALE
|
||||
# if defined(BOOST_NO_STD_LOCALE) || \
|
||||
defined(__CYGWIN__) && \
|
||||
# if defined(BOOST_NO_STD_LOCALE) && \
|
||||
( !defined(__MSL_CPP__) || defined(_MSL_NO_WCHART_CPP_SUPPORT) ) \
|
||||
/**/
|
||||
# define BOOST_IOSTREAMS_NO_LOCALE
|
||||
|
||||
@@ -478,4 +478,6 @@ BOOST_IOSTREAMS_RESTRICT(T& t, stream_offset off, stream_offset len = -1)
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
# include <boost/iostreams/detail/config/enable_warnings.hpp>
|
||||
|
||||
#endif // #if !defined(BOOST_IOSTREAMS_RESTRICT_IMPL_HPP_INCLUDED) ...
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstddef>
|
||||
#include <typeinfo>
|
||||
#include <utility> // pair.
|
||||
#include <boost/config.hpp> // BOOST_DEDUCED_TYPENAME,
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/iostreams/detail/char_traits.hpp> // member template friends.
|
||||
#include <boost/iostreams/detail/config/wide_streams.hpp>
|
||||
#include <boost/iostreams/detail/error.hpp>
|
||||
@@ -74,7 +74,7 @@ protected:
|
||||
|
||||
// Declared in linked_streambuf.
|
||||
void close_impl(BOOST_IOS::openmode m);
|
||||
const std::type_info& component_type() const { return typeid(T); }
|
||||
const boost::core::typeinfo& component_type() const { return BOOST_CORE_TYPEID(T); }
|
||||
void* component_impl() { return component(); }
|
||||
#ifdef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES
|
||||
public:
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
#include <algorithm> // min, max.
|
||||
#include <cassert>
|
||||
#include <exception>
|
||||
#include <typeinfo>
|
||||
#include <boost/config.hpp> // Member template friends.
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/iostreams/constants.hpp>
|
||||
#include <boost/iostreams/detail/adapter/concept_adapter.hpp>
|
||||
#include <boost/iostreams/detail/buffer.hpp>
|
||||
@@ -94,7 +94,7 @@ protected:
|
||||
// Declared in linked_streambuf.
|
||||
void set_next(streambuf_type* next);
|
||||
void close_impl(BOOST_IOS::openmode m);
|
||||
const std::type_info& component_type() const { return typeid(T); }
|
||||
const boost::core::typeinfo& component_type() const { return BOOST_CORE_TYPEID(T); }
|
||||
void* component_impl() { return component(); }
|
||||
private:
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <typeinfo>
|
||||
#include <boost/config.hpp> // member template friends.
|
||||
#include <boost/core/typeinfo.hpp>
|
||||
#include <boost/iostreams/detail/char_traits.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // openmode.
|
||||
#include <boost/iostreams/detail/streambuf.hpp>
|
||||
@@ -91,7 +91,7 @@ protected:
|
||||
virtual bool auto_close() const = 0;
|
||||
virtual void set_auto_close(bool) = 0;
|
||||
virtual bool strict_sync() = 0;
|
||||
virtual const std::type_info& component_type() const = 0;
|
||||
virtual const boost::core::typeinfo& component_type() const = 0;
|
||||
virtual void* component_impl() = 0;
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
private:
|
||||
|
||||
@@ -123,7 +123,11 @@ namespace detail {
|
||||
template<typename Alloc>
|
||||
struct bzip2_allocator_traits {
|
||||
#ifndef BOOST_NO_STD_ALLOCATOR
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef typename Alloc::template rebind<char>::other type;
|
||||
#else
|
||||
typedef typename std::allocator_traits<Alloc>::template rebind_alloc<char> type;
|
||||
#endif
|
||||
#else
|
||||
typedef std::allocator<char> type;
|
||||
#endif
|
||||
@@ -134,7 +138,11 @@ template< typename Alloc,
|
||||
BOOST_DEDUCED_TYPENAME bzip2_allocator_traits<Alloc>::type >
|
||||
struct bzip2_allocator : private Base {
|
||||
private:
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_NO_STD_ALLOCATOR)
|
||||
typedef typename Base::size_type size_type;
|
||||
#else
|
||||
typedef typename std::allocator_traits<Base>::size_type size_type;
|
||||
#endif
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, custom =
|
||||
(!is_same<std::allocator<char>, Base>::value));
|
||||
@@ -167,6 +175,7 @@ protected:
|
||||
int check_end(const char* src_begin, const char* dest_begin);
|
||||
int compress(int action);
|
||||
int decompress();
|
||||
int end(bool compress, std::nothrow_t);
|
||||
void end(bool compress);
|
||||
private:
|
||||
void do_init( bool compress,
|
||||
@@ -193,6 +202,7 @@ class bzip2_compressor_impl
|
||||
{
|
||||
public:
|
||||
bzip2_compressor_impl(const bzip2_params&);
|
||||
~bzip2_compressor_impl();
|
||||
bool filter( const char*& src_begin, const char* src_end,
|
||||
char*& dest_begin, char* dest_end, bool flush );
|
||||
void close();
|
||||
@@ -216,6 +226,7 @@ class bzip2_decompressor_impl
|
||||
{
|
||||
public:
|
||||
bzip2_decompressor_impl(bool small = bzip2::default_small);
|
||||
~bzip2_decompressor_impl();
|
||||
bool filter( const char*& begin_in, const char* end_in,
|
||||
char*& begin_out, char* end_out, bool flush );
|
||||
void close();
|
||||
@@ -305,6 +316,10 @@ template<typename Alloc>
|
||||
bzip2_compressor_impl<Alloc>::bzip2_compressor_impl(const bzip2_params& p)
|
||||
: bzip2_base(p), eof_(false) { }
|
||||
|
||||
template<typename Alloc>
|
||||
bzip2_compressor_impl<Alloc>::~bzip2_compressor_impl()
|
||||
{ (void) bzip2_base::end(true, std::nothrow); }
|
||||
|
||||
template<typename Alloc>
|
||||
bool bzip2_compressor_impl<Alloc>::filter
|
||||
( const char*& src_begin, const char* src_end,
|
||||
@@ -341,6 +356,10 @@ template<typename Alloc>
|
||||
bzip2_decompressor_impl<Alloc>::bzip2_decompressor_impl(bool small)
|
||||
: bzip2_base(bzip2_params(small)), eof_(false) { }
|
||||
|
||||
template<typename Alloc>
|
||||
bzip2_decompressor_impl<Alloc>::~bzip2_decompressor_impl()
|
||||
{ (void) bzip2_base::end(false, std::nothrow); }
|
||||
|
||||
template<typename Alloc>
|
||||
bool bzip2_decompressor_impl<Alloc>::filter
|
||||
( const char*& src_begin, const char* src_end,
|
||||
|
||||
@@ -671,7 +671,7 @@ basic_gzip_compressor<Alloc>::basic_gzip_compressor
|
||||
0 );
|
||||
header_.reserve(length);
|
||||
header_ += gzip::magic::id1; // ID1.
|
||||
header_ += gzip::magic::id2; // ID2.
|
||||
header_ += static_cast<char>(gzip::magic::id2); // ID2.
|
||||
header_ += gzip::method::deflate; // CM.
|
||||
header_ += static_cast<char>(flags); // FLG.
|
||||
header_ += static_cast<char>(0xFF & p.mtime); // MTIME.
|
||||
|
||||
372
linx64/include/boost/iostreams/filter/lzma.hpp
Normal file
372
linx64/include/boost/iostreams/filter/lzma.hpp
Normal file
@@ -0,0 +1,372 @@
|
||||
// (C) Copyright Milan Svoboda 2008.
|
||||
// Originally developed under the fusecompress project.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
|
||||
|
||||
// See http://www.boost.org/libs/iostreams for documentation.
|
||||
|
||||
// Note: custom allocators are not supported on VC6, since that compiler
|
||||
// had trouble finding the function lzma_base::do_init.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_LZMA_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_LZMA_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
#include <iosfwd> // streamsize.
|
||||
#include <memory> // allocator, bad_alloc.
|
||||
#include <new>
|
||||
#include <boost/config.hpp> // MSVC, STATIC_CONSTANT, DEDUCED_TYPENAME, DINKUM.
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/iostreams/constants.hpp> // buffer size.
|
||||
#include <boost/iostreams/detail/config/auto_link.hpp>
|
||||
#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>
|
||||
|
||||
// Must come last.
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4251 4231 4660) // Dependencies not exported.
|
||||
#endif
|
||||
#include <boost/config/abi_prefix.hpp>
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
namespace lzma {
|
||||
|
||||
typedef void* (*alloc_func)(void*, size_t, size_t);
|
||||
typedef void (*free_func)(void*, void*);
|
||||
|
||||
// Compression levels
|
||||
|
||||
BOOST_IOSTREAMS_DECL extern const uint32_t no_compression;
|
||||
BOOST_IOSTREAMS_DECL extern const uint32_t best_speed;
|
||||
BOOST_IOSTREAMS_DECL extern const uint32_t best_compression;
|
||||
BOOST_IOSTREAMS_DECL extern const uint32_t default_compression;
|
||||
|
||||
// Status codes
|
||||
|
||||
BOOST_IOSTREAMS_DECL extern const int okay;
|
||||
BOOST_IOSTREAMS_DECL extern const int stream_end;
|
||||
BOOST_IOSTREAMS_DECL extern const int unsupported_check;
|
||||
BOOST_IOSTREAMS_DECL extern const int mem_error;
|
||||
BOOST_IOSTREAMS_DECL extern const int options_error;
|
||||
BOOST_IOSTREAMS_DECL extern const int data_error;
|
||||
BOOST_IOSTREAMS_DECL extern const int buf_error;
|
||||
BOOST_IOSTREAMS_DECL extern const int prog_error;
|
||||
|
||||
// Flush codes
|
||||
|
||||
BOOST_IOSTREAMS_DECL extern const int finish;
|
||||
BOOST_IOSTREAMS_DECL extern const int full_flush;
|
||||
BOOST_IOSTREAMS_DECL extern const int sync_flush;
|
||||
BOOST_IOSTREAMS_DECL extern const int run;
|
||||
|
||||
// Code for current OS
|
||||
|
||||
// Null pointer constant.
|
||||
|
||||
const int null = 0;
|
||||
|
||||
// Default values
|
||||
|
||||
} // End namespace lzma.
|
||||
|
||||
//
|
||||
// Class name: lzma_params.
|
||||
// Description: Encapsulates the parameters passed to lzmadec_init
|
||||
// to customize compression and decompression.
|
||||
//
|
||||
struct lzma_params {
|
||||
|
||||
// Non-explicit constructor.
|
||||
lzma_params( uint32_t level = lzma::default_compression )
|
||||
: level(level)
|
||||
{ }
|
||||
uint32_t level;
|
||||
};
|
||||
|
||||
//
|
||||
// Class name: lzma_error.
|
||||
// Description: Subclass of std::ios::failure thrown to indicate
|
||||
// lzma errors other than out-of-memory conditions.
|
||||
//
|
||||
class BOOST_IOSTREAMS_DECL lzma_error : public BOOST_IOSTREAMS_FAILURE {
|
||||
public:
|
||||
explicit lzma_error(int error);
|
||||
int error() const { return error_; }
|
||||
static void check BOOST_PREVENT_MACRO_SUBSTITUTION(int error);
|
||||
private:
|
||||
int error_;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename Alloc>
|
||||
struct lzma_allocator_traits {
|
||||
#ifndef BOOST_NO_STD_ALLOCATOR
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef typename Alloc::template rebind<char>::other type;
|
||||
#else
|
||||
typedef typename std::allocator_traits<Alloc>::template rebind_alloc<char> type;
|
||||
#endif
|
||||
#else
|
||||
typedef std::allocator<char> type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template< typename Alloc,
|
||||
typename Base = // VC6 workaround (C2516)
|
||||
BOOST_DEDUCED_TYPENAME lzma_allocator_traits<Alloc>::type >
|
||||
struct lzma_allocator : private Base {
|
||||
private:
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_NO_STD_ALLOCATOR)
|
||||
typedef typename Base::size_type size_type;
|
||||
#else
|
||||
typedef typename std::allocator_traits<Base>::size_type size_type;
|
||||
#endif
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, custom =
|
||||
(!is_same<std::allocator<char>, Base>::value));
|
||||
typedef typename lzma_allocator_traits<Alloc>::type allocator_type;
|
||||
static void* allocate(void* self, size_t items, size_t size);
|
||||
static void deallocate(void* self, void* address);
|
||||
};
|
||||
|
||||
class BOOST_IOSTREAMS_DECL lzma_base {
|
||||
public:
|
||||
typedef char char_type;
|
||||
protected:
|
||||
lzma_base();
|
||||
~lzma_base();
|
||||
void* stream() { return stream_; }
|
||||
template<typename Alloc>
|
||||
void init( const lzma_params& p,
|
||||
bool compress,
|
||||
lzma_allocator<Alloc>& zalloc )
|
||||
{
|
||||
bool custom = lzma_allocator<Alloc>::custom;
|
||||
do_init( p, compress,
|
||||
custom ? lzma_allocator<Alloc>::allocate : 0,
|
||||
custom ? lzma_allocator<Alloc>::deallocate : 0,
|
||||
&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,
|
||||
bool compress );
|
||||
int deflate(int action);
|
||||
int inflate(int action);
|
||||
void reset(bool compress, bool realloc);
|
||||
private:
|
||||
void do_init( const lzma_params& p, bool compress,
|
||||
lzma::alloc_func,
|
||||
lzma::free_func,
|
||||
void* derived );
|
||||
void* stream_; // Actual type: lzmadec_stream*.
|
||||
uint32_t level;
|
||||
};
|
||||
|
||||
//
|
||||
// Template name: lzma_compressor_impl
|
||||
// Description: Model of C-Style Filter implementing compression by
|
||||
// delegating to the lzma function deflate.
|
||||
//
|
||||
template<typename Alloc = std::allocator<char> >
|
||||
class lzma_compressor_impl : public lzma_base, public lzma_allocator<Alloc> {
|
||||
public:
|
||||
lzma_compressor_impl(const lzma_params& = lzma::default_compression);
|
||||
~lzma_compressor_impl();
|
||||
bool filter( const char*& src_begin, const char* src_end,
|
||||
char*& dest_begin, char* dest_end, bool flush );
|
||||
void close();
|
||||
};
|
||||
|
||||
//
|
||||
// Template name: lzma_compressor_impl
|
||||
// Description: Model of C-Style Filte implementing decompression by
|
||||
// delegating to the lzma function inflate.
|
||||
//
|
||||
template<typename Alloc = std::allocator<char> >
|
||||
class lzma_decompressor_impl : public lzma_base, public lzma_allocator<Alloc> {
|
||||
public:
|
||||
lzma_decompressor_impl(const lzma_params&);
|
||||
lzma_decompressor_impl();
|
||||
~lzma_decompressor_impl();
|
||||
bool filter( const char*& begin_in, const char* end_in,
|
||||
char*& begin_out, char* end_out, bool flush );
|
||||
void close();
|
||||
};
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
//
|
||||
// Template name: lzma_compressor
|
||||
// Description: Model of InputFilter and OutputFilter implementing
|
||||
// compression using lzma.
|
||||
//
|
||||
template<typename Alloc = std::allocator<char> >
|
||||
struct basic_lzma_compressor
|
||||
: symmetric_filter<detail::lzma_compressor_impl<Alloc>, Alloc>
|
||||
{
|
||||
private:
|
||||
typedef detail::lzma_compressor_impl<Alloc> impl_type;
|
||||
typedef symmetric_filter<impl_type, Alloc> base_type;
|
||||
public:
|
||||
typedef typename base_type::char_type char_type;
|
||||
typedef typename base_type::category category;
|
||||
basic_lzma_compressor( const lzma_params& = lzma::default_compression,
|
||||
std::streamsize buffer_size = default_device_buffer_size );
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(basic_lzma_compressor, 1)
|
||||
|
||||
typedef basic_lzma_compressor<> lzma_compressor;
|
||||
|
||||
//
|
||||
// Template name: lzma_decompressor
|
||||
// Description: Model of InputFilter and OutputFilter implementing
|
||||
// decompression using lzma.
|
||||
//
|
||||
template<typename Alloc = std::allocator<char> >
|
||||
struct basic_lzma_decompressor
|
||||
: symmetric_filter<detail::lzma_decompressor_impl<Alloc>, Alloc>
|
||||
{
|
||||
private:
|
||||
typedef detail::lzma_decompressor_impl<Alloc> impl_type;
|
||||
typedef symmetric_filter<impl_type, Alloc> base_type;
|
||||
public:
|
||||
typedef typename base_type::char_type char_type;
|
||||
typedef typename base_type::category category;
|
||||
basic_lzma_decompressor( std::streamsize buffer_size = default_device_buffer_size );
|
||||
basic_lzma_decompressor( const lzma_params& p,
|
||||
std::streamsize buffer_size = default_device_buffer_size );
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(basic_lzma_decompressor, 1)
|
||||
|
||||
typedef basic_lzma_decompressor<> lzma_decompressor;
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
//------------------Implementation of lzma_allocator--------------------------//
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename Alloc, typename Base>
|
||||
void* lzma_allocator<Alloc, Base>::allocate
|
||||
(void* self, size_t items, size_t size)
|
||||
{
|
||||
size_type len = items * size;
|
||||
char* ptr =
|
||||
static_cast<allocator_type*>(self)->allocate
|
||||
(len + sizeof(size_type)
|
||||
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
|
||||
, (char*)0
|
||||
#endif
|
||||
);
|
||||
*reinterpret_cast<size_type*>(ptr) = len;
|
||||
return ptr + sizeof(size_type);
|
||||
}
|
||||
|
||||
template<typename Alloc, typename Base>
|
||||
void lzma_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);
|
||||
}
|
||||
|
||||
//------------------Implementation of lzma_compressor_impl--------------------//
|
||||
|
||||
template<typename Alloc>
|
||||
lzma_compressor_impl<Alloc>::lzma_compressor_impl(const lzma_params& p)
|
||||
{ init(p, true, static_cast<lzma_allocator<Alloc>&>(*this)); }
|
||||
|
||||
template<typename Alloc>
|
||||
lzma_compressor_impl<Alloc>::~lzma_compressor_impl()
|
||||
{ reset(true, false); }
|
||||
|
||||
template<typename Alloc>
|
||||
bool lzma_compressor_impl<Alloc>::filter
|
||||
( const char*& src_begin, const char* src_end,
|
||||
char*& dest_begin, char* dest_end, bool flush )
|
||||
{
|
||||
before(src_begin, src_end, dest_begin, dest_end);
|
||||
int result = deflate(flush ? lzma::finish : lzma::run);
|
||||
after(src_begin, dest_begin, true);
|
||||
lzma_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(result);
|
||||
return result != lzma::stream_end;
|
||||
}
|
||||
|
||||
template<typename Alloc>
|
||||
void lzma_compressor_impl<Alloc>::close() { reset(true, true); }
|
||||
|
||||
//------------------Implementation of lzma_decompressor_impl------------------//
|
||||
|
||||
template<typename Alloc>
|
||||
lzma_decompressor_impl<Alloc>::lzma_decompressor_impl(const lzma_params& p)
|
||||
{ init(p, false, static_cast<lzma_allocator<Alloc>&>(*this)); }
|
||||
|
||||
template<typename Alloc>
|
||||
lzma_decompressor_impl<Alloc>::~lzma_decompressor_impl()
|
||||
{ reset(false, false); }
|
||||
|
||||
template<typename Alloc>
|
||||
lzma_decompressor_impl<Alloc>::lzma_decompressor_impl()
|
||||
{
|
||||
lzma_params p;
|
||||
init(p, false, static_cast<lzma_allocator<Alloc>&>(*this));
|
||||
}
|
||||
|
||||
template<typename Alloc>
|
||||
bool lzma_decompressor_impl<Alloc>::filter
|
||||
( const char*& src_begin, const char* src_end,
|
||||
char*& dest_begin, char* dest_end, bool flush )
|
||||
{
|
||||
before(src_begin, src_end, dest_begin, dest_end);
|
||||
int result = inflate(flush ? lzma::finish : lzma::run);
|
||||
after(src_begin, dest_begin, false);
|
||||
lzma_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(result);
|
||||
return result != lzma::stream_end;
|
||||
}
|
||||
|
||||
template<typename Alloc>
|
||||
void lzma_decompressor_impl<Alloc>::close() { reset(false, true); }
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
//------------------Implementation of lzma_compressor-----------------------//
|
||||
|
||||
template<typename Alloc>
|
||||
basic_lzma_compressor<Alloc>::basic_lzma_compressor
|
||||
(const lzma_params& p, std::streamsize buffer_size)
|
||||
: base_type(buffer_size, p) { }
|
||||
|
||||
//------------------Implementation of lzma_decompressor-----------------------//
|
||||
|
||||
template<typename Alloc>
|
||||
basic_lzma_decompressor<Alloc>::basic_lzma_decompressor
|
||||
(std::streamsize buffer_size)
|
||||
: base_type(buffer_size) { }
|
||||
|
||||
template<typename Alloc>
|
||||
basic_lzma_decompressor<Alloc>::basic_lzma_decompressor
|
||||
(const lzma_params& p, std::streamsize buffer_size)
|
||||
: base_type(buffer_size, p) { }
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#include <boost/config/abi_suffix.hpp> // Pops abi_suffix.hpp pragmas.
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_LZMA_HPP_INCLUDED
|
||||
@@ -58,7 +58,7 @@ private:
|
||||
return;
|
||||
iterator first(&src[0], &src[0] + src.size(), re_, flags_);
|
||||
iterator last;
|
||||
const Ch* suffix = &src[0];
|
||||
const Ch* suffix = 0;
|
||||
for (; first != last; ++first) {
|
||||
dest.insert( dest.end(),
|
||||
first->prefix().first,
|
||||
|
||||
@@ -149,7 +149,11 @@ namespace detail {
|
||||
template<typename Alloc>
|
||||
struct zlib_allocator_traits {
|
||||
#ifndef BOOST_NO_STD_ALLOCATOR
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef typename Alloc::template rebind<char>::other type;
|
||||
#else
|
||||
typedef typename std::allocator_traits<Alloc>::template rebind_alloc<char> type;
|
||||
#endif
|
||||
#else
|
||||
typedef std::allocator<char> type;
|
||||
#endif
|
||||
@@ -160,7 +164,11 @@ template< typename Alloc,
|
||||
BOOST_DEDUCED_TYPENAME zlib_allocator_traits<Alloc>::type >
|
||||
struct zlib_allocator : private Base {
|
||||
private:
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_NO_STD_ALLOCATOR)
|
||||
typedef typename Base::size_type size_type;
|
||||
#else
|
||||
typedef typename std::allocator_traits<Base>::size_type size_type;
|
||||
#endif
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, custom =
|
||||
(!is_same<std::allocator<char>, Base>::value));
|
||||
|
||||
363
linx64/include/boost/iostreams/filter/zstd.hpp
Normal file
363
linx64/include/boost/iostreams/filter/zstd.hpp
Normal file
@@ -0,0 +1,363 @@
|
||||
// (C) Copyright Reimar Döffinger 2018.
|
||||
// Based on zstd.hpp by:
|
||||
// (C) Copyright Milan Svoboda 2008.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
|
||||
|
||||
// See http://www.boost.org/libs/iostreams for documentation.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_ZSTD_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_ZSTD_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
#include <iosfwd> // streamsize.
|
||||
#include <memory> // allocator, bad_alloc.
|
||||
#include <new>
|
||||
#include <boost/config.hpp> // MSVC, STATIC_CONSTANT, DEDUCED_TYPENAME, DINKUM.
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/iostreams/constants.hpp> // buffer size.
|
||||
#include <boost/iostreams/detail/config/auto_link.hpp>
|
||||
#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>
|
||||
|
||||
// Must come last.
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4251 4231 4660) // Dependencies not exported.
|
||||
#endif
|
||||
#include <boost/config/abi_prefix.hpp>
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
namespace zstd {
|
||||
|
||||
typedef void* (*alloc_func)(void*, size_t, size_t);
|
||||
typedef void (*free_func)(void*, void*);
|
||||
|
||||
// Compression levels
|
||||
|
||||
BOOST_IOSTREAMS_DECL extern const uint32_t best_speed;
|
||||
BOOST_IOSTREAMS_DECL extern const uint32_t best_compression;
|
||||
BOOST_IOSTREAMS_DECL extern const uint32_t default_compression;
|
||||
|
||||
// Status codes
|
||||
|
||||
BOOST_IOSTREAMS_DECL extern const int okay;
|
||||
BOOST_IOSTREAMS_DECL extern const int stream_end;
|
||||
|
||||
// Flush codes
|
||||
|
||||
BOOST_IOSTREAMS_DECL extern const int finish;
|
||||
BOOST_IOSTREAMS_DECL extern const int flush;
|
||||
BOOST_IOSTREAMS_DECL extern const int run;
|
||||
|
||||
// Code for current OS
|
||||
|
||||
// Null pointer constant.
|
||||
|
||||
const int null = 0;
|
||||
|
||||
// Default values
|
||||
|
||||
} // End namespace zstd.
|
||||
|
||||
//
|
||||
// Class name: zstd_params.
|
||||
// Description: Encapsulates the parameters passed to zstddec_init
|
||||
// to customize compression and decompression.
|
||||
//
|
||||
struct zstd_params {
|
||||
|
||||
// Non-explicit constructor.
|
||||
zstd_params( uint32_t level = zstd::default_compression )
|
||||
: level(level)
|
||||
{ }
|
||||
uint32_t level;
|
||||
};
|
||||
|
||||
//
|
||||
// Class name: zstd_error.
|
||||
// Description: Subclass of std::ios::failure thrown to indicate
|
||||
// zstd errors other than out-of-memory conditions.
|
||||
//
|
||||
class BOOST_IOSTREAMS_DECL zstd_error : public BOOST_IOSTREAMS_FAILURE {
|
||||
public:
|
||||
explicit zstd_error(size_t error);
|
||||
int error() const { return error_; }
|
||||
static void check BOOST_PREVENT_MACRO_SUBSTITUTION(size_t error);
|
||||
private:
|
||||
size_t error_;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename Alloc>
|
||||
struct zstd_allocator_traits {
|
||||
#ifndef BOOST_NO_STD_ALLOCATOR
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef typename Alloc::template rebind<char>::other type;
|
||||
#else
|
||||
typedef typename std::allocator_traits<Alloc>::template rebind_alloc<char> type;
|
||||
#endif
|
||||
#else
|
||||
typedef std::allocator<char> type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template< typename Alloc,
|
||||
typename Base = // VC6 workaround (C2516)
|
||||
BOOST_DEDUCED_TYPENAME zstd_allocator_traits<Alloc>::type >
|
||||
struct zstd_allocator : private Base {
|
||||
private:
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_NO_STD_ALLOCATOR)
|
||||
typedef typename Base::size_type size_type;
|
||||
#else
|
||||
typedef typename std::allocator_traits<Base>::size_type size_type;
|
||||
#endif
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT(bool, custom =
|
||||
(!is_same<std::allocator<char>, Base>::value));
|
||||
typedef typename zstd_allocator_traits<Alloc>::type allocator_type;
|
||||
static void* allocate(void* self, size_t items, size_t size);
|
||||
static void deallocate(void* self, void* address);
|
||||
};
|
||||
|
||||
class BOOST_IOSTREAMS_DECL zstd_base {
|
||||
public:
|
||||
typedef char char_type;
|
||||
protected:
|
||||
zstd_base();
|
||||
~zstd_base();
|
||||
template<typename Alloc>
|
||||
void init( const zstd_params& p,
|
||||
bool compress,
|
||||
zstd_allocator<Alloc>& zalloc )
|
||||
{
|
||||
bool custom = zstd_allocator<Alloc>::custom;
|
||||
do_init( p, compress,
|
||||
custom ? zstd_allocator<Alloc>::allocate : 0,
|
||||
custom ? zstd_allocator<Alloc>::deallocate : 0,
|
||||
&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,
|
||||
bool compress );
|
||||
int deflate(int action);
|
||||
int inflate(int action);
|
||||
void reset(bool compress, bool realloc);
|
||||
private:
|
||||
void do_init( const zstd_params& p, bool compress,
|
||||
zstd::alloc_func,
|
||||
zstd::free_func,
|
||||
void* derived );
|
||||
void* cstream_; // Actual type: ZSTD_CStream *
|
||||
void* dstream_; // Actual type: ZSTD_DStream *
|
||||
void* in_; // Actual type: ZSTD_inBuffer *
|
||||
void* out_; // Actual type: ZSTD_outBuffer *
|
||||
int eof_;
|
||||
uint32_t level;
|
||||
};
|
||||
|
||||
//
|
||||
// Template name: zstd_compressor_impl
|
||||
// Description: Model of C-Style Filter implementing compression by
|
||||
// delegating to the zstd function deflate.
|
||||
//
|
||||
template<typename Alloc = std::allocator<char> >
|
||||
class zstd_compressor_impl : public zstd_base, public zstd_allocator<Alloc> {
|
||||
public:
|
||||
zstd_compressor_impl(const zstd_params& = zstd::default_compression);
|
||||
~zstd_compressor_impl();
|
||||
bool filter( const char*& src_begin, const char* src_end,
|
||||
char*& dest_begin, char* dest_end, bool flush );
|
||||
void close();
|
||||
};
|
||||
|
||||
//
|
||||
// Template name: zstd_compressor_impl
|
||||
// Description: Model of C-Style Filte implementing decompression by
|
||||
// delegating to the zstd function inflate.
|
||||
//
|
||||
template<typename Alloc = std::allocator<char> >
|
||||
class zstd_decompressor_impl : public zstd_base, public zstd_allocator<Alloc> {
|
||||
public:
|
||||
zstd_decompressor_impl(const zstd_params&);
|
||||
zstd_decompressor_impl();
|
||||
~zstd_decompressor_impl();
|
||||
bool filter( const char*& begin_in, const char* end_in,
|
||||
char*& begin_out, char* end_out, bool flush );
|
||||
void close();
|
||||
};
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
//
|
||||
// Template name: zstd_compressor
|
||||
// Description: Model of InputFilter and OutputFilter implementing
|
||||
// compression using zstd.
|
||||
//
|
||||
template<typename Alloc = std::allocator<char> >
|
||||
struct basic_zstd_compressor
|
||||
: symmetric_filter<detail::zstd_compressor_impl<Alloc>, Alloc>
|
||||
{
|
||||
private:
|
||||
typedef detail::zstd_compressor_impl<Alloc> impl_type;
|
||||
typedef symmetric_filter<impl_type, Alloc> base_type;
|
||||
public:
|
||||
typedef typename base_type::char_type char_type;
|
||||
typedef typename base_type::category category;
|
||||
basic_zstd_compressor( const zstd_params& = zstd::default_compression,
|
||||
std::streamsize buffer_size = default_device_buffer_size );
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(basic_zstd_compressor, 1)
|
||||
|
||||
typedef basic_zstd_compressor<> zstd_compressor;
|
||||
|
||||
//
|
||||
// Template name: zstd_decompressor
|
||||
// Description: Model of InputFilter and OutputFilter implementing
|
||||
// decompression using zstd.
|
||||
//
|
||||
template<typename Alloc = std::allocator<char> >
|
||||
struct basic_zstd_decompressor
|
||||
: symmetric_filter<detail::zstd_decompressor_impl<Alloc>, Alloc>
|
||||
{
|
||||
private:
|
||||
typedef detail::zstd_decompressor_impl<Alloc> impl_type;
|
||||
typedef symmetric_filter<impl_type, Alloc> base_type;
|
||||
public:
|
||||
typedef typename base_type::char_type char_type;
|
||||
typedef typename base_type::category category;
|
||||
basic_zstd_decompressor( std::streamsize buffer_size = default_device_buffer_size );
|
||||
basic_zstd_decompressor( const zstd_params& p,
|
||||
std::streamsize buffer_size = default_device_buffer_size );
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(basic_zstd_decompressor, 1)
|
||||
|
||||
typedef basic_zstd_decompressor<> zstd_decompressor;
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
//------------------Implementation of zstd_allocator--------------------------//
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename Alloc, typename Base>
|
||||
void* zstd_allocator<Alloc, Base>::allocate
|
||||
(void* self, size_t items, size_t size)
|
||||
{
|
||||
size_type len = items * size;
|
||||
char* ptr =
|
||||
static_cast<allocator_type*>(self)->allocate
|
||||
(len + sizeof(size_type)
|
||||
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
|
||||
, (char*)0
|
||||
#endif
|
||||
);
|
||||
*reinterpret_cast<size_type*>(ptr) = len;
|
||||
return ptr + sizeof(size_type);
|
||||
}
|
||||
|
||||
template<typename Alloc, typename Base>
|
||||
void zstd_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);
|
||||
}
|
||||
|
||||
//------------------Implementation of zstd_compressor_impl--------------------//
|
||||
|
||||
template<typename Alloc>
|
||||
zstd_compressor_impl<Alloc>::zstd_compressor_impl(const zstd_params& p)
|
||||
{ init(p, true, static_cast<zstd_allocator<Alloc>&>(*this)); }
|
||||
|
||||
template<typename Alloc>
|
||||
zstd_compressor_impl<Alloc>::~zstd_compressor_impl()
|
||||
{ reset(true, false); }
|
||||
|
||||
template<typename Alloc>
|
||||
bool zstd_compressor_impl<Alloc>::filter
|
||||
( const char*& src_begin, const char* src_end,
|
||||
char*& dest_begin, char* dest_end, bool flush )
|
||||
{
|
||||
before(src_begin, src_end, dest_begin, dest_end);
|
||||
int result = deflate(flush ? zstd::finish : zstd::run);
|
||||
after(src_begin, dest_begin, true);
|
||||
return result != zstd::stream_end;
|
||||
}
|
||||
|
||||
template<typename Alloc>
|
||||
void zstd_compressor_impl<Alloc>::close() { reset(true, true); }
|
||||
|
||||
//------------------Implementation of zstd_decompressor_impl------------------//
|
||||
|
||||
template<typename Alloc>
|
||||
zstd_decompressor_impl<Alloc>::zstd_decompressor_impl(const zstd_params& p)
|
||||
{ init(p, false, static_cast<zstd_allocator<Alloc>&>(*this)); }
|
||||
|
||||
template<typename Alloc>
|
||||
zstd_decompressor_impl<Alloc>::~zstd_decompressor_impl()
|
||||
{ reset(false, false); }
|
||||
|
||||
template<typename Alloc>
|
||||
zstd_decompressor_impl<Alloc>::zstd_decompressor_impl()
|
||||
{
|
||||
zstd_params p;
|
||||
init(p, false, static_cast<zstd_allocator<Alloc>&>(*this));
|
||||
}
|
||||
|
||||
template<typename Alloc>
|
||||
bool zstd_decompressor_impl<Alloc>::filter
|
||||
( const char*& src_begin, const char* src_end,
|
||||
char*& dest_begin, char* dest_end, bool flush )
|
||||
{
|
||||
before(src_begin, src_end, dest_begin, dest_end);
|
||||
int result = inflate(flush ? zstd::finish : zstd::run);
|
||||
after(src_begin, dest_begin, false);
|
||||
return result != zstd::stream_end;
|
||||
}
|
||||
|
||||
template<typename Alloc>
|
||||
void zstd_decompressor_impl<Alloc>::close() { reset(false, true); }
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
//------------------Implementation of zstd_compressor-----------------------//
|
||||
|
||||
template<typename Alloc>
|
||||
basic_zstd_compressor<Alloc>::basic_zstd_compressor
|
||||
(const zstd_params& p, std::streamsize buffer_size)
|
||||
: base_type(buffer_size, p) { }
|
||||
|
||||
//------------------Implementation of zstd_decompressor-----------------------//
|
||||
|
||||
template<typename Alloc>
|
||||
basic_zstd_decompressor<Alloc>::basic_zstd_decompressor
|
||||
(std::streamsize buffer_size)
|
||||
: base_type(buffer_size) { }
|
||||
|
||||
template<typename Alloc>
|
||||
basic_zstd_decompressor<Alloc>::basic_zstd_decompressor
|
||||
(const zstd_params& p, std::streamsize buffer_size)
|
||||
: base_type(buffer_size, p) { }
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#include <boost/config/abi_suffix.hpp> // Pops abi_suffix.hpp pragmas.
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_ZSTD_HPP_INCLUDED
|
||||
@@ -62,6 +62,12 @@ struct filtering_stream_traits {
|
||||
>::type stream_tag;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
|
||||
# pragma warning(push)
|
||||
// https://connect.microsoft.com/VisualStudio/feedback/details/733720/
|
||||
# pragma warning(disable: 4250)
|
||||
#endif
|
||||
|
||||
template<typename Chain, typename Access>
|
||||
class filtering_stream_base
|
||||
: public access_control<
|
||||
@@ -93,6 +99,10 @@ private:
|
||||
Chain chain_;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
//
|
||||
@@ -149,9 +159,20 @@ private:
|
||||
{ client_type::push(t BOOST_IOSTREAMS_PUSH_ARGS()); } \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
|
||||
# pragma warning(push)
|
||||
// https://connect.microsoft.com/VisualStudio/feedback/details/733720/
|
||||
# pragma warning(disable: 4250)
|
||||
#endif
|
||||
|
||||
BOOST_IOSTREAMS_DEFINE_FILTER_STREAM(filtering_stream, boost::iostreams::chain, char)
|
||||
BOOST_IOSTREAMS_DEFINE_FILTER_STREAM(wfiltering_stream, boost::iostreams::chain, wchar_t)
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
typedef filtering_stream<input> filtering_istream;
|
||||
typedef filtering_stream<output> filtering_ostream;
|
||||
typedef wfiltering_stream<input> filtering_wistream;
|
||||
|
||||
@@ -56,6 +56,12 @@ struct stream_traits {
|
||||
>::type stream_tag;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
|
||||
# pragma warning(push)
|
||||
// https://connect.microsoft.com/VisualStudio/feedback/details/733720/
|
||||
# pragma warning(disable: 4250)
|
||||
#endif
|
||||
|
||||
// By encapsulating initialization in a base, we can define the macro
|
||||
// BOOST_IOSTREAMS_DEFINE_FORWARDING_FUNCTIONS to generate constructors
|
||||
// without base member initializer lists.
|
||||
@@ -84,6 +90,10 @@ public:
|
||||
stream_base() : pbase_type(), stream_type(&member) { }
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
#ifdef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
|
||||
@@ -92,6 +102,12 @@ public:
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
|
||||
# pragma warning(push)
|
||||
// https://connect.microsoft.com/VisualStudio/feedback/details/733720/
|
||||
# pragma warning(disable: 4250)
|
||||
#endif
|
||||
|
||||
//
|
||||
// Template name: stream.
|
||||
// Description: A iostream which reads from and writes to an instance of a
|
||||
@@ -144,6 +160,10 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#endif // #ifdef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
|
||||
|
||||
Reference in New Issue
Block a user