mirror of
https://github.com/shadps4-emu/ext-boost.git
synced 2024-11-26 21:00:21 +00:00
boost: Readd and adjust libraries
* Add back variant. Turns out dynarmic needs this * Explicitely add circular_buffer. We rely on this but it was removed previously * Trim down url and iostreams libraries to what we need
This commit is contained in:
parent
4b0f33f6f9
commit
dfb313f835
106
boost/blank.hpp
Normal file
106
boost/blank.hpp
Normal file
@ -0,0 +1,106 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost blank.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003
|
||||
// Eric Friedman
|
||||
//
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_BLANK_HPP
|
||||
#define BOOST_BLANK_HPP
|
||||
|
||||
#include "boost/blank_fwd.hpp"
|
||||
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
#include <iosfwd> // for std::basic_ostream forward declare
|
||||
#include "boost/detail/templated_streams.hpp"
|
||||
#endif // BOOST_NO_IOSTREAM
|
||||
|
||||
#include "boost/type_traits/integral_constant.hpp"
|
||||
#include "boost/type_traits/is_empty.hpp"
|
||||
#include "boost/type_traits/is_pod.hpp"
|
||||
#include "boost/type_traits/is_stateless.hpp"
|
||||
|
||||
namespace boost {
|
||||
|
||||
struct blank
|
||||
{
|
||||
};
|
||||
|
||||
// type traits specializations
|
||||
//
|
||||
|
||||
template <>
|
||||
struct is_pod< blank >
|
||||
: boost::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_empty< blank >
|
||||
: boost::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_stateless< blank >
|
||||
: boost::true_type
|
||||
{
|
||||
};
|
||||
|
||||
// relational operators
|
||||
//
|
||||
|
||||
inline bool operator==(const blank&, const blank&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool operator<=(const blank&, const blank&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool operator>=(const blank&, const blank&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool operator!=(const blank&, const blank&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool operator<(const blank&, const blank&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool operator>(const blank&, const blank&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// streaming support
|
||||
//
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
BOOST_TEMPLATED_STREAM_TEMPLATE(E,T)
|
||||
inline BOOST_TEMPLATED_STREAM(ostream, E,T)& operator<<(
|
||||
BOOST_TEMPLATED_STREAM(ostream, E,T)& out
|
||||
, const blank&
|
||||
)
|
||||
{
|
||||
// (output nothing)
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_IOSTREAM
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_BLANK_HPP
|
22
boost/blank_fwd.hpp
Normal file
22
boost/blank_fwd.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost blank_fwd.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003
|
||||
// Eric Friedman
|
||||
//
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_BLANK_FWD_HPP
|
||||
#define BOOST_BLANK_FWD_HPP
|
||||
|
||||
namespace boost {
|
||||
|
||||
struct blank;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_BLANK_FWD_HPP
|
@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Glen Fernandes
|
||||
*
|
||||
* 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)
|
||||
*/
|
||||
|
||||
#ifndef BOOST_CHECKED_DELETE_HPP
|
||||
#define BOOST_CHECKED_DELETE_HPP
|
||||
|
||||
// The header file at this path is deprecated;
|
||||
// use boost/core/checked_delete.hpp instead.
|
||||
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
|
||||
#endif
|
65
boost/circular_buffer.hpp
Normal file
65
boost/circular_buffer.hpp
Normal file
@ -0,0 +1,65 @@
|
||||
// Circular buffer library header file.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
|
||||
// Use, modification, and distribution is subject to 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 www.boost.org/libs/circular_buffer for documentation.
|
||||
|
||||
/*! @file
|
||||
Includes <boost/circular_buffer/base.hpp>
|
||||
*/
|
||||
|
||||
#if !defined(BOOST_CIRCULAR_BUFFER_HPP)
|
||||
#define BOOST_CIRCULAR_BUFFER_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/circular_buffer_fwd.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
/*! Debug support control. */
|
||||
#if !defined(BOOST_CB_ENABLE_DEBUG)
|
||||
#define BOOST_CB_ENABLE_DEBUG 0
|
||||
#endif
|
||||
|
||||
/*! INTERNAL ONLY */
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#define BOOST_CB_ASSERT(Expr) BOOST_ASSERT(Expr)
|
||||
#else
|
||||
#define BOOST_CB_ASSERT(Expr) ((void)0)
|
||||
#endif
|
||||
|
||||
/*! INTERNAL ONLY */
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x0550) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
#define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) ((void)0)
|
||||
#else
|
||||
#include <iterator>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) \
|
||||
BOOST_STATIC_ASSERT((is_convertible<typename std::iterator_traits<Iterator>::value_type, Type>::value))
|
||||
#endif
|
||||
|
||||
/*! INTERNAL ONLY */
|
||||
#if defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
|
||||
#define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS BOOST_STATIC_ASSERT(false);
|
||||
#else
|
||||
#define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS ((void)0);
|
||||
#endif
|
||||
|
||||
#include <boost/circular_buffer/debug.hpp>
|
||||
#include <boost/circular_buffer/details.hpp>
|
||||
#include <boost/circular_buffer/base.hpp>
|
||||
#include <boost/circular_buffer/space_optimized.hpp>
|
||||
|
||||
#undef BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS
|
||||
#undef BOOST_CB_IS_CONVERTIBLE
|
||||
#undef BOOST_CB_ASSERT
|
||||
|
||||
#endif // #if !defined(BOOST_CIRCULAR_BUFFER_HPP)
|
3134
boost/circular_buffer/base.hpp
Normal file
3134
boost/circular_buffer/base.hpp
Normal file
File diff suppressed because it is too large
Load Diff
248
boost/circular_buffer/debug.hpp
Normal file
248
boost/circular_buffer/debug.hpp
Normal file
@ -0,0 +1,248 @@
|
||||
// Debug support for the circular buffer library.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
|
||||
// Use, modification, and distribution is subject to 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)
|
||||
|
||||
#if !defined(BOOST_CIRCULAR_BUFFER_DEBUG_HPP)
|
||||
#define BOOST_CIRCULAR_BUFFER_DEBUG_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
#include <cstring>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std {
|
||||
using ::memset;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // BOOST_CB_ENABLE_DEBUG
|
||||
namespace boost {
|
||||
|
||||
namespace cb_details {
|
||||
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
|
||||
// The value the uninitialized memory is filled with.
|
||||
const int UNINITIALIZED = 0xcc;
|
||||
|
||||
template <class T>
|
||||
inline void do_fill_uninitialized_memory(T* data, std::size_t size_in_bytes) BOOST_NOEXCEPT {
|
||||
std::memset(static_cast<void*>(data), UNINITIALIZED, size_in_bytes);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void do_fill_uninitialized_memory(T& /*data*/, std::size_t /*size_in_bytes*/) BOOST_NOEXCEPT {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
class debug_iterator_registry;
|
||||
|
||||
/*!
|
||||
\class debug_iterator_base
|
||||
\brief Registers/unregisters iterators into the registry of valid iterators.
|
||||
|
||||
This class is intended to be a base class of an iterator.
|
||||
*/
|
||||
class debug_iterator_base {
|
||||
|
||||
private:
|
||||
// Members
|
||||
|
||||
//! Iterator registry.
|
||||
mutable const debug_iterator_registry* m_registry;
|
||||
|
||||
//! Next iterator in the iterator chain.
|
||||
mutable const debug_iterator_base* m_next;
|
||||
|
||||
public:
|
||||
// Construction/destruction
|
||||
|
||||
//! Default constructor.
|
||||
debug_iterator_base();
|
||||
|
||||
//! Constructor taking the iterator registry as a parameter.
|
||||
debug_iterator_base(const debug_iterator_registry* registry);
|
||||
|
||||
//! Copy constructor.
|
||||
debug_iterator_base(const debug_iterator_base& rhs);
|
||||
|
||||
//! Destructor.
|
||||
~debug_iterator_base();
|
||||
|
||||
// Methods
|
||||
|
||||
//! Assign operator.
|
||||
debug_iterator_base& operator = (const debug_iterator_base& rhs);
|
||||
|
||||
//! Is the iterator valid?
|
||||
bool is_valid(const debug_iterator_registry* registry) const;
|
||||
|
||||
//! Invalidate the iterator.
|
||||
/*!
|
||||
\note The method is const in order to invalidate const iterators, too.
|
||||
*/
|
||||
void invalidate() const;
|
||||
|
||||
//! Return the next iterator in the iterator chain.
|
||||
const debug_iterator_base* next() const;
|
||||
|
||||
//! Set the next iterator in the iterator chain.
|
||||
/*!
|
||||
\note The method is const in order to set a next iterator to a const iterator, too.
|
||||
*/
|
||||
void set_next(const debug_iterator_base* it) const;
|
||||
|
||||
private:
|
||||
// Helpers
|
||||
|
||||
//! Register self as a valid iterator.
|
||||
void register_self();
|
||||
|
||||
//! Unregister self from valid iterators.
|
||||
void unregister_self();
|
||||
};
|
||||
|
||||
/*!
|
||||
\class debug_iterator_registry
|
||||
\brief Registry of valid iterators.
|
||||
|
||||
This class is intended to be a base class of a container.
|
||||
*/
|
||||
class debug_iterator_registry {
|
||||
|
||||
//! Pointer to the chain of valid iterators.
|
||||
mutable const debug_iterator_base* m_iterators;
|
||||
|
||||
public:
|
||||
// Methods
|
||||
|
||||
//! Default constructor.
|
||||
debug_iterator_registry() : m_iterators(0) {}
|
||||
|
||||
//! Register an iterator into the list of valid iterators.
|
||||
/*!
|
||||
\note The method is const in order to register iterators into const containers, too.
|
||||
*/
|
||||
void register_iterator(const debug_iterator_base* it) const {
|
||||
it->set_next(m_iterators);
|
||||
m_iterators = it;
|
||||
}
|
||||
|
||||
//! Unregister an iterator from the list of valid iterators.
|
||||
/*!
|
||||
\note The method is const in order to unregister iterators from const containers, too.
|
||||
*/
|
||||
void unregister_iterator(const debug_iterator_base* it) const {
|
||||
const debug_iterator_base* previous = 0;
|
||||
for (const debug_iterator_base* p = m_iterators; p != it; previous = p, p = p->next()) {}
|
||||
remove(it, previous);
|
||||
}
|
||||
|
||||
//! Invalidate every iterator pointing to the same element as the iterator passed as a parameter.
|
||||
template <class Iterator>
|
||||
void invalidate_iterators(const Iterator& it) {
|
||||
const debug_iterator_base* previous = 0;
|
||||
for (const debug_iterator_base* p = m_iterators; p != 0; p = p->next()) {
|
||||
if (((Iterator*)p)->m_it == it.m_it) {
|
||||
p->invalidate();
|
||||
remove(p, previous);
|
||||
continue;
|
||||
}
|
||||
previous = p;
|
||||
}
|
||||
}
|
||||
|
||||
//! Invalidate all iterators except an iterator poining to the same element as the iterator passed as a parameter.
|
||||
template <class Iterator>
|
||||
void invalidate_iterators_except(const Iterator& it) {
|
||||
const debug_iterator_base* previous = 0;
|
||||
for (const debug_iterator_base* p = m_iterators; p != 0; p = p->next()) {
|
||||
if (((Iterator*)p)->m_it != it.m_it) {
|
||||
p->invalidate();
|
||||
remove(p, previous);
|
||||
continue;
|
||||
}
|
||||
previous = p;
|
||||
}
|
||||
}
|
||||
|
||||
//! Invalidate all iterators.
|
||||
void invalidate_all_iterators() {
|
||||
for (const debug_iterator_base* p = m_iterators; p != 0; p = p->next())
|
||||
p->invalidate();
|
||||
m_iterators = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
// Helpers
|
||||
|
||||
//! Remove the current iterator from the iterator chain.
|
||||
void remove(const debug_iterator_base* current,
|
||||
const debug_iterator_base* previous) const {
|
||||
if (previous == 0)
|
||||
m_iterators = m_iterators->next();
|
||||
else
|
||||
previous->set_next(current->next());
|
||||
}
|
||||
};
|
||||
|
||||
// Implementation of the debug_iterator_base methods.
|
||||
|
||||
inline debug_iterator_base::debug_iterator_base() : m_registry(0), m_next(0) {}
|
||||
|
||||
inline debug_iterator_base::debug_iterator_base(const debug_iterator_registry* registry)
|
||||
: m_registry(registry), m_next(0) {
|
||||
register_self();
|
||||
}
|
||||
|
||||
inline debug_iterator_base::debug_iterator_base(const debug_iterator_base& rhs)
|
||||
: m_registry(rhs.m_registry), m_next(0) {
|
||||
register_self();
|
||||
}
|
||||
|
||||
inline debug_iterator_base::~debug_iterator_base() { unregister_self(); }
|
||||
|
||||
inline debug_iterator_base& debug_iterator_base::operator = (const debug_iterator_base& rhs) {
|
||||
if (m_registry == rhs.m_registry)
|
||||
return *this;
|
||||
unregister_self();
|
||||
m_registry = rhs.m_registry;
|
||||
register_self();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool debug_iterator_base::is_valid(const debug_iterator_registry* registry) const {
|
||||
return m_registry == registry;
|
||||
}
|
||||
|
||||
inline void debug_iterator_base::invalidate() const { m_registry = 0; }
|
||||
|
||||
inline const debug_iterator_base* debug_iterator_base::next() const { return m_next; }
|
||||
|
||||
inline void debug_iterator_base::set_next(const debug_iterator_base* it) const { m_next = it; }
|
||||
|
||||
inline void debug_iterator_base::register_self() {
|
||||
if (m_registry != 0)
|
||||
m_registry->register_iterator(this);
|
||||
}
|
||||
|
||||
inline void debug_iterator_base::unregister_self() {
|
||||
if (m_registry != 0)
|
||||
m_registry->unregister_iterator(this);
|
||||
}
|
||||
|
||||
#endif // #if BOOST_CB_ENABLE_DEBUG
|
||||
|
||||
} // namespace cb_details
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #if !defined(BOOST_CIRCULAR_BUFFER_DEBUG_HPP)
|
491
boost/circular_buffer/details.hpp
Normal file
491
boost/circular_buffer/details.hpp
Normal file
@ -0,0 +1,491 @@
|
||||
// Helper classes and functions for the circular buffer.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
|
||||
// Copyright 2014,2018 Glen Joseph Fernandes
|
||||
// (glenjofe@gmail.com)
|
||||
|
||||
// Use, modification, and distribution is subject to 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)
|
||||
|
||||
#if !defined(BOOST_CIRCULAR_BUFFER_DETAILS_HPP)
|
||||
#define BOOST_CIRCULAR_BUFFER_DETAILS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <iterator>
|
||||
|
||||
// Silence MS /W4 warnings like C4913:
|
||||
// "user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used"
|
||||
// This might happen when previously including some boost headers that overload the coma operator.
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4913)
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace cb_details {
|
||||
|
||||
template <class Alloc> struct nonconst_traits;
|
||||
|
||||
template<class ForwardIterator, class Diff, class T, class Alloc>
|
||||
void uninitialized_fill_n_with_alloc(
|
||||
ForwardIterator first, Diff n, const T& item, Alloc& alloc);
|
||||
|
||||
template<class InputIterator, class ForwardIterator, class Alloc>
|
||||
ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a);
|
||||
|
||||
template<class InputIterator, class ForwardIterator, class Alloc>
|
||||
ForwardIterator uninitialized_move_if_noexcept(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a);
|
||||
|
||||
/*!
|
||||
\struct const_traits
|
||||
\brief Defines the data types for a const iterator.
|
||||
*/
|
||||
template <class Alloc>
|
||||
struct const_traits {
|
||||
// Basic types
|
||||
typedef typename Alloc::value_type value_type;
|
||||
typedef typename boost::allocator_const_pointer<Alloc>::type pointer;
|
||||
typedef const value_type& reference;
|
||||
typedef typename boost::allocator_size_type<Alloc>::type size_type;
|
||||
typedef typename boost::allocator_difference_type<Alloc>::type difference_type;
|
||||
|
||||
// Non-const traits
|
||||
typedef nonconst_traits<Alloc> nonconst_self;
|
||||
};
|
||||
|
||||
/*!
|
||||
\struct nonconst_traits
|
||||
\brief Defines the data types for a non-const iterator.
|
||||
*/
|
||||
template <class Alloc>
|
||||
struct nonconst_traits {
|
||||
// Basic types
|
||||
typedef typename Alloc::value_type value_type;
|
||||
typedef typename boost::allocator_pointer<Alloc>::type pointer;
|
||||
typedef value_type& reference;
|
||||
typedef typename boost::allocator_size_type<Alloc>::type size_type;
|
||||
typedef typename boost::allocator_difference_type<Alloc>::type difference_type;
|
||||
|
||||
// Non-const traits
|
||||
typedef nonconst_traits<Alloc> nonconst_self;
|
||||
};
|
||||
|
||||
/*!
|
||||
\struct iterator_wrapper
|
||||
\brief Helper iterator dereference wrapper.
|
||||
*/
|
||||
template <class Iterator>
|
||||
struct iterator_wrapper {
|
||||
mutable Iterator m_it;
|
||||
explicit iterator_wrapper(Iterator it) : m_it(it) {}
|
||||
Iterator operator () () const { return m_it++; }
|
||||
private:
|
||||
iterator_wrapper<Iterator>& operator = (const iterator_wrapper<Iterator>&); // do not generate
|
||||
};
|
||||
|
||||
/*!
|
||||
\struct item_wrapper
|
||||
\brief Helper item dereference wrapper.
|
||||
*/
|
||||
template <class Pointer, class Value>
|
||||
struct item_wrapper {
|
||||
Value m_item;
|
||||
explicit item_wrapper(Value item) : m_item(item) {}
|
||||
Pointer operator () () const { return &m_item; }
|
||||
private:
|
||||
item_wrapper<Pointer, Value>& operator = (const item_wrapper<Pointer, Value>&); // do not generate
|
||||
};
|
||||
|
||||
/*!
|
||||
\struct assign_n
|
||||
\brief Helper functor for assigning n items.
|
||||
*/
|
||||
template <class Value, class Alloc>
|
||||
struct assign_n {
|
||||
typedef typename boost::allocator_size_type<Alloc>::type size_type;
|
||||
size_type m_n;
|
||||
Value m_item;
|
||||
Alloc& m_alloc;
|
||||
assign_n(size_type n, Value item, Alloc& alloc) : m_n(n), m_item(item), m_alloc(alloc) {}
|
||||
template <class Pointer>
|
||||
void operator () (Pointer p) const {
|
||||
uninitialized_fill_n_with_alloc(p, m_n, m_item, m_alloc);
|
||||
}
|
||||
private:
|
||||
assign_n<Value, Alloc>& operator = (const assign_n<Value, Alloc>&); // do not generate
|
||||
};
|
||||
|
||||
/*!
|
||||
\struct assign_range
|
||||
\brief Helper functor for assigning range of items.
|
||||
*/
|
||||
template <class Iterator, class Alloc>
|
||||
struct assign_range {
|
||||
Iterator m_first;
|
||||
Iterator m_last;
|
||||
Alloc& m_alloc;
|
||||
|
||||
assign_range(const Iterator& first, const Iterator& last, Alloc& alloc)
|
||||
: m_first(first), m_last(last), m_alloc(alloc) {}
|
||||
|
||||
template <class Pointer>
|
||||
void operator () (Pointer p) const {
|
||||
boost::cb_details::uninitialized_copy(m_first, m_last, p, m_alloc);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Iterator, class Alloc>
|
||||
inline assign_range<Iterator, Alloc> make_assign_range(const Iterator& first, const Iterator& last, Alloc& a) {
|
||||
return assign_range<Iterator, Alloc>(first, last, a);
|
||||
}
|
||||
|
||||
/*!
|
||||
\class capacity_control
|
||||
\brief Capacity controller of the space optimized circular buffer.
|
||||
*/
|
||||
template <class Size>
|
||||
class capacity_control {
|
||||
|
||||
//! The capacity of the space-optimized circular buffer.
|
||||
Size m_capacity;
|
||||
|
||||
//! The lowest guaranteed or minimum capacity of the adapted space-optimized circular buffer.
|
||||
Size m_min_capacity;
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
capacity_control(Size buffer_capacity, Size min_buffer_capacity = 0)
|
||||
: m_capacity(buffer_capacity), m_min_capacity(min_buffer_capacity)
|
||||
{ // Check for capacity lower than min_capacity.
|
||||
BOOST_CB_ASSERT(buffer_capacity >= min_buffer_capacity);
|
||||
}
|
||||
|
||||
// Default copy constructor.
|
||||
|
||||
// Default assign operator.
|
||||
|
||||
//! Get the capacity of the space optimized circular buffer.
|
||||
Size capacity() const { return m_capacity; }
|
||||
|
||||
//! Get the minimal capacity of the space optimized circular buffer.
|
||||
Size min_capacity() const { return m_min_capacity; }
|
||||
|
||||
//! Size operator - returns the capacity of the space optimized circular buffer.
|
||||
operator Size() const { return m_capacity; }
|
||||
};
|
||||
|
||||
/*!
|
||||
\struct iterator
|
||||
\brief Random access iterator for the circular buffer.
|
||||
\param Buff The type of the underlying circular buffer.
|
||||
\param Traits Basic iterator types.
|
||||
\note This iterator is not circular. It was designed
|
||||
for iterating from begin() to end() of the circular buffer.
|
||||
*/
|
||||
template <class Buff, class Traits>
|
||||
struct iterator
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
: public debug_iterator_base
|
||||
#endif // #if BOOST_CB_ENABLE_DEBUG
|
||||
{
|
||||
// Helper types
|
||||
|
||||
//! Non-const iterator.
|
||||
typedef iterator<Buff, typename Traits::nonconst_self> nonconst_self;
|
||||
|
||||
// Basic types
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
|
||||
//! The type of the elements stored in the circular buffer.
|
||||
typedef typename Traits::value_type value_type;
|
||||
|
||||
//! Pointer to the element.
|
||||
typedef typename Traits::pointer pointer;
|
||||
|
||||
//! Reference to the element.
|
||||
typedef typename Traits::reference reference;
|
||||
|
||||
//! Size type.
|
||||
typedef typename Traits::size_type size_type;
|
||||
|
||||
//! Difference type.
|
||||
typedef typename Traits::difference_type difference_type;
|
||||
|
||||
// Member variables
|
||||
|
||||
//! The circular buffer where the iterator points to.
|
||||
const Buff* m_buff;
|
||||
|
||||
//! An internal iterator.
|
||||
pointer m_it;
|
||||
|
||||
// Construction & assignment
|
||||
|
||||
// Default copy constructor.
|
||||
|
||||
//! Default constructor.
|
||||
iterator() : m_buff(0), m_it(0) {}
|
||||
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
|
||||
//! Copy constructor (used for converting from a non-const to a const iterator).
|
||||
iterator(const nonconst_self& it) : debug_iterator_base(it), m_buff(it.m_buff), m_it(it.m_it) {}
|
||||
|
||||
//! Internal constructor.
|
||||
/*!
|
||||
\note This constructor is not intended to be used directly by the user.
|
||||
*/
|
||||
iterator(const Buff* cb, const pointer p) : debug_iterator_base(cb), m_buff(cb), m_it(p) {}
|
||||
|
||||
#else
|
||||
|
||||
iterator(const nonconst_self& it) : m_buff(it.m_buff), m_it(it.m_it) {}
|
||||
|
||||
iterator(const Buff* cb, const pointer p) : m_buff(cb), m_it(p) {}
|
||||
|
||||
#endif // #if BOOST_CB_ENABLE_DEBUG
|
||||
|
||||
//! Assign operator.
|
||||
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
|
||||
iterator& operator=(const iterator&) = default;
|
||||
#else
|
||||
iterator& operator=(const iterator& it) {
|
||||
if (this == &it)
|
||||
return *this;
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
debug_iterator_base::operator =(it);
|
||||
#endif // #if BOOST_CB_ENABLE_DEBUG
|
||||
m_buff = it.m_buff;
|
||||
m_it = it.m_it;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Random access iterator methods
|
||||
|
||||
//! Dereferencing operator.
|
||||
reference operator * () const {
|
||||
BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
BOOST_CB_ASSERT(m_it != 0); // check for iterator pointing to end()
|
||||
return *m_it;
|
||||
}
|
||||
|
||||
//! Dereferencing operator.
|
||||
pointer operator -> () const { return &(operator*()); }
|
||||
|
||||
//! Difference operator.
|
||||
template <class Traits0>
|
||||
difference_type operator - (const iterator<Buff, Traits0>& it) const {
|
||||
BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
BOOST_CB_ASSERT(it.is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
return linearize_pointer(*this) - linearize_pointer(it);
|
||||
}
|
||||
|
||||
//! Increment operator (prefix).
|
||||
iterator& operator ++ () {
|
||||
BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
BOOST_CB_ASSERT(m_it != 0); // check for iterator pointing to end()
|
||||
m_buff->increment(m_it);
|
||||
if (m_it == m_buff->m_last)
|
||||
m_it = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Increment operator (postfix).
|
||||
iterator operator ++ (int) {
|
||||
iterator<Buff, Traits> tmp = *this;
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
//! Decrement operator (prefix).
|
||||
iterator& operator -- () {
|
||||
BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
BOOST_CB_ASSERT(m_it != m_buff->m_first); // check for iterator pointing to begin()
|
||||
if (m_it == 0)
|
||||
m_it = m_buff->m_last;
|
||||
m_buff->decrement(m_it);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Decrement operator (postfix).
|
||||
iterator operator -- (int) {
|
||||
iterator<Buff, Traits> tmp = *this;
|
||||
--*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
//! Iterator addition.
|
||||
iterator& operator += (difference_type n) {
|
||||
BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
if (n > 0) {
|
||||
BOOST_CB_ASSERT(m_buff->end() - *this >= n); // check for too large n
|
||||
m_it = m_buff->add(m_it, n);
|
||||
if (m_it == m_buff->m_last)
|
||||
m_it = 0;
|
||||
} else if (n < 0) {
|
||||
*this -= -n;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Iterator addition.
|
||||
iterator operator + (difference_type n) const { return iterator<Buff, Traits>(*this) += n; }
|
||||
|
||||
//! Iterator subtraction.
|
||||
iterator& operator -= (difference_type n) {
|
||||
BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
if (n > 0) {
|
||||
BOOST_CB_ASSERT(*this - m_buff->begin() >= n); // check for too large n
|
||||
m_it = m_buff->sub(m_it == 0 ? m_buff->m_last : m_it, n);
|
||||
} else if (n < 0) {
|
||||
*this += -n;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Iterator subtraction.
|
||||
iterator operator - (difference_type n) const { return iterator<Buff, Traits>(*this) -= n; }
|
||||
|
||||
//! Element access operator.
|
||||
reference operator [] (difference_type n) const { return *(*this + n); }
|
||||
|
||||
// Equality & comparison
|
||||
|
||||
//! Equality.
|
||||
template <class Traits0>
|
||||
bool operator == (const iterator<Buff, Traits0>& it) const {
|
||||
BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
BOOST_CB_ASSERT(it.is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
return m_it == it.m_it;
|
||||
}
|
||||
|
||||
//! Inequality.
|
||||
template <class Traits0>
|
||||
bool operator != (const iterator<Buff, Traits0>& it) const {
|
||||
BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
BOOST_CB_ASSERT(it.is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
return m_it != it.m_it;
|
||||
}
|
||||
|
||||
//! Less.
|
||||
template <class Traits0>
|
||||
bool operator < (const iterator<Buff, Traits0>& it) const {
|
||||
BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
BOOST_CB_ASSERT(it.is_valid(m_buff)); // check for uninitialized or invalidated iterator
|
||||
return linearize_pointer(*this) < linearize_pointer(it);
|
||||
}
|
||||
|
||||
//! Greater.
|
||||
template <class Traits0>
|
||||
bool operator > (const iterator<Buff, Traits0>& it) const { return it < *this; }
|
||||
|
||||
//! Less or equal.
|
||||
template <class Traits0>
|
||||
bool operator <= (const iterator<Buff, Traits0>& it) const { return !(it < *this); }
|
||||
|
||||
//! Greater or equal.
|
||||
template <class Traits0>
|
||||
bool operator >= (const iterator<Buff, Traits0>& it) const { return !(*this < it); }
|
||||
|
||||
// Helpers
|
||||
|
||||
//! Get a pointer which would point to the same element as the iterator in case the circular buffer is linearized.
|
||||
template <class Traits0>
|
||||
typename Traits0::pointer linearize_pointer(const iterator<Buff, Traits0>& it) const {
|
||||
return it.m_it == 0 ? m_buff->m_buff + m_buff->size() :
|
||||
(it.m_it < m_buff->m_first ? it.m_it + (m_buff->m_end - m_buff->m_first)
|
||||
: m_buff->m_buff + (it.m_it - m_buff->m_first));
|
||||
}
|
||||
};
|
||||
|
||||
//! Iterator addition.
|
||||
template <class Buff, class Traits>
|
||||
inline iterator<Buff, Traits>
|
||||
operator + (typename Traits::difference_type n, const iterator<Buff, Traits>& it) {
|
||||
return it + n;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator dest)
|
||||
\brief Equivalent of <code>std::uninitialized_copy</code> but with explicit specification of value type.
|
||||
*/
|
||||
template<class InputIterator, class ForwardIterator, class Alloc>
|
||||
inline ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a) {
|
||||
ForwardIterator next = dest;
|
||||
BOOST_TRY {
|
||||
for (; first != last; ++first, ++dest)
|
||||
boost::allocator_construct(a, boost::to_address(dest), *first);
|
||||
} BOOST_CATCH(...) {
|
||||
for (; next != dest; ++next)
|
||||
boost::allocator_destroy(a, boost::to_address(next));
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
return dest;
|
||||
}
|
||||
|
||||
template<class InputIterator, class ForwardIterator, class Alloc>
|
||||
ForwardIterator uninitialized_move_if_noexcept_impl(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a,
|
||||
true_type) {
|
||||
for (; first != last; ++first, ++dest)
|
||||
boost::allocator_construct(a, boost::to_address(dest), boost::move(*first));
|
||||
return dest;
|
||||
}
|
||||
|
||||
template<class InputIterator, class ForwardIterator, class Alloc>
|
||||
ForwardIterator uninitialized_move_if_noexcept_impl(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a,
|
||||
false_type) {
|
||||
return uninitialized_copy(first, last, dest, a);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn ForwardIterator uninitialized_move_if_noexcept(InputIterator first, InputIterator last, ForwardIterator dest)
|
||||
\brief Equivalent of <code>std::uninitialized_copy</code> but with explicit specification of value type and moves elements if they have noexcept move constructors.
|
||||
*/
|
||||
template<class InputIterator, class ForwardIterator, class Alloc>
|
||||
ForwardIterator uninitialized_move_if_noexcept(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a) {
|
||||
typedef typename boost::is_nothrow_move_constructible<typename Alloc::value_type>::type tag_t;
|
||||
return uninitialized_move_if_noexcept_impl(first, last, dest, a, tag_t());
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void uninitialized_fill_n_with_alloc(ForwardIterator first, Diff n, const T& item, Alloc& alloc)
|
||||
\brief Equivalent of <code>std::uninitialized_fill_n</code> with allocator.
|
||||
*/
|
||||
template<class ForwardIterator, class Diff, class T, class Alloc>
|
||||
inline void uninitialized_fill_n_with_alloc(ForwardIterator first, Diff n, const T& item, Alloc& alloc) {
|
||||
ForwardIterator next = first;
|
||||
BOOST_TRY {
|
||||
for (; n > 0; ++first, --n)
|
||||
boost::allocator_construct(alloc, boost::to_address(first), item);
|
||||
} BOOST_CATCH(...) {
|
||||
for (; next != first; ++next)
|
||||
boost::allocator_destroy(alloc, boost::to_address(next));
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
}
|
||||
|
||||
} // namespace cb_details
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // #if !defined(BOOST_CIRCULAR_BUFFER_DETAILS_HPP)
|
1713
boost/circular_buffer/space_optimized.hpp
Normal file
1713
boost/circular_buffer/space_optimized.hpp
Normal file
File diff suppressed because it is too large
Load Diff
43
boost/circular_buffer_fwd.hpp
Normal file
43
boost/circular_buffer_fwd.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
// Forward declaration of the circular buffer and its adaptor.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
|
||||
// Use, modification, and distribution is subject to 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 www.boost.org/libs/circular_buffer for documentation.
|
||||
|
||||
#if !defined(BOOST_CIRCULAR_BUFFER_FWD_HPP)
|
||||
#define BOOST_CIRCULAR_BUFFER_FWD_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_STD_ALLOCATOR)
|
||||
#include <memory>
|
||||
#else
|
||||
#include <vector>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_STD_ALLOCATOR)
|
||||
#define BOOST_CB_DEFAULT_ALLOCATOR(T) std::allocator<T>
|
||||
#else
|
||||
#define BOOST_CB_DEFAULT_ALLOCATOR(T) BOOST_DEDUCED_TYPENAME std::vector<T>::allocator_type
|
||||
#endif
|
||||
|
||||
template <class T, class Alloc = BOOST_CB_DEFAULT_ALLOCATOR(T)>
|
||||
class circular_buffer;
|
||||
|
||||
template <class T, class Alloc = BOOST_CB_DEFAULT_ALLOCATOR(T)>
|
||||
class circular_buffer_space_optimized;
|
||||
|
||||
#undef BOOST_CB_DEFAULT_ALLOCATOR
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #if !defined(BOOST_CIRCULAR_BUFFER_FWD_HPP)
|
74
boost/detail/templated_streams.hpp
Normal file
74
boost/detail/templated_streams.hpp
Normal file
@ -0,0 +1,74 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost detail/templated_streams.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003
|
||||
// Eric Friedman
|
||||
//
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_DETAIL_TEMPLATED_STREAMS_HPP
|
||||
#define BOOST_DETAIL_TEMPLATED_STREAMS_HPP
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) BOOST_TEMPLATED_STREAM_* macros
|
||||
//
|
||||
// Provides workaround platforms without stream class templates.
|
||||
//
|
||||
|
||||
#if !defined(BOOST_NO_STD_LOCALE)
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_TEMPLATE(E,T) \
|
||||
template < typename E , typename T >
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_TEMPLATE_ALLOC(E,T,A) \
|
||||
template < typename E , typename T , typename A >
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_ARGS(E,T) \
|
||||
typename E , typename T
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_ARGS_ALLOC(E,T,A) \
|
||||
typename E , typename T , typename A
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_COMMA ,
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_ELEM(E) E
|
||||
#define BOOST_TEMPLATED_STREAM_TRAITS(T) T
|
||||
#define BOOST_TEMPLATED_STREAM_ALLOC(A) A
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM(X,E,T) \
|
||||
BOOST_JOIN(std::basic_,X)< E , T >
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_WITH_ALLOC(X,E,T,A) \
|
||||
BOOST_JOIN(std::basic_,X)< E , T , A >
|
||||
|
||||
#else // defined(BOOST_NO_STD_LOCALE)
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_TEMPLATE(E,T) /**/
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_TEMPLATE_ALLOC(E,T,A) /**/
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_ARGS(E,T) /**/
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_ARGS_ALLOC(E,T,A) /**/
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_COMMA /**/
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_ELEM(E) char
|
||||
#define BOOST_TEMPLATED_STREAM_TRAITS(T) std::char_traits<char>
|
||||
#define BOOST_TEMPLATED_STREAM_ALLOC(A) std::allocator<char>
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM(X,E,T) \
|
||||
std::X
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_WITH_ALLOC(X,E,T,A) \
|
||||
std::X
|
||||
|
||||
#endif // BOOST_NO_STD_LOCALE
|
||||
|
||||
#endif // BOOST_DETAIL_TEMPLATED_STREAMS_HPP
|
102
boost/integer/common_factor_ct.hpp
Normal file
102
boost/integer/common_factor_ct.hpp
Normal file
@ -0,0 +1,102 @@
|
||||
// Boost common_factor_ct.hpp header file ----------------------------------//
|
||||
|
||||
// (C) Copyright Daryle Walker and Stephen Cleary 2001-2002.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See https://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_INTEGER_COMMON_FACTOR_CT_HPP
|
||||
#define BOOST_INTEGER_COMMON_FACTOR_CT_HPP
|
||||
|
||||
#include <boost/integer_fwd.hpp> // self include
|
||||
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT, etc.
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace integer
|
||||
{
|
||||
|
||||
// Implementation details --------------------------------------------------//
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// Build GCD with Euclid's recursive algorithm
|
||||
template < static_gcd_type Value1, static_gcd_type Value2 >
|
||||
struct static_gcd_helper_t
|
||||
{
|
||||
private:
|
||||
BOOST_STATIC_CONSTANT( static_gcd_type, new_value1 = Value2 );
|
||||
BOOST_STATIC_CONSTANT( static_gcd_type, new_value2 = Value1 % Value2 );
|
||||
|
||||
#ifndef BOOST_BORLANDC
|
||||
#define BOOST_DETAIL_GCD_HELPER_VAL(Value) static_cast<static_gcd_type>(Value)
|
||||
#else
|
||||
typedef static_gcd_helper_t self_type;
|
||||
#define BOOST_DETAIL_GCD_HELPER_VAL(Value) (self_type:: Value )
|
||||
#endif
|
||||
|
||||
typedef static_gcd_helper_t< BOOST_DETAIL_GCD_HELPER_VAL(new_value1),
|
||||
BOOST_DETAIL_GCD_HELPER_VAL(new_value2) > next_step_type;
|
||||
|
||||
#undef BOOST_DETAIL_GCD_HELPER_VAL
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT( static_gcd_type, value = next_step_type::value );
|
||||
};
|
||||
|
||||
// Non-recursive case
|
||||
template < static_gcd_type Value1 >
|
||||
struct static_gcd_helper_t< Value1, 0UL >
|
||||
{
|
||||
BOOST_STATIC_CONSTANT( static_gcd_type, value = Value1 );
|
||||
};
|
||||
|
||||
// Build the LCM from the GCD
|
||||
template < static_gcd_type Value1, static_gcd_type Value2 >
|
||||
struct static_lcm_helper_t
|
||||
{
|
||||
typedef static_gcd_helper_t<Value1, Value2> gcd_type;
|
||||
|
||||
BOOST_STATIC_CONSTANT( static_gcd_type, value = Value1 / gcd_type::value
|
||||
* Value2 );
|
||||
};
|
||||
|
||||
// Special case for zero-GCD values
|
||||
template < >
|
||||
struct static_lcm_helper_t< 0UL, 0UL >
|
||||
{
|
||||
BOOST_STATIC_CONSTANT( static_gcd_type, value = 0UL );
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
// Compile-time greatest common divisor evaluator class declaration --------//
|
||||
|
||||
template < static_gcd_type Value1, static_gcd_type Value2 > struct static_gcd
|
||||
{
|
||||
BOOST_STATIC_CONSTANT( static_gcd_type, value = (detail::static_gcd_helper_t<Value1, Value2>::value) );
|
||||
}; // boost::integer::static_gcd
|
||||
|
||||
#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
|
||||
template< static_gcd_type Value1, static_gcd_type Value2 > static_gcd_type const static_gcd< Value1, Value2 >::value;
|
||||
#endif
|
||||
|
||||
// Compile-time least common multiple evaluator class declaration ----------//
|
||||
|
||||
template < static_gcd_type Value1, static_gcd_type Value2 > struct static_lcm
|
||||
{
|
||||
BOOST_STATIC_CONSTANT( static_gcd_type, value = (detail::static_lcm_helper_t<Value1, Value2>::value) );
|
||||
}; // boost::integer::static_lcm
|
||||
|
||||
#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
|
||||
template< static_gcd_type Value1, static_gcd_type Value2 > static_gcd_type const static_lcm< Value1, Value2 >::value;
|
||||
#endif
|
||||
|
||||
} // namespace integer
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_INTEGER_COMMON_FACTOR_CT_HPP
|
@ -1,117 +0,0 @@
|
||||
// -----------------------------------------------------------
|
||||
// integer_log2.hpp
|
||||
//
|
||||
// Gives the integer part of the logarithm, in base 2, of a
|
||||
// given number. Behavior is undefined if the argument is <= 0.
|
||||
//
|
||||
// Copyright (c) 2003-2004, 2008 Gennaro Prota
|
||||
// Copyright (c) 2022 Andrey Semashev
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// -----------------------------------------------------------
|
||||
|
||||
#ifndef BOOST_INTEGER_INTEGER_LOG2_HPP
|
||||
#define BOOST_INTEGER_INTEGER_LOG2_HPP
|
||||
|
||||
#include <climits>
|
||||
#include <limits>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/core/bit.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
|
||||
// helper to find the maximum power of two
|
||||
// less than p
|
||||
template< unsigned int p, unsigned int n, bool = ((2u * n) < p) >
|
||||
struct max_pow2_less :
|
||||
public max_pow2_less< p, 2u * n >
|
||||
{
|
||||
};
|
||||
|
||||
template< unsigned int p, unsigned int n >
|
||||
struct max_pow2_less< p, n, false >
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(unsigned int, value = n);
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
inline typename boost::disable_if< boost::is_integral< T >, int >::type integer_log2_impl(T x)
|
||||
{
|
||||
unsigned int n = detail::max_pow2_less<
|
||||
std::numeric_limits< T >::digits,
|
||||
CHAR_BIT / 2u
|
||||
>::value;
|
||||
|
||||
int result = 0;
|
||||
while (x != 1)
|
||||
{
|
||||
T t(x >> n);
|
||||
if (t)
|
||||
{
|
||||
result += static_cast< int >(n);
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
x = static_cast< T&& >(t);
|
||||
#else
|
||||
x = t;
|
||||
#endif
|
||||
}
|
||||
n >>= 1u;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
inline typename boost::enable_if< boost::is_integral< T >, int >::type integer_log2_impl(T x)
|
||||
{
|
||||
// We could simply rely on numeric_limits but sometimes
|
||||
// Borland tries to use numeric_limits<const T>, because
|
||||
// of its usual const-related problems in argument deduction
|
||||
// - gps
|
||||
return static_cast< int >((sizeof(T) * CHAR_BIT - 1u) -
|
||||
boost::core::countl_zero(static_cast< typename boost::make_unsigned< T >::type >(x)));
|
||||
}
|
||||
|
||||
#if defined(BOOST_HAS_INT128)
|
||||
// We need to provide explicit overloads for __int128 because (a) boost/core/bit.hpp currently does not support it and
|
||||
// (b) std::numeric_limits are not specialized for __int128 in some standard libraries.
|
||||
inline int integer_log2_impl(boost::uint128_type x)
|
||||
{
|
||||
const boost::uint64_t x_hi = static_cast< boost::uint64_t >(x >> 64u);
|
||||
if (x_hi != 0u)
|
||||
return 127 - boost::core::countl_zero(x_hi);
|
||||
else
|
||||
return 63 - boost::core::countl_zero(static_cast< boost::uint64_t >(x));
|
||||
}
|
||||
|
||||
inline int integer_log2_impl(boost::int128_type x)
|
||||
{
|
||||
return detail::integer_log2_impl(static_cast< boost::uint128_type >(x));
|
||||
}
|
||||
#endif // defined(BOOST_HAS_INT128)
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
// ------------
|
||||
// integer_log2
|
||||
// ------------
|
||||
template< typename T >
|
||||
inline int integer_log2(T x)
|
||||
{
|
||||
BOOST_ASSERT(x > 0);
|
||||
return detail::integer_log2_impl(x);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_INTEGER_INTEGER_LOG2_HPP
|
@ -1,134 +0,0 @@
|
||||
// Boost integer/integer_mask.hpp header file ------------------------------//
|
||||
|
||||
// (C) Copyright Daryle Walker 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See https://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_INTEGER_INTEGER_MASK_HPP
|
||||
#define BOOST_INTEGER_INTEGER_MASK_HPP
|
||||
|
||||
#include <boost/integer_fwd.hpp> // self include
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
|
||||
#include <boost/integer.hpp> // for boost::uint_t
|
||||
|
||||
#include <climits> // for UCHAR_MAX, etc.
|
||||
#include <cstddef> // for std::size_t
|
||||
|
||||
#include <boost/limits.hpp> // for std::numeric_limits
|
||||
|
||||
//
|
||||
// We simply cannot include this header on gcc without getting copious warnings of the kind:
|
||||
//
|
||||
// boost/integer/integer_mask.hpp:93:35: warning: use of C99 long long integer constant
|
||||
//
|
||||
// And yet there is no other reasonable implementation, so we declare this a system header
|
||||
// to suppress these warnings.
|
||||
//
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 4)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
|
||||
// Specified single-bit mask class declaration -----------------------------//
|
||||
// (Lowest bit starts counting at 0.)
|
||||
|
||||
template < std::size_t Bit >
|
||||
struct high_bit_mask_t
|
||||
{
|
||||
typedef typename uint_t<(Bit + 1)>::least least;
|
||||
typedef typename uint_t<(Bit + 1)>::fast fast;
|
||||
|
||||
BOOST_STATIC_CONSTANT( least, high_bit = (least( 1u ) << Bit) );
|
||||
BOOST_STATIC_CONSTANT( fast, high_bit_fast = (fast( 1u ) << Bit) );
|
||||
|
||||
BOOST_STATIC_CONSTANT( std::size_t, bit_position = Bit );
|
||||
|
||||
}; // boost::high_bit_mask_t
|
||||
|
||||
|
||||
// Specified bit-block mask class declaration ------------------------------//
|
||||
// Makes masks for the lowest N bits
|
||||
// (Specializations are needed when N fills up a type.)
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4310) // cast truncates constant value
|
||||
#endif
|
||||
|
||||
template < std::size_t Bits >
|
||||
struct low_bits_mask_t
|
||||
{
|
||||
typedef typename uint_t<Bits>::least least;
|
||||
typedef typename uint_t<Bits>::fast fast;
|
||||
|
||||
BOOST_STATIC_CONSTANT( least, sig_bits = least(~(least(~(least( 0u ))) << Bits )) );
|
||||
BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) );
|
||||
|
||||
BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );
|
||||
|
||||
}; // boost::low_bits_mask_t
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#define BOOST_LOW_BITS_MASK_SPECIALIZE( Type ) \
|
||||
template < > struct low_bits_mask_t< std::numeric_limits<Type>::digits > { \
|
||||
typedef std::numeric_limits<Type> limits_type; \
|
||||
typedef uint_t<limits_type::digits>::least least; \
|
||||
typedef uint_t<limits_type::digits>::fast fast; \
|
||||
BOOST_STATIC_CONSTANT( least, sig_bits = (~( least(0u) )) ); \
|
||||
BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) ); \
|
||||
BOOST_STATIC_CONSTANT( std::size_t, bit_count = limits_type::digits ); \
|
||||
}
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4245) // 'initializing' : conversion from 'int' to 'const boost::low_bits_mask_t<8>::least', signed/unsigned mismatch
|
||||
#endif
|
||||
|
||||
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned char );
|
||||
|
||||
#if USHRT_MAX > UCHAR_MAX
|
||||
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned short );
|
||||
#endif
|
||||
|
||||
#if UINT_MAX > USHRT_MAX
|
||||
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned int );
|
||||
#endif
|
||||
|
||||
#if ULONG_MAX > UINT_MAX
|
||||
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long );
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_LONG_LONG)
|
||||
#if ((defined(ULLONG_MAX) && (ULLONG_MAX > ULONG_MAX)) ||\
|
||||
(defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX > ULONG_MAX)) ||\
|
||||
(defined(ULONGLONG_MAX) && (ULONGLONG_MAX > ULONG_MAX)) ||\
|
||||
(defined(_ULLONG_MAX) && (_ULLONG_MAX > ULONG_MAX)))
|
||||
BOOST_LOW_BITS_MASK_SPECIALIZE( boost::ulong_long_type );
|
||||
#endif
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
#if 18446744073709551615ui64 > ULONG_MAX
|
||||
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned __int64 );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#undef BOOST_LOW_BITS_MASK_SPECIALIZE
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_INTEGER_INTEGER_MASK_HPP
|
@ -1,126 +0,0 @@
|
||||
// -------------- Boost static_log2.hpp header file ----------------------- //
|
||||
//
|
||||
// Copyright (C) 2001 Daryle Walker.
|
||||
// Copyright (C) 2003 Vesa Karvonen.
|
||||
// Copyright (C) 2003 Gennaro Prota.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// ---------------------------------------------------
|
||||
// See https://www.boost.org/libs/integer for documentation.
|
||||
// ------------------------------------------------------------------------- //
|
||||
|
||||
|
||||
#ifndef BOOST_INTEGER_STATIC_LOG2_HPP
|
||||
#define BOOST_INTEGER_STATIC_LOG2_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/integer_fwd.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
|
||||
namespace static_log2_impl {
|
||||
|
||||
// choose_initial_n<>
|
||||
//
|
||||
// Recursively doubles its integer argument, until it
|
||||
// becomes >= of the "width" (C99, 6.2.6.2p4) of
|
||||
// static_log2_argument_type.
|
||||
//
|
||||
// Used to get the maximum power of two less then the width.
|
||||
//
|
||||
// Example: if on your platform argument_type has 48 value
|
||||
// bits it yields n=32.
|
||||
//
|
||||
// It's easy to prove that, starting from such a value
|
||||
// of n, the core algorithm works correctly for any width
|
||||
// of static_log2_argument_type and that recursion always
|
||||
// terminates with x = 1 and n = 0 (see the algorithm's
|
||||
// invariant).
|
||||
|
||||
typedef boost::static_log2_argument_type argument_type;
|
||||
typedef boost::static_log2_result_type result_type;
|
||||
|
||||
template <result_type n>
|
||||
struct choose_initial_n {
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, c = (argument_type(1) << n << n) != 0);
|
||||
BOOST_STATIC_CONSTANT(
|
||||
result_type,
|
||||
value = !c*n + choose_initial_n<2*c*n>::value
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
template <>
|
||||
struct choose_initial_n<0> {
|
||||
BOOST_STATIC_CONSTANT(result_type, value = 0);
|
||||
};
|
||||
|
||||
|
||||
|
||||
// start computing from n_zero - must be a power of two
|
||||
const result_type n_zero = 16;
|
||||
const result_type initial_n = choose_initial_n<n_zero>::value;
|
||||
|
||||
// static_log2_impl<>
|
||||
//
|
||||
// * Invariant:
|
||||
// 2n
|
||||
// 1 <= x && x < 2 at the start of each recursion
|
||||
// (see also choose_initial_n<>)
|
||||
//
|
||||
// * Type requirements:
|
||||
//
|
||||
// argument_type maybe any unsigned type with at least n_zero + 1
|
||||
// value bits. (Note: If larger types will be standardized -e.g.
|
||||
// unsigned long long- then the argument_type typedef can be
|
||||
// changed without affecting the rest of the code.)
|
||||
//
|
||||
|
||||
template <argument_type x, result_type n = initial_n>
|
||||
struct static_log2_impl {
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, c = (x >> n) > 0); // x >= 2**n ?
|
||||
BOOST_STATIC_CONSTANT(
|
||||
result_type,
|
||||
value = c*n + (static_log2_impl< (x>>c*n), n/2 >::value)
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
template <>
|
||||
struct static_log2_impl<1, 0> {
|
||||
BOOST_STATIC_CONSTANT(result_type, value = 0);
|
||||
};
|
||||
|
||||
}
|
||||
} // detail
|
||||
|
||||
|
||||
|
||||
// --------------------------------------
|
||||
// static_log2<x>
|
||||
// ----------------------------------------
|
||||
|
||||
template <static_log2_argument_type x>
|
||||
struct static_log2 {
|
||||
|
||||
BOOST_STATIC_CONSTANT(
|
||||
static_log2_result_type,
|
||||
value = detail::static_log2_impl::static_log2_impl<x>::value
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
struct static_log2<0> { };
|
||||
|
||||
}
|
||||
|
||||
#endif // include guard
|
@ -1,594 +0,0 @@
|
||||
// (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
|
||||
// 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_DETAIL_CHAIN_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_CHAIN_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <exception>
|
||||
#include <iterator> // advance.
|
||||
#include <list>
|
||||
#include <memory> // allocator, auto_ptr or unique_ptr.
|
||||
#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>
|
||||
#include <boost/iostreams/detail/push.hpp>
|
||||
#include <boost/iostreams/detail/streambuf.hpp> // pubsync.
|
||||
#include <boost/iostreams/detail/wrap_unwrap.hpp>
|
||||
#include <boost/iostreams/device/null.hpp>
|
||||
#include <boost/iostreams/positioning.hpp>
|
||||
#include <boost/iostreams/traits.hpp> // is_filter.
|
||||
#include <boost/iostreams/stream_buffer.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type.hpp>
|
||||
#include <boost/iostreams/detail/execute.hpp>
|
||||
|
||||
// Sometimes type_info objects must be compared by name. Borrowed from
|
||||
// Boost.Python and Boost.Function.
|
||||
#if defined(__GNUC__) || \
|
||||
defined(_AIX) || \
|
||||
(defined(__sgi) && defined(__host_mips)) || \
|
||||
(defined(linux) && defined(__INTEL_COMPILER) && defined(__ICC)) \
|
||||
/**/
|
||||
# include <cstring>
|
||||
# define BOOST_IOSTREAMS_COMPARE_TYPE_ID(X,Y) \
|
||||
(std::strcmp((X).name(),(Y).name()) == 0)
|
||||
#else
|
||||
# define BOOST_IOSTREAMS_COMPARE_TYPE_ID(X,Y) ((X)==(Y))
|
||||
#endif
|
||||
|
||||
// Deprecated. Unused.
|
||||
#define BOOST_IOSTREAMS_COMPONENT_TYPE(chain, index) \
|
||||
chain.component_type( index ) \
|
||||
/**/
|
||||
|
||||
// Deprecated. Unused.
|
||||
#define BOOST_IOSTREAMS_COMPONENT(chain, index, target) \
|
||||
chain.component< target >( index ) \
|
||||
/**/
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
//--------------Definition of chain and wchain--------------------------------//
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename Chain> class chain_client;
|
||||
|
||||
//
|
||||
// Concept name: Chain.
|
||||
// Description: Represents a chain of stream buffers which provides access
|
||||
// to the first buffer in the chain and sends notifications when the
|
||||
// streambufs are added to or removed from chain.
|
||||
// Refines: Closable device with mode equal to typename Chain::mode.
|
||||
// Models: chain, converting_chain.
|
||||
// Example:
|
||||
//
|
||||
// class chain {
|
||||
// public:
|
||||
// typedef xxx chain_type;
|
||||
// typedef xxx client_type;
|
||||
// typedef xxx mode;
|
||||
// bool is_complete() const; // Ready for i/o.
|
||||
// template<typename T>
|
||||
// void push( const T& t, // Adds a stream buffer to
|
||||
// streamsize, // chain, based on t, with
|
||||
// streamsize ); // given buffer and putback
|
||||
// // buffer sizes. Pass -1 to
|
||||
// // request default size.
|
||||
// protected:
|
||||
// void register_client(client_type* client); // Associate client.
|
||||
// void notify(); // Notify client.
|
||||
// };
|
||||
//
|
||||
|
||||
//
|
||||
// Description: Represents a chain of filters with an optional device at the
|
||||
// end.
|
||||
// Template parameters:
|
||||
// Self - A class deriving from the current instantiation of this template.
|
||||
// This is an example of the Curiously Recurring Template Pattern.
|
||||
// Ch - The character type.
|
||||
// Tr - The character traits type.
|
||||
// Alloc - The allocator type.
|
||||
// Mode - A mode tag.
|
||||
//
|
||||
template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
|
||||
class chain_base {
|
||||
public:
|
||||
typedef Ch char_type;
|
||||
BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
|
||||
typedef Alloc allocator_type;
|
||||
typedef Mode mode;
|
||||
struct category
|
||||
: Mode,
|
||||
device_tag
|
||||
{ };
|
||||
typedef chain_client<Self> client_type;
|
||||
friend class chain_client<Self>;
|
||||
private:
|
||||
typedef linked_streambuf<Ch> streambuf_type;
|
||||
typedef std::list<streambuf_type*> list_type;
|
||||
typedef chain_base<Self, Ch, Tr, Alloc, Mode> my_type;
|
||||
protected:
|
||||
chain_base() : pimpl_(new chain_impl) { }
|
||||
chain_base(const chain_base& rhs): pimpl_(rhs.pimpl_) { }
|
||||
public:
|
||||
|
||||
// dual_use is a pseudo-mode to facilitate filter writing,
|
||||
// not a genuine mode.
|
||||
BOOST_STATIC_ASSERT((!is_convertible<mode, dual_use>::value));
|
||||
|
||||
//----------Buffer sizing-------------------------------------------------//
|
||||
|
||||
// Sets the size of the buffer created for the devices to be added to this
|
||||
// chain. Does not affect the size of the buffer for devices already
|
||||
// added.
|
||||
void set_device_buffer_size(std::streamsize n)
|
||||
{ pimpl_->device_buffer_size_ = n; }
|
||||
|
||||
// Sets the size of the buffer created for the filters to be added
|
||||
// to this chain. Does not affect the size of the buffer for filters already
|
||||
// added.
|
||||
void set_filter_buffer_size(std::streamsize n)
|
||||
{ pimpl_->filter_buffer_size_ = n; }
|
||||
|
||||
// Sets the size of the putback buffer for filters and devices to be added
|
||||
// to this chain. Does not affect the size of the buffer for filters or
|
||||
// devices already added.
|
||||
void set_pback_size(std::streamsize n)
|
||||
{ pimpl_->pback_size_ = n; }
|
||||
|
||||
//----------Device interface----------------------------------------------//
|
||||
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
std::streamsize write(const char_type* s, std::streamsize n);
|
||||
std::streampos seek(stream_offset off, BOOST_IOS::seekdir way);
|
||||
|
||||
//----------Direct component access---------------------------------------//
|
||||
|
||||
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"));
|
||||
return (*boost::next(list().begin(), n))->component_type();
|
||||
}
|
||||
|
||||
// Deprecated.
|
||||
template<int 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>()); }
|
||||
|
||||
// Deprecated.
|
||||
template<int N, typename T>
|
||||
T* component() const { return component<T>(N); }
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
private:
|
||||
#endif
|
||||
template<typename T>
|
||||
T* component(int n, boost::type<T>) const
|
||||
{
|
||||
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(), BOOST_CORE_TYPEID(T)))
|
||||
return static_cast<T*>(link->component_impl());
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
public:
|
||||
|
||||
//----------Container-like interface--------------------------------------//
|
||||
|
||||
typedef typename list_type::size_type size_type;
|
||||
streambuf_type& front() { return *list().front(); }
|
||||
BOOST_IOSTREAMS_DEFINE_PUSH(push, mode, char_type, push_impl)
|
||||
void pop();
|
||||
bool empty() const { return list().empty(); }
|
||||
size_type size() const { return list().size(); }
|
||||
void reset();
|
||||
|
||||
//----------Additional i/o functions--------------------------------------//
|
||||
|
||||
// Returns true if this chain is non-empty and its final link
|
||||
// is a source or sink, i.e., if it is ready to perform i/o.
|
||||
bool is_complete() const;
|
||||
bool auto_close() const;
|
||||
void set_auto_close(bool close);
|
||||
bool sync() { return front().BOOST_IOSTREAMS_PUBSYNC() != -1; }
|
||||
bool strict_sync();
|
||||
private:
|
||||
template<typename T>
|
||||
void push_impl(const T& t, std::streamsize buffer_size = -1,
|
||||
std::streamsize pback_size = -1)
|
||||
{
|
||||
typedef typename iostreams::category_of<T>::type category;
|
||||
typedef typename unwrap_ios<T>::type component_type;
|
||||
typedef stream_buffer<
|
||||
component_type,
|
||||
BOOST_IOSTREAMS_CHAR_TRAITS(char_type),
|
||||
Alloc, Mode
|
||||
> streambuf_t;
|
||||
typedef typename list_type::iterator iterator;
|
||||
BOOST_STATIC_ASSERT((is_convertible<category, Mode>::value));
|
||||
if (is_complete())
|
||||
boost::throw_exception(std::logic_error("chain complete"));
|
||||
streambuf_type* prev = !empty() ? list().back() : 0;
|
||||
buffer_size =
|
||||
buffer_size != -1 ?
|
||||
buffer_size :
|
||||
iostreams::optimal_buffer_size(t);
|
||||
pback_size =
|
||||
pback_size != -1 ?
|
||||
pback_size :
|
||||
pimpl_->pback_size_;
|
||||
|
||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
|
||||
std::auto_ptr<streambuf_t>
|
||||
buf(new streambuf_t(t, buffer_size, pback_size));
|
||||
|
||||
#else
|
||||
|
||||
std::unique_ptr<streambuf_t>
|
||||
buf(new streambuf_t(t, buffer_size, pback_size));
|
||||
|
||||
#endif
|
||||
|
||||
list().push_back(buf.get());
|
||||
buf.release();
|
||||
if (is_device<component_type>::value) {
|
||||
pimpl_->flags_ |= f_complete | f_open;
|
||||
for ( iterator first = list().begin(),
|
||||
last = list().end();
|
||||
first != last;
|
||||
++first )
|
||||
{
|
||||
(*first)->set_needs_close();
|
||||
}
|
||||
}
|
||||
if (prev) prev->set_next(list().back());
|
||||
notify();
|
||||
}
|
||||
|
||||
list_type& list() { return pimpl_->links_; }
|
||||
const list_type& list() const { return pimpl_->links_; }
|
||||
void register_client(client_type* client) { pimpl_->client_ = client; }
|
||||
void notify() { if (pimpl_->client_) pimpl_->client_->notify(); }
|
||||
|
||||
//----------Nested classes------------------------------------------------//
|
||||
|
||||
static void close(streambuf_type* b, BOOST_IOS::openmode m)
|
||||
{
|
||||
if (m == BOOST_IOS::out && is_convertible<Mode, output>::value)
|
||||
b->BOOST_IOSTREAMS_PUBSYNC();
|
||||
b->close(m);
|
||||
}
|
||||
|
||||
static void set_next(streambuf_type* b, streambuf_type* next)
|
||||
{ b->set_next(next); }
|
||||
|
||||
static void set_auto_close(streambuf_type* b, bool close)
|
||||
{ b->set_auto_close(close); }
|
||||
|
||||
struct closer {
|
||||
typedef streambuf_type* argument_type;
|
||||
typedef void result_type;
|
||||
closer(BOOST_IOS::openmode m) : mode_(m) { }
|
||||
void operator() (streambuf_type* b)
|
||||
{
|
||||
close(b, mode_);
|
||||
}
|
||||
BOOST_IOS::openmode mode_;
|
||||
};
|
||||
friend struct closer;
|
||||
|
||||
enum flags {
|
||||
f_complete = 1,
|
||||
f_open = 2,
|
||||
f_auto_close = 4
|
||||
};
|
||||
|
||||
struct chain_impl {
|
||||
chain_impl()
|
||||
: client_(0), device_buffer_size_(default_device_buffer_size),
|
||||
filter_buffer_size_(default_filter_buffer_size),
|
||||
pback_size_(default_pback_buffer_size),
|
||||
flags_(f_auto_close)
|
||||
{ }
|
||||
~chain_impl()
|
||||
{
|
||||
try { close(); } catch (...) { }
|
||||
try { reset(); } catch (...) { }
|
||||
}
|
||||
void close()
|
||||
{
|
||||
if ((flags_ & f_open) != 0) {
|
||||
flags_ &= ~f_open;
|
||||
stream_buffer< basic_null_device<Ch, Mode> > null;
|
||||
if ((flags_ & f_complete) == 0) {
|
||||
null.open(basic_null_device<Ch, Mode>());
|
||||
set_next(links_.back(), &null);
|
||||
}
|
||||
links_.front()->BOOST_IOSTREAMS_PUBSYNC();
|
||||
try {
|
||||
boost::iostreams::detail::execute_foreach(
|
||||
links_.rbegin(), links_.rend(),
|
||||
closer(BOOST_IOS::in)
|
||||
);
|
||||
} catch (...) {
|
||||
try {
|
||||
boost::iostreams::detail::execute_foreach(
|
||||
links_.begin(), links_.end(),
|
||||
closer(BOOST_IOS::out)
|
||||
);
|
||||
} catch (...) { }
|
||||
throw;
|
||||
}
|
||||
boost::iostreams::detail::execute_foreach(
|
||||
links_.begin(), links_.end(),
|
||||
closer(BOOST_IOS::out)
|
||||
);
|
||||
}
|
||||
}
|
||||
void reset()
|
||||
{
|
||||
typedef typename list_type::iterator iterator;
|
||||
for ( iterator first = links_.begin(),
|
||||
last = links_.end();
|
||||
first != last;
|
||||
++first )
|
||||
{
|
||||
if ( (flags_ & f_complete) == 0 ||
|
||||
(flags_ & f_auto_close) == 0 )
|
||||
{
|
||||
set_auto_close(*first, false);
|
||||
}
|
||||
streambuf_type* buf = 0;
|
||||
std::swap(buf, *first);
|
||||
delete buf;
|
||||
}
|
||||
links_.clear();
|
||||
flags_ &= ~f_complete;
|
||||
flags_ &= ~f_open;
|
||||
}
|
||||
list_type links_;
|
||||
client_type* client_;
|
||||
std::streamsize device_buffer_size_,
|
||||
filter_buffer_size_,
|
||||
pback_size_;
|
||||
int flags_;
|
||||
};
|
||||
friend struct chain_impl;
|
||||
|
||||
//----------Member data---------------------------------------------------//
|
||||
|
||||
private:
|
||||
shared_ptr<chain_impl> pimpl_;
|
||||
};
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
//
|
||||
// Macro: BOOST_IOSTREAMS_DECL_CHAIN(name, category)
|
||||
// Description: Defines a template derived from chain_base appropriate for a
|
||||
// particular i/o category. The template has the following parameters:
|
||||
// Ch - The character type.
|
||||
// Tr - The character traits type.
|
||||
// Alloc - The allocator type.
|
||||
// Macro parameters:
|
||||
// name_ - The name of the template to be defined.
|
||||
// category_ - The i/o category of the template to be defined.
|
||||
//
|
||||
#define BOOST_IOSTREAMS_DECL_CHAIN(name_, default_char_) \
|
||||
template< typename Mode, typename Ch = default_char_, \
|
||||
typename Tr = BOOST_IOSTREAMS_CHAR_TRAITS(Ch), \
|
||||
typename Alloc = std::allocator<Ch> > \
|
||||
class name_ : public boost::iostreams::detail::chain_base< \
|
||||
name_<Mode, Ch, Tr, Alloc>, \
|
||||
Ch, Tr, Alloc, Mode \
|
||||
> \
|
||||
{ \
|
||||
public: \
|
||||
struct category : device_tag, Mode { }; \
|
||||
typedef Mode mode; \
|
||||
private: \
|
||||
typedef boost::iostreams::detail::chain_base< \
|
||||
name_<Mode, Ch, Tr, Alloc>, \
|
||||
Ch, Tr, Alloc, Mode \
|
||||
> base_type; \
|
||||
public: \
|
||||
typedef Ch char_type; \
|
||||
typedef Tr traits_type; \
|
||||
typedef typename traits_type::int_type int_type; \
|
||||
typedef typename traits_type::off_type off_type; \
|
||||
name_() { } \
|
||||
name_(const name_& rhs) : base_type(rhs) { } \
|
||||
name_& operator=(const name_& rhs) \
|
||||
{ base_type::operator=(rhs); return *this; } \
|
||||
}; \
|
||||
/**/
|
||||
BOOST_IOSTREAMS_DECL_CHAIN(chain, char)
|
||||
BOOST_IOSTREAMS_DECL_CHAIN(wchain, wchar_t)
|
||||
#undef BOOST_IOSTREAMS_DECL_CHAIN
|
||||
|
||||
//--------------Definition of chain_client------------------------------------//
|
||||
|
||||
namespace detail {
|
||||
|
||||
//
|
||||
// Template name: chain_client
|
||||
// Description: Class whose instances provide access to an underlying chain
|
||||
// using an interface similar to the chains.
|
||||
// Subclasses: the various stream and stream buffer templates.
|
||||
//
|
||||
template<typename Chain>
|
||||
class chain_client {
|
||||
public:
|
||||
typedef Chain chain_type;
|
||||
typedef typename chain_type::char_type char_type;
|
||||
typedef typename chain_type::traits_type traits_type;
|
||||
typedef typename chain_type::size_type size_type;
|
||||
typedef typename chain_type::mode mode;
|
||||
|
||||
chain_client(chain_type* chn = 0) : chain_(chn ) { }
|
||||
chain_client(chain_client* client) : chain_(client->chain_) { }
|
||||
virtual ~chain_client() { }
|
||||
|
||||
const boost::core::typeinfo& component_type(int n) const
|
||||
{ return chain_->component_type(n); }
|
||||
|
||||
// Deprecated.
|
||||
template<int N>
|
||||
const boost::core::typeinfo& component_type() const
|
||||
{ return chain_->BOOST_NESTED_TEMPLATE component_type<N>(); }
|
||||
|
||||
template<typename T>
|
||||
T* component(int n) const
|
||||
{ return chain_->BOOST_NESTED_TEMPLATE component<T>(n); }
|
||||
|
||||
// Deprecated.
|
||||
template<int N, typename T>
|
||||
T* component() const
|
||||
{ return chain_->BOOST_NESTED_TEMPLATE component<N, T>(); }
|
||||
|
||||
bool is_complete() const { return chain_->is_complete(); }
|
||||
bool auto_close() const { return chain_->auto_close(); }
|
||||
void set_auto_close(bool close) { chain_->set_auto_close(close); }
|
||||
bool strict_sync() { return chain_->strict_sync(); }
|
||||
void set_device_buffer_size(std::streamsize n)
|
||||
{ chain_->set_device_buffer_size(n); }
|
||||
void set_filter_buffer_size(std::streamsize n)
|
||||
{ chain_->set_filter_buffer_size(n); }
|
||||
void set_pback_size(std::streamsize n) { chain_->set_pback_size(n); }
|
||||
BOOST_IOSTREAMS_DEFINE_PUSH(push, mode, char_type, push_impl)
|
||||
void pop() { chain_->pop(); }
|
||||
bool empty() const { return chain_->empty(); }
|
||||
size_type size() const { return chain_->size(); }
|
||||
void reset() { chain_->reset(); }
|
||||
|
||||
// Returns a copy of the underlying chain.
|
||||
chain_type filters() { return *chain_; }
|
||||
chain_type filters() const { return *chain_; }
|
||||
protected:
|
||||
template<typename T>
|
||||
void push_impl(const T& t BOOST_IOSTREAMS_PUSH_PARAMS())
|
||||
{ chain_->push(t BOOST_IOSTREAMS_PUSH_ARGS()); }
|
||||
chain_type& ref() { return *chain_; }
|
||||
void set_chain(chain_type* c)
|
||||
{ chain_ = c; chain_->register_client(this); }
|
||||
#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) && \
|
||||
(!BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600))
|
||||
template<typename S, typename C, typename T, typename A, typename M>
|
||||
friend class chain_base;
|
||||
#else
|
||||
public:
|
||||
#endif
|
||||
virtual void notify() { }
|
||||
private:
|
||||
chain_type* chain_;
|
||||
};
|
||||
|
||||
//--------------Implementation of chain_base----------------------------------//
|
||||
|
||||
template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
|
||||
inline std::streamsize chain_base<Self, Ch, Tr, Alloc, Mode>::read
|
||||
(char_type* s, std::streamsize n)
|
||||
{ return iostreams::read(*list().front(), s, n); }
|
||||
|
||||
template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
|
||||
inline std::streamsize chain_base<Self, Ch, Tr, Alloc, Mode>::write
|
||||
(const char_type* s, std::streamsize n)
|
||||
{ return iostreams::write(*list().front(), s, n); }
|
||||
|
||||
template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
|
||||
inline std::streampos chain_base<Self, Ch, Tr, Alloc, Mode>::seek
|
||||
(stream_offset off, BOOST_IOS::seekdir way)
|
||||
{ return iostreams::seek(*list().front(), off, way); }
|
||||
|
||||
template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
|
||||
void chain_base<Self, Ch, Tr, Alloc, Mode>::reset()
|
||||
{
|
||||
using namespace std;
|
||||
pimpl_->close();
|
||||
pimpl_->reset();
|
||||
}
|
||||
|
||||
template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
|
||||
bool chain_base<Self, Ch, Tr, Alloc, Mode>::is_complete() const
|
||||
{
|
||||
return (pimpl_->flags_ & f_complete) != 0;
|
||||
}
|
||||
|
||||
template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
|
||||
bool chain_base<Self, Ch, Tr, Alloc, Mode>::auto_close() const
|
||||
{
|
||||
return (pimpl_->flags_ & f_auto_close) != 0;
|
||||
}
|
||||
|
||||
template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
|
||||
void chain_base<Self, Ch, Tr, Alloc, Mode>::set_auto_close(bool close)
|
||||
{
|
||||
pimpl_->flags_ =
|
||||
(pimpl_->flags_ & ~f_auto_close) |
|
||||
(close ? f_auto_close : 0);
|
||||
}
|
||||
|
||||
template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
|
||||
bool chain_base<Self, Ch, Tr, Alloc, Mode>::strict_sync()
|
||||
{
|
||||
typedef typename list_type::iterator iterator;
|
||||
bool result = true;
|
||||
for ( iterator first = list().begin(),
|
||||
last = list().end();
|
||||
first != last;
|
||||
++first )
|
||||
{
|
||||
bool s = (*first)->strict_sync();
|
||||
result = result && s;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
|
||||
void chain_base<Self, Ch, Tr, Alloc, Mode>::pop()
|
||||
{
|
||||
BOOST_ASSERT(!empty());
|
||||
if (auto_close())
|
||||
pimpl_->close();
|
||||
streambuf_type* buf = 0;
|
||||
std::swap(buf, list().back());
|
||||
buf->set_auto_close(false);
|
||||
buf->set_next(0);
|
||||
delete buf;
|
||||
list().pop_back();
|
||||
pimpl_->flags_ &= ~f_complete;
|
||||
if (auto_close() || list().empty())
|
||||
pimpl_->flags_ &= ~f_open;
|
||||
}
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_CHAIN_HPP_INCLUDED
|
@ -1,417 +0,0 @@
|
||||
// (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
|
||||
// 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.
|
||||
|
||||
// Contains machinery for performing code conversion.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_CODE_CONVERTER_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_CODE_CONVERTER_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/iostreams/detail/config/wide_streams.hpp>
|
||||
#if defined(BOOST_IOSTREAMS_NO_WIDE_STREAMS) || \
|
||||
defined(BOOST_IOSTREAMS_NO_LOCALE) \
|
||||
/**/
|
||||
# error code conversion not supported on this platform
|
||||
#endif
|
||||
|
||||
#include <algorithm> // max.
|
||||
#include <cstring> // memcpy.
|
||||
#include <exception>
|
||||
#include <boost/config.hpp> // DEDUCED_TYPENAME,
|
||||
#include <boost/iostreams/char_traits.hpp>
|
||||
#include <boost/iostreams/constants.hpp> // default_filter_buffer_size.
|
||||
#include <boost/iostreams/detail/adapter/concept_adapter.hpp>
|
||||
#include <boost/iostreams/detail/adapter/direct_adapter.hpp>
|
||||
#include <boost/iostreams/detail/buffer.hpp>
|
||||
#include <boost/iostreams/detail/call_traits.hpp>
|
||||
#include <boost/iostreams/detail/codecvt_holder.hpp>
|
||||
#include <boost/iostreams/detail/codecvt_helper.hpp>
|
||||
#include <boost/iostreams/detail/double_object.hpp>
|
||||
#include <boost/iostreams/detail/execute.hpp>
|
||||
#include <boost/iostreams/detail/forward.hpp>
|
||||
#include <boost/iostreams/detail/functional.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // failure, openmode, int types, streamsize.
|
||||
#include <boost/iostreams/detail/optional.hpp>
|
||||
#include <boost/iostreams/detail/select.hpp>
|
||||
#include <boost/iostreams/traits.hpp>
|
||||
#include <boost/iostreams/operations.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
// Must come last.
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp> // Borland 5.x
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
struct code_conversion_error : BOOST_IOSTREAMS_FAILURE {
|
||||
code_conversion_error()
|
||||
: BOOST_IOSTREAMS_FAILURE("code conversion error")
|
||||
{ }
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
//--------------Definition of strncpy_if_same---------------------------------//
|
||||
|
||||
// Helper template for strncpy_if_same, below.
|
||||
template<bool B>
|
||||
struct strncpy_if_same_impl;
|
||||
|
||||
template<>
|
||||
struct strncpy_if_same_impl<true> {
|
||||
template<typename Ch>
|
||||
static Ch* copy(Ch* tgt, const Ch* src, std::streamsize n)
|
||||
{ return BOOST_IOSTREAMS_CHAR_TRAITS(Ch)::copy(tgt, src, n); }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct strncpy_if_same_impl<false> {
|
||||
template<typename Src, typename Tgt>
|
||||
static Tgt* copy(Tgt* tgt, const Src*, std::streamsize) { return tgt; }
|
||||
};
|
||||
|
||||
template<typename Src, typename Tgt>
|
||||
Tgt* strncpy_if_same(Tgt* tgt, const Src* src, std::streamsize n)
|
||||
{
|
||||
typedef strncpy_if_same_impl<is_same<Src, Tgt>::value> impl;
|
||||
return impl::copy(tgt, src, n);
|
||||
}
|
||||
|
||||
//--------------Definition of conversion_buffer-------------------------------//
|
||||
|
||||
// Buffer and conversion state for reading.
|
||||
template<typename Codecvt, typename Alloc>
|
||||
class conversion_buffer
|
||||
: public buffer<
|
||||
BOOST_DEDUCED_TYPENAME detail::codecvt_extern<Codecvt>::type,
|
||||
Alloc
|
||||
>
|
||||
{
|
||||
public:
|
||||
typedef typename Codecvt::state_type state_type;
|
||||
conversion_buffer()
|
||||
: buffer<
|
||||
BOOST_DEDUCED_TYPENAME detail::codecvt_extern<Codecvt>::type,
|
||||
Alloc
|
||||
>(0)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
state_type& state() { return state_; }
|
||||
void reset()
|
||||
{
|
||||
if (this->size())
|
||||
this->set(0, 0);
|
||||
state_ = state_type();
|
||||
}
|
||||
private:
|
||||
state_type state_;
|
||||
};
|
||||
|
||||
//--------------Definition of converter_impl----------------------------------//
|
||||
|
||||
// Contains member data, open/is_open/close and buffer management functions.
|
||||
template<typename Device, typename Codecvt, typename Alloc>
|
||||
struct code_converter_impl {
|
||||
typedef typename codecvt_extern<Codecvt>::type extern_type;
|
||||
typedef typename category_of<Device>::type device_category;
|
||||
typedef is_convertible<device_category, input> can_read;
|
||||
typedef is_convertible<device_category, output> can_write;
|
||||
typedef is_convertible<device_category, bidirectional> is_bidir;
|
||||
typedef typename
|
||||
iostreams::select< // Disambiguation for Tru64.
|
||||
is_bidir, bidirectional,
|
||||
can_read, input,
|
||||
can_write, output
|
||||
>::type mode;
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
is_direct<Device>,
|
||||
direct_adapter<Device>,
|
||||
Device
|
||||
>::type device_type;
|
||||
typedef optional< concept_adapter<device_type> > storage_type;
|
||||
typedef is_convertible<device_category, two_sequence> is_double;
|
||||
typedef conversion_buffer<Codecvt, Alloc> buffer_type;
|
||||
|
||||
code_converter_impl() : cvt_(), flags_(0) { }
|
||||
|
||||
~code_converter_impl()
|
||||
{
|
||||
try {
|
||||
if (flags_ & f_open) close();
|
||||
} catch (...) { /* */ }
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void open(const T& dev, std::streamsize buffer_size)
|
||||
{
|
||||
if (flags_ & f_open)
|
||||
boost::throw_exception(BOOST_IOSTREAMS_FAILURE("already open"));
|
||||
if (buffer_size == -1)
|
||||
buffer_size = default_filter_buffer_size;
|
||||
std::streamsize max_length = cvt_.get().max_length();
|
||||
buffer_size = (std::max)(buffer_size, 2 * max_length);
|
||||
if (can_read::value) {
|
||||
buf_.first().resize(buffer_size);
|
||||
buf_.first().set(0, 0);
|
||||
}
|
||||
if (can_write::value && !is_double::value) {
|
||||
buf_.second().resize(buffer_size);
|
||||
buf_.second().set(0, 0);
|
||||
}
|
||||
dev_.reset(concept_adapter<device_type>(dev));
|
||||
flags_ = f_open;
|
||||
}
|
||||
|
||||
void close()
|
||||
{
|
||||
detail::execute_all(
|
||||
detail::call_member_close(*this, BOOST_IOS::in),
|
||||
detail::call_member_close(*this, BOOST_IOS::out)
|
||||
);
|
||||
}
|
||||
|
||||
void close(BOOST_IOS::openmode which)
|
||||
{
|
||||
if (which == BOOST_IOS::in && (flags_ & f_input_closed) == 0) {
|
||||
flags_ |= f_input_closed;
|
||||
iostreams::close(dev(), BOOST_IOS::in);
|
||||
}
|
||||
if (which == BOOST_IOS::out && (flags_ & f_output_closed) == 0) {
|
||||
flags_ |= f_output_closed;
|
||||
detail::execute_all(
|
||||
detail::flush_buffer(buf_.second(), dev(), can_write::value),
|
||||
detail::call_close(dev(), BOOST_IOS::out),
|
||||
detail::call_reset(dev_),
|
||||
detail::call_reset(buf_.first()),
|
||||
detail::call_reset(buf_.second())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
bool is_open() const { return (flags_ & f_open) != 0;}
|
||||
|
||||
device_type& dev() { return **dev_; }
|
||||
|
||||
enum flag_type {
|
||||
f_open = 1,
|
||||
f_input_closed = f_open << 1,
|
||||
f_output_closed = f_input_closed << 1
|
||||
};
|
||||
|
||||
codecvt_holder<Codecvt> cvt_;
|
||||
storage_type dev_;
|
||||
double_object<
|
||||
buffer_type,
|
||||
is_double
|
||||
> buf_;
|
||||
int flags_;
|
||||
};
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
//--------------Definition of converter---------------------------------------//
|
||||
|
||||
#define BOOST_IOSTREAMS_CONVERTER_PARAMS() , std::streamsize buffer_size = -1
|
||||
#define BOOST_IOSTREAMS_CONVERTER_ARGS() , buffer_size
|
||||
|
||||
template<typename Device, typename Codecvt, typename Alloc>
|
||||
struct code_converter_base {
|
||||
typedef detail::code_converter_impl<
|
||||
Device, Codecvt, Alloc
|
||||
> impl_type;
|
||||
code_converter_base() : pimpl_(new impl_type) { }
|
||||
shared_ptr<impl_type> pimpl_;
|
||||
};
|
||||
|
||||
template< typename Device,
|
||||
typename Codecvt = detail::default_codecvt,
|
||||
typename Alloc = std::allocator<char> >
|
||||
class code_converter
|
||||
: protected code_converter_base<Device, Codecvt, Alloc>
|
||||
{
|
||||
private:
|
||||
typedef detail::code_converter_impl<
|
||||
Device, Codecvt, Alloc
|
||||
> impl_type;
|
||||
typedef typename impl_type::device_type device_type;
|
||||
typedef typename impl_type::buffer_type buffer_type;
|
||||
typedef typename detail::codecvt_holder<Codecvt>::codecvt_type codecvt_type;
|
||||
typedef typename detail::codecvt_intern<Codecvt>::type intern_type;
|
||||
typedef typename detail::codecvt_extern<Codecvt>::type extern_type;
|
||||
typedef typename detail::codecvt_state<Codecvt>::type state_type;
|
||||
public:
|
||||
typedef intern_type char_type;
|
||||
struct category
|
||||
: impl_type::mode, device_tag, closable_tag, localizable_tag
|
||||
{ };
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_same<
|
||||
extern_type,
|
||||
BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
|
||||
>::value
|
||||
));
|
||||
public:
|
||||
code_converter() { }
|
||||
BOOST_IOSTREAMS_FORWARD( code_converter, open_impl, Device,
|
||||
BOOST_IOSTREAMS_CONVERTER_PARAMS,
|
||||
BOOST_IOSTREAMS_CONVERTER_ARGS )
|
||||
|
||||
// fstream-like interface.
|
||||
|
||||
bool is_open() const { return this->pimpl_->is_open(); }
|
||||
void close(BOOST_IOS::openmode which = BOOST_IOS::in | BOOST_IOS::out )
|
||||
{ impl().close(which); }
|
||||
|
||||
// Device interface.
|
||||
|
||||
std::streamsize read(char_type*, std::streamsize);
|
||||
std::streamsize write(const char_type*, std::streamsize);
|
||||
void imbue(const std::locale& loc) { impl().cvt_.imbue(loc); }
|
||||
|
||||
// Direct device access.
|
||||
|
||||
Device& operator*() { return detail::unwrap_direct(dev()); }
|
||||
Device* operator->() { return &detail::unwrap_direct(dev()); }
|
||||
private:
|
||||
template<typename T> // Used for forwarding.
|
||||
void open_impl(const T& t BOOST_IOSTREAMS_CONVERTER_PARAMS())
|
||||
{
|
||||
impl().open(t BOOST_IOSTREAMS_CONVERTER_ARGS());
|
||||
}
|
||||
|
||||
const codecvt_type& cvt() { return impl().cvt_.get(); }
|
||||
device_type& dev() { return impl().dev(); }
|
||||
buffer_type& in() { return impl().buf_.first(); }
|
||||
buffer_type& out() { return impl().buf_.second(); }
|
||||
impl_type& impl() { return *this->pimpl_; }
|
||||
};
|
||||
|
||||
//--------------Implementation of converter-----------------------------------//
|
||||
|
||||
// Implementation note: if end of stream contains a partial character,
|
||||
// it is ignored.
|
||||
template<typename Device, typename Codevt, typename Alloc>
|
||||
std::streamsize code_converter<Device, Codevt, Alloc>::read
|
||||
(char_type* s, std::streamsize n)
|
||||
{
|
||||
const extern_type* next; // Next external char.
|
||||
intern_type* nint; // Next internal char.
|
||||
std::streamsize total = 0; // Characters read.
|
||||
int status = iostreams::char_traits<char>::good();
|
||||
bool partial = false;
|
||||
buffer_type& buf = in();
|
||||
|
||||
do {
|
||||
|
||||
// Fill buffer.
|
||||
if (buf.ptr() == buf.eptr() || partial) {
|
||||
status = buf.fill(dev());
|
||||
if (buf.ptr() == buf.eptr())
|
||||
break;
|
||||
partial = false;
|
||||
}
|
||||
|
||||
// Convert.
|
||||
std::codecvt_base::result result =
|
||||
cvt().in( buf.state(),
|
||||
buf.ptr(), buf.eptr(), next,
|
||||
s + total, s + n, nint );
|
||||
buf.ptr() += next - buf.ptr();
|
||||
total = static_cast<std::streamsize>(nint - s);
|
||||
|
||||
switch (result) {
|
||||
case std::codecvt_base::partial:
|
||||
partial = true;
|
||||
break;
|
||||
case std::codecvt_base::ok:
|
||||
break;
|
||||
case std::codecvt_base::noconv:
|
||||
{
|
||||
std::streamsize amt =
|
||||
std::min<std::streamsize>(next - buf.ptr(), n - total);
|
||||
detail::strncpy_if_same(s + total, buf.ptr(), amt);
|
||||
total += amt;
|
||||
}
|
||||
break;
|
||||
case std::codecvt_base::error:
|
||||
default:
|
||||
buf.state() = state_type();
|
||||
boost::throw_exception(code_conversion_error());
|
||||
}
|
||||
|
||||
} while (total < n && status != EOF && status != WOULD_BLOCK);
|
||||
|
||||
return total == 0 && status == EOF ? -1 : total;
|
||||
}
|
||||
|
||||
template<typename Device, typename Codevt, typename Alloc>
|
||||
std::streamsize code_converter<Device, Codevt, Alloc>::write
|
||||
(const char_type* s, std::streamsize n)
|
||||
{
|
||||
buffer_type& buf = out();
|
||||
extern_type* next; // Next external char.
|
||||
const intern_type* nint; // Next internal char.
|
||||
std::streamsize total = 0; // Characters written.
|
||||
bool partial = false;
|
||||
|
||||
while (total < n) {
|
||||
|
||||
// Empty buffer.
|
||||
if (buf.eptr() == buf.end() || partial) {
|
||||
if (!buf.flush(dev()))
|
||||
break;
|
||||
partial = false;
|
||||
}
|
||||
|
||||
// Convert.
|
||||
std::codecvt_base::result result =
|
||||
cvt().out( buf.state(),
|
||||
s + total, s + n, nint,
|
||||
buf.eptr(), buf.end(), next );
|
||||
int progress = (int) (next - buf.eptr());
|
||||
buf.eptr() += progress;
|
||||
|
||||
switch (result) {
|
||||
case std::codecvt_base::partial:
|
||||
partial = true;
|
||||
BOOST_FALLTHROUGH;
|
||||
case std::codecvt_base::ok:
|
||||
total = static_cast<std::streamsize>(nint - s);
|
||||
break;
|
||||
case std::codecvt_base::noconv:
|
||||
{
|
||||
std::streamsize amt =
|
||||
std::min<std::streamsize>( nint - total - s,
|
||||
buf.end() - buf.eptr() );
|
||||
detail::strncpy_if_same(buf.eptr(), s + total, amt);
|
||||
total += amt;
|
||||
}
|
||||
break;
|
||||
case std::codecvt_base::error:
|
||||
default:
|
||||
buf.state() = state_type();
|
||||
boost::throw_exception(code_conversion_error());
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp> // Borland 5.x
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_CODE_CONVERTER_HPP_INCLUDED
|
@ -1,260 +0,0 @@
|
||||
// (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
|
||||
// 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.
|
||||
|
||||
// To do: add support for random-access.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_COMBINE_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_COMBINE_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> // NO_STD_LOCALE, DEDUCED_TYPENAME.
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
# include <locale>
|
||||
#endif
|
||||
#include <boost/iostreams/detail/ios.hpp>
|
||||
#include <boost/iostreams/detail/wrap_unwrap.hpp>
|
||||
#include <boost/iostreams/traits.hpp>
|
||||
#include <boost/iostreams/operations.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
// Must come last.
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp>
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
namespace detail {
|
||||
|
||||
//
|
||||
// Template name: combined_device.
|
||||
// Description: Model of Device defined in terms of a Source/Sink pair.
|
||||
// Template parameters:
|
||||
// Source - A model of Source, with the same char_type and traits_type
|
||||
// as Sink.
|
||||
// Sink - A model of Sink, with the same char_type and traits_type
|
||||
// as Source.
|
||||
//
|
||||
template<typename Source, typename Sink>
|
||||
class combined_device {
|
||||
private:
|
||||
typedef typename category_of<Source>::type in_category;
|
||||
typedef typename category_of<Sink>::type out_category;
|
||||
typedef typename char_type_of<Sink>::type sink_char_type;
|
||||
public:
|
||||
typedef typename char_type_of<Source>::type char_type;
|
||||
struct category
|
||||
: bidirectional,
|
||||
device_tag,
|
||||
closable_tag,
|
||||
localizable_tag
|
||||
{ };
|
||||
BOOST_STATIC_ASSERT(is_device<Source>::value);
|
||||
BOOST_STATIC_ASSERT(is_device<Sink>::value);
|
||||
BOOST_STATIC_ASSERT((is_convertible<in_category, input>::value));
|
||||
BOOST_STATIC_ASSERT((is_convertible<out_category, output>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<char_type, sink_char_type>::value));
|
||||
combined_device(const Source& src, const Sink& snk);
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
std::streamsize write(const char_type* s, std::streamsize n);
|
||||
void close(BOOST_IOS::openmode);
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
void imbue(const std::locale& loc);
|
||||
#endif
|
||||
private:
|
||||
Source src_;
|
||||
Sink sink_;
|
||||
};
|
||||
|
||||
//
|
||||
// Template name: combined_filter.
|
||||
// Description: Model of Device defined in terms of a Source/Sink pair.
|
||||
// Template parameters:
|
||||
// InputFilter - A model of InputFilter, with the same char_type as
|
||||
// OutputFilter.
|
||||
// OutputFilter - A model of OutputFilter, with the same char_type as
|
||||
// InputFilter.
|
||||
//
|
||||
template<typename InputFilter, typename OutputFilter>
|
||||
class combined_filter {
|
||||
private:
|
||||
typedef typename category_of<InputFilter>::type in_category;
|
||||
typedef typename category_of<OutputFilter>::type out_category;
|
||||
typedef typename char_type_of<OutputFilter>::type output_char_type;
|
||||
public:
|
||||
typedef typename char_type_of<InputFilter>::type char_type;
|
||||
struct category
|
||||
: multichar_bidirectional_filter_tag,
|
||||
closable_tag,
|
||||
localizable_tag
|
||||
{ };
|
||||
BOOST_STATIC_ASSERT(is_filter<InputFilter>::value);
|
||||
BOOST_STATIC_ASSERT(is_filter<OutputFilter>::value);
|
||||
BOOST_STATIC_ASSERT((is_convertible<in_category, input>::value));
|
||||
BOOST_STATIC_ASSERT((is_convertible<out_category, output>::value));
|
||||
BOOST_STATIC_ASSERT((is_same<char_type, output_char_type>::value));
|
||||
combined_filter(const InputFilter& in, const OutputFilter& out);
|
||||
|
||||
template<typename Source>
|
||||
std::streamsize read(Source& src, char_type* s, std::streamsize n)
|
||||
{ return boost::iostreams::read(in_, src, s, n); }
|
||||
|
||||
template<typename Sink>
|
||||
std::streamsize write(Sink& snk, const char_type* s, std::streamsize n)
|
||||
{ return boost::iostreams::write(out_, snk, s, n); }
|
||||
|
||||
template<typename Sink>
|
||||
void close(Sink& snk, BOOST_IOS::openmode which)
|
||||
{
|
||||
if (which == BOOST_IOS::in) {
|
||||
if (is_convertible<in_category, dual_use>::value) {
|
||||
iostreams::close(in_, snk, BOOST_IOS::in);
|
||||
} else {
|
||||
detail::close_all(in_, snk);
|
||||
}
|
||||
}
|
||||
if (which == BOOST_IOS::out) {
|
||||
if (is_convertible<out_category, dual_use>::value) {
|
||||
iostreams::close(out_, snk, BOOST_IOS::out);
|
||||
} else {
|
||||
detail::close_all(out_, snk);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
void imbue(const std::locale& loc);
|
||||
#endif
|
||||
private:
|
||||
InputFilter in_;
|
||||
OutputFilter out_;
|
||||
};
|
||||
|
||||
template<typename In, typename Out>
|
||||
struct combination_traits
|
||||
: mpl::if_<
|
||||
is_device<In>,
|
||||
combined_device<
|
||||
typename wrapped_type<In>::type,
|
||||
typename wrapped_type<Out>::type
|
||||
>,
|
||||
combined_filter<
|
||||
typename wrapped_type<In>::type,
|
||||
typename wrapped_type<Out>::type
|
||||
>
|
||||
>
|
||||
{ };
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
template<typename In, typename Out>
|
||||
struct combination : detail::combination_traits<In, Out>::type {
|
||||
typedef typename detail::combination_traits<In, Out>::type base_type;
|
||||
typedef typename detail::wrapped_type<In>::type in_type;
|
||||
typedef typename detail::wrapped_type<Out>::type out_type;
|
||||
combination(const in_type& in, const out_type& out)
|
||||
: base_type(in, out) { }
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Workaround for VC6 ETI bug.
|
||||
template<typename In, typename Out>
|
||||
struct combine_traits {
|
||||
typedef combination<
|
||||
BOOST_DEDUCED_TYPENAME detail::unwrapped_type<In>::type,
|
||||
BOOST_DEDUCED_TYPENAME detail::unwrapped_type<Out>::type
|
||||
> type;
|
||||
};
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
//
|
||||
// Template name: combine.
|
||||
// Description: Takes a Source/Sink pair or InputFilter/OutputFilter pair and
|
||||
// returns a Source or Filter which performs input using the first member
|
||||
// of the pair and output using the second member of the pair.
|
||||
// Template parameters:
|
||||
// In - A model of Source or InputFilter, with the same char_type as Out.
|
||||
// Out - A model of Sink or OutputFilter, with the same char_type as In.
|
||||
//
|
||||
template<typename In, typename Out>
|
||||
typename detail::combine_traits<In, Out>::type
|
||||
combine(const In& in, const Out& out)
|
||||
{
|
||||
typedef typename detail::combine_traits<In, Out>::type return_type;
|
||||
return return_type(in, out);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
namespace detail {
|
||||
|
||||
//--------------Implementation of combined_device-----------------------------//
|
||||
|
||||
template<typename Source, typename Sink>
|
||||
inline combined_device<Source, Sink>::combined_device
|
||||
(const Source& src, const Sink& snk)
|
||||
: src_(src), sink_(snk) { }
|
||||
|
||||
template<typename Source, typename Sink>
|
||||
inline std::streamsize
|
||||
combined_device<Source, Sink>::read(char_type* s, std::streamsize n)
|
||||
{ return iostreams::read(src_, s, n); }
|
||||
|
||||
template<typename Source, typename Sink>
|
||||
inline std::streamsize
|
||||
combined_device<Source, Sink>::write(const char_type* s, std::streamsize n)
|
||||
{ return iostreams::write(sink_, s, n); }
|
||||
|
||||
template<typename Source, typename Sink>
|
||||
inline void
|
||||
combined_device<Source, Sink>::close(BOOST_IOS::openmode which)
|
||||
{
|
||||
if (which == BOOST_IOS::in)
|
||||
detail::close_all(src_);
|
||||
if (which == BOOST_IOS::out)
|
||||
detail::close_all(sink_);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
template<typename Source, typename Sink>
|
||||
void combined_device<Source, Sink>::imbue(const std::locale& loc)
|
||||
{
|
||||
iostreams::imbue(src_, loc);
|
||||
iostreams::imbue(sink_, loc);
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------------Implementation of filter_pair---------------------------------//
|
||||
|
||||
template<typename InputFilter, typename OutputFilter>
|
||||
inline combined_filter<InputFilter, OutputFilter>::combined_filter
|
||||
(const InputFilter& in, const OutputFilter& out) : in_(in), out_(out)
|
||||
{ }
|
||||
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
template<typename InputFilter, typename OutputFilter>
|
||||
void combined_filter<InputFilter, OutputFilter>::imbue
|
||||
(const std::locale& loc)
|
||||
{
|
||||
iostreams::imbue(in_, loc);
|
||||
iostreams::imbue(out_, loc);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_COMBINE_HPP_INCLUDED
|
@ -1,493 +0,0 @@
|
||||
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
|
||||
// (C) Copyright 2005-2007 Jonathan Turkanis
|
||||
// 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: bidirectional streams are not supported.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_COMPOSE_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_COMPOSE_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <algorithm> // min.
|
||||
#include <utility> // pair.
|
||||
#include <boost/config.hpp> // DEDUCED_TYPENAME.
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/detail/adapter/direct_adapter.hpp>
|
||||
#include <boost/iostreams/detail/call_traits.hpp>
|
||||
#include <boost/iostreams/detail/enable_if_stream.hpp>
|
||||
#include <boost/iostreams/detail/execute.hpp>
|
||||
#include <boost/iostreams/detail/functional.hpp>
|
||||
#include <boost/iostreams/operations.hpp>
|
||||
#include <boost/iostreams/traits.hpp> // mode_of, is_direct.
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
// Must come last.
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template< typename First,
|
||||
typename Second,
|
||||
typename FirstMode =
|
||||
BOOST_DEDUCED_TYPENAME mode_of<First>::type,
|
||||
typename SecondMode =
|
||||
BOOST_DEDUCED_TYPENAME mode_of<Second>::type >
|
||||
struct composite_mode
|
||||
: select<
|
||||
is_convertible<SecondMode, FirstMode>, FirstMode,
|
||||
is_convertible<FirstMode, SecondMode>, SecondMode,
|
||||
is_convertible<SecondMode, input>, input,
|
||||
else_, output
|
||||
>
|
||||
{ };
|
||||
|
||||
//
|
||||
// Template name: composite_device.
|
||||
// Description: Provides a Device view of a Filter, Device pair.
|
||||
// Template parameters:
|
||||
// Filter - A model of Filter.
|
||||
// Device - An indirect model of Device.
|
||||
//
|
||||
template< typename Filter,
|
||||
typename Device,
|
||||
typename Mode =
|
||||
BOOST_DEDUCED_TYPENAME composite_mode<Filter, Device>::type >
|
||||
class composite_device {
|
||||
private:
|
||||
typedef typename detail::param_type<Device>::type param_type;
|
||||
typedef typename mode_of<Filter>::type filter_mode;
|
||||
typedef typename mode_of<Device>::type device_mode;
|
||||
typedef typename
|
||||
iostreams::select< // Disambiguation for Tru64.
|
||||
is_direct<Device>, direct_adapter<Device>,
|
||||
is_std_io<Device>, Device&,
|
||||
else_, Device
|
||||
>::type value_type;
|
||||
BOOST_STATIC_ASSERT(is_filter<Filter>::value);
|
||||
BOOST_STATIC_ASSERT(is_device<Device>::value);
|
||||
public:
|
||||
typedef typename char_type_of<Filter>::type char_type;
|
||||
struct category
|
||||
: Mode,
|
||||
device_tag,
|
||||
closable_tag,
|
||||
flushable_tag,
|
||||
localizable_tag,
|
||||
optimally_buffered_tag
|
||||
{ };
|
||||
composite_device(const Filter& flt, param_type dev);
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
std::streamsize write(const char_type* s, std::streamsize n);
|
||||
std::streampos seek( stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which =
|
||||
BOOST_IOS::in | BOOST_IOS::out );
|
||||
|
||||
void close();
|
||||
void close(BOOST_IOS::openmode which);
|
||||
bool flush();
|
||||
std::streamsize optimal_buffer_size() const;
|
||||
|
||||
template<typename Locale> // Avoid dependency on <locale>
|
||||
void imbue(const Locale& loc)
|
||||
{
|
||||
iostreams::imbue(filter_, loc);
|
||||
iostreams::imbue(device_, loc);
|
||||
}
|
||||
|
||||
Filter& first() { return filter_; }
|
||||
Device& second() { return device_; }
|
||||
private:
|
||||
Filter filter_;
|
||||
value_type device_;
|
||||
};
|
||||
|
||||
//
|
||||
// Template name: composite_device.
|
||||
// Description: Provides a Device view of a Filter, Device pair.
|
||||
// Template parameters:
|
||||
// Filter - A model of Filter.
|
||||
// Device - An indirect model of Device.
|
||||
//
|
||||
template< typename Filter1,
|
||||
typename Filter2,
|
||||
typename Mode =
|
||||
BOOST_DEDUCED_TYPENAME composite_mode<Filter1, Filter2>::type >
|
||||
class composite_filter {
|
||||
private:
|
||||
typedef reference_wrapper<Filter2> filter_ref;
|
||||
typedef typename mode_of<Filter1>::type first_mode;
|
||||
typedef typename mode_of<Filter2>::type second_mode;
|
||||
|
||||
// A dual-use filter cannot be composed with a read-write filter
|
||||
BOOST_STATIC_ASSERT(
|
||||
!(is_convertible<first_mode, dual_use>::value) ||
|
||||
!(is_convertible<second_mode, input>::value) ||
|
||||
!(is_convertible<second_mode, output>::value) ||
|
||||
(is_convertible<second_mode, dual_use>::value)
|
||||
);
|
||||
BOOST_STATIC_ASSERT(
|
||||
!(is_convertible<second_mode, dual_use>::value) ||
|
||||
!(is_convertible<first_mode, input>::value) ||
|
||||
!(is_convertible<first_mode, output>::value) ||
|
||||
(is_convertible<first_mode, dual_use>::value)
|
||||
);
|
||||
BOOST_STATIC_ASSERT(is_filter<Filter1>::value);
|
||||
BOOST_STATIC_ASSERT(is_filter<Filter2>::value);
|
||||
public:
|
||||
typedef typename char_type_of<Filter1>::type char_type;
|
||||
struct category
|
||||
: Mode,
|
||||
filter_tag,
|
||||
multichar_tag,
|
||||
closable_tag,
|
||||
flushable_tag,
|
||||
localizable_tag,
|
||||
optimally_buffered_tag
|
||||
{ };
|
||||
composite_filter(const Filter1& filter1, const Filter2& filter2)
|
||||
: filter1_(filter1), filter2_(filter2)
|
||||
{ }
|
||||
|
||||
template<typename Source>
|
||||
std::streamsize read(Source& src, char_type* s, std::streamsize n)
|
||||
{
|
||||
composite_device<filter_ref, Source> cmp(boost::ref(filter2_), src);
|
||||
return iostreams::read(filter1_, cmp, s, n);
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
std::streamsize write(Sink& snk, const char_type* s, std::streamsize n)
|
||||
{
|
||||
composite_device<filter_ref, Sink> cmp(boost::ref(filter2_), snk);
|
||||
return iostreams::write(filter1_, cmp, s, n);
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
std::streampos seek( Device& dev, stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which =
|
||||
BOOST_IOS::in | BOOST_IOS::out )
|
||||
{
|
||||
composite_device<filter_ref, Device> cmp(boost::ref(filter2_), dev);
|
||||
return iostreams::seek(filter1_, cmp, off, way, which);
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
void close(Device& dev)
|
||||
{
|
||||
BOOST_STATIC_ASSERT((!is_convertible<category, two_sequence>::value));
|
||||
BOOST_STATIC_ASSERT((!is_convertible<category, dual_use>::value));
|
||||
|
||||
// Create a new device by composing the second filter2_ with dev.
|
||||
composite_device<filter_ref, Device> cmp(boost::ref(filter2_), dev);
|
||||
|
||||
// Close input sequences in reverse order and output sequences in
|
||||
// forward order
|
||||
if (!is_convertible<first_mode, dual_use>::value) {
|
||||
detail::execute_all(
|
||||
detail::call_close(filter2_, dev, BOOST_IOS::in),
|
||||
detail::call_close(filter1_, cmp, BOOST_IOS::in),
|
||||
detail::call_close(filter1_, cmp, BOOST_IOS::out),
|
||||
detail::call_close(filter2_, dev, BOOST_IOS::out)
|
||||
);
|
||||
} else if (is_convertible<second_mode, input>::value) {
|
||||
detail::execute_all(
|
||||
detail::call_close(filter2_, dev, BOOST_IOS::in),
|
||||
detail::call_close(filter1_, cmp, BOOST_IOS::in)
|
||||
);
|
||||
} else {
|
||||
detail::execute_all(
|
||||
detail::call_close(filter1_, cmp, BOOST_IOS::out),
|
||||
detail::call_close(filter2_, dev, BOOST_IOS::out)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
void close(Device& dev, BOOST_IOS::openmode which)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(
|
||||
(is_convertible<category, two_sequence>::value) ||
|
||||
(is_convertible<category, dual_use>::value)
|
||||
);
|
||||
|
||||
// Create a new device by composing the second filter2_ with dev.
|
||||
composite_device<filter_ref, Device> cmp(boost::ref(filter2_), dev);
|
||||
|
||||
// Close input sequences in reverse order
|
||||
if ( which == BOOST_IOS::in &&
|
||||
( !is_convertible<first_mode, dual_use>::value ||
|
||||
is_convertible<second_mode, input>::value ) )
|
||||
{
|
||||
detail::execute_all(
|
||||
detail::call_close(filter2_, dev, BOOST_IOS::in),
|
||||
detail::call_close(filter1_, cmp, BOOST_IOS::in)
|
||||
);
|
||||
}
|
||||
|
||||
// Close output sequences in forward order
|
||||
if ( which == BOOST_IOS::out &&
|
||||
( !is_convertible<first_mode, dual_use>::value ||
|
||||
is_convertible<second_mode, output>::value ) )
|
||||
{
|
||||
detail::execute_all(
|
||||
detail::call_close(filter1_, cmp, BOOST_IOS::out),
|
||||
detail::call_close(filter2_, dev, BOOST_IOS::out)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
bool flush(Device& dev)
|
||||
{
|
||||
composite_device<Filter2, Device> cmp(filter2_, dev);
|
||||
return iostreams::flush(filter1_, cmp);
|
||||
}
|
||||
|
||||
std::streamsize optimal_buffer_size() const
|
||||
{
|
||||
std::streamsize first = iostreams::optimal_buffer_size(filter1_);
|
||||
std::streamsize second = iostreams::optimal_buffer_size(filter2_);
|
||||
return first < second ? second : first;
|
||||
}
|
||||
|
||||
template<typename Locale> // Avoid dependency on <locale>
|
||||
void imbue(const Locale& loc)
|
||||
{ // To do: consider using RAII.
|
||||
iostreams::imbue(filter1_, loc);
|
||||
iostreams::imbue(filter2_, loc);
|
||||
}
|
||||
|
||||
Filter1& first() { return filter1_; }
|
||||
Filter2& second() { return filter2_; }
|
||||
private:
|
||||
Filter1 filter1_;
|
||||
Filter2 filter2_;
|
||||
};
|
||||
|
||||
template<typename Filter, typename FilterOrDevice>
|
||||
struct composite_traits
|
||||
: mpl::if_<
|
||||
is_device<FilterOrDevice>,
|
||||
composite_device<Filter, FilterOrDevice>,
|
||||
composite_filter<Filter, FilterOrDevice>
|
||||
>
|
||||
{ };
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
template<typename Filter, typename FilterOrDevice>
|
||||
struct composite : detail::composite_traits<Filter, FilterOrDevice>::type {
|
||||
typedef typename detail::param_type<FilterOrDevice>::type param_type;
|
||||
typedef typename detail::composite_traits<Filter, FilterOrDevice>::type base;
|
||||
composite(const Filter& flt, param_type dev)
|
||||
: base(flt, dev)
|
||||
{ }
|
||||
};
|
||||
|
||||
//--------------Implementation of compose-------------------------------------//
|
||||
|
||||
// Note: The following workarounds are patterned after resolve.hpp. It has not
|
||||
// yet been confirmed that they are necessary.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //-------------------------//
|
||||
# ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //-------------------------------//
|
||||
|
||||
template<typename Filter, typename FilterOrDevice>
|
||||
composite<Filter, FilterOrDevice>
|
||||
compose( const Filter& filter, const FilterOrDevice& fod
|
||||
BOOST_IOSTREAMS_DISABLE_IF_STREAM(FilterOrDevice) )
|
||||
{ return composite<Filter, FilterOrDevice>(filter, fod); }
|
||||
|
||||
template<typename Filter, typename Ch, typename Tr>
|
||||
composite< Filter, std::basic_streambuf<Ch, Tr> >
|
||||
compose(const Filter& filter, std::basic_streambuf<Ch, Tr>& sb)
|
||||
{ return composite< Filter, std::basic_streambuf<Ch, Tr> >(filter, sb); }
|
||||
|
||||
template<typename Filter, typename Ch, typename Tr>
|
||||
composite< Filter, std::basic_istream<Ch, Tr> >
|
||||
compose(const Filter& filter, std::basic_istream<Ch, Tr>& is)
|
||||
{ return composite< Filter, std::basic_istream<Ch, Tr> >(filter, is); }
|
||||
|
||||
template<typename Filter, typename Ch, typename Tr>
|
||||
composite< Filter, std::basic_ostream<Ch, Tr> >
|
||||
compose(const Filter& filter, std::basic_ostream<Ch, Tr>& os)
|
||||
{ return composite< Filter, std::basic_ostream<Ch, Tr> >(filter, os); }
|
||||
|
||||
template<typename Filter, typename Ch, typename Tr>
|
||||
composite< Filter, std::basic_iostream<Ch, Tr> >
|
||||
compose(const Filter& filter, std::basic_iostream<Ch, Tr>& io)
|
||||
{ return composite< Filter, std::basic_iostream<Ch, Tr> >(filter, io); }
|
||||
|
||||
# else // # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //---------------------//
|
||||
|
||||
template<typename Filter, typename FilterOrDevice>
|
||||
composite<Filter, FilterOrDevice>
|
||||
compose( const Filter& filter, const FilterOrDevice& fod
|
||||
BOOST_IOSTREAMS_DISABLE_IF_STREAM(FilterOrDevice) )
|
||||
{ return composite<Filter, FilterOrDevice>(filter, fod); }
|
||||
|
||||
template<typename Filter>
|
||||
composite<Filter, std::streambuf>
|
||||
compose(const Filter& filter, std::streambuf& sb)
|
||||
{ return composite<Filter, std::streambuf>(filter, sb); }
|
||||
|
||||
template<typename Filter>
|
||||
composite<Filter, std::istream>
|
||||
compose(const Filter& filter, std::istream& is)
|
||||
{ return composite<Filter, std::istream>(filter, is); }
|
||||
|
||||
template<typename Filter>
|
||||
composite<Filter, std::ostream>
|
||||
compose(const Filter& filter, std::ostream& os)
|
||||
{ return composite<Filter, std::ostream>(filter, os); }
|
||||
|
||||
template<typename Filter>
|
||||
composite<Filter, std::iostream>
|
||||
compose(const Filter& filter, std::iostream& io)
|
||||
{ return composite<Filter, std::iostream>(filter, io); }
|
||||
|
||||
# endif // # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //--------------------//
|
||||
#else // #ifndef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //----------------//
|
||||
|
||||
template<typename Filter, typename Stream>
|
||||
composite<Filter, Stream>
|
||||
compose(const Filter& flt, const Stream& strm, mpl::true_)
|
||||
{ // Bad overload resolution.
|
||||
return composite<Filter, Stream>(flt, const_cast<Stream&>(strm));
|
||||
}
|
||||
|
||||
template<typename Filter, typename FilterOrDevice>
|
||||
composite<Filter, FilterOrDevice>
|
||||
compose(const Filter& flt, const FilterOrDevice& fod, mpl::false_)
|
||||
{ return composite<Filter, FilterOrDevice>(flt, fod); }
|
||||
|
||||
template<typename Filter, typename FilterOrDevice>
|
||||
composite<Filter, FilterOrDevice>
|
||||
compose( const Filter& flt, const FilterOrDevice& fod
|
||||
BOOST_IOSTREAMS_DISABLE_IF_STREAM(T) )
|
||||
{ return compose(flt, fod, is_std_io<FilterOrDevice>()); }
|
||||
|
||||
# if !BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600) && \
|
||||
!defined(__GNUC__) // ---------------------------------------------------//
|
||||
|
||||
template<typename Filter, typename FilterOrDevice>
|
||||
composite<Filter, FilterOrDevice>
|
||||
compose (const Filter& filter, FilterOrDevice& fod)
|
||||
{ return composite<Filter, FilterOrDevice>(filter, fod); }
|
||||
|
||||
# endif // Borland 5.x or GCC //--------------------------------//
|
||||
#endif // #ifndef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //---------------//
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
namespace detail {
|
||||
|
||||
//--------------Implementation of composite_device---------------------------//
|
||||
|
||||
template<typename Filter, typename Device, typename Mode>
|
||||
composite_device<Filter, Device, Mode>::composite_device
|
||||
(const Filter& flt, param_type dev)
|
||||
: filter_(flt), device_(dev)
|
||||
{ }
|
||||
|
||||
template<typename Filter, typename Device, typename Mode>
|
||||
inline std::streamsize composite_device<Filter, Device, Mode>::read
|
||||
(char_type* s, std::streamsize n)
|
||||
{ return iostreams::read(filter_, device_, s, n); }
|
||||
|
||||
template<typename Filter, typename Device, typename Mode>
|
||||
inline std::streamsize composite_device<Filter, Device, Mode>::write
|
||||
(const char_type* s, std::streamsize n)
|
||||
{ return iostreams::write(filter_, device_, s, n); }
|
||||
|
||||
template<typename Filter, typename Device, typename Mode>
|
||||
std::streampos composite_device<Filter, Device, Mode>::seek
|
||||
(stream_offset off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which)
|
||||
{ return iostreams::seek(filter_, device_, off, way, which); }
|
||||
|
||||
template<typename Filter, typename Device, typename Mode>
|
||||
void composite_device<Filter, Device, Mode>::close()
|
||||
{
|
||||
BOOST_STATIC_ASSERT((!is_convertible<Mode, two_sequence>::value));
|
||||
BOOST_STATIC_ASSERT(
|
||||
!(is_convertible<filter_mode, dual_use>::value) ||
|
||||
!(is_convertible<device_mode, input>::value) ||
|
||||
!(is_convertible<device_mode, output>::value)
|
||||
);
|
||||
|
||||
// Close input sequences in reverse order and output sequences
|
||||
// in forward order
|
||||
if (!is_convertible<filter_mode, dual_use>::value) {
|
||||
detail::execute_all(
|
||||
detail::call_close(device_, BOOST_IOS::in),
|
||||
detail::call_close(filter_, device_, BOOST_IOS::in),
|
||||
detail::call_close(filter_, device_, BOOST_IOS::out),
|
||||
detail::call_close(device_, BOOST_IOS::out)
|
||||
);
|
||||
} else if (is_convertible<device_mode, input>::value) {
|
||||
detail::execute_all(
|
||||
detail::call_close(device_, BOOST_IOS::in),
|
||||
detail::call_close(filter_, device_, BOOST_IOS::in)
|
||||
);
|
||||
} else {
|
||||
detail::execute_all(
|
||||
detail::call_close(filter_, device_, BOOST_IOS::out),
|
||||
detail::call_close(device_, BOOST_IOS::out)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Filter, typename Device, typename Mode>
|
||||
void composite_device<Filter, Device, Mode>::close(BOOST_IOS::openmode which)
|
||||
{
|
||||
BOOST_STATIC_ASSERT((is_convertible<Mode, two_sequence>::value));
|
||||
BOOST_STATIC_ASSERT(!(is_convertible<filter_mode, dual_use>::value));
|
||||
|
||||
// Close input sequences in reverse order
|
||||
if (which == BOOST_IOS::in) {
|
||||
detail::execute_all(
|
||||
detail::call_close(device_, BOOST_IOS::in),
|
||||
detail::call_close(filter_, device_, BOOST_IOS::in)
|
||||
);
|
||||
}
|
||||
|
||||
// Close output sequences in forward order
|
||||
if (which == BOOST_IOS::out) {
|
||||
detail::execute_all(
|
||||
detail::call_close(filter_, device_, BOOST_IOS::out),
|
||||
detail::call_close(device_, BOOST_IOS::out)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Filter, typename Device, typename Mode>
|
||||
bool composite_device<Filter, Device, Mode>::flush()
|
||||
{
|
||||
bool r1 = iostreams::flush(filter_, device_);
|
||||
bool r2 = iostreams::flush(device_);
|
||||
return r1 && r2;
|
||||
}
|
||||
|
||||
template<typename Filter, typename Device, typename Mode>
|
||||
std::streamsize
|
||||
composite_device<Filter, Device, Mode>::optimal_buffer_size() const
|
||||
{ return iostreams::optimal_buffer_size(device_); }
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_COMPOSE_HPP_INCLUDED
|
@ -1,248 +0,0 @@
|
||||
// (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
|
||||
// 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.
|
||||
|
||||
// Contains: The function template copy, which reads data from a Source
|
||||
// and writes it to a Sink until the end of the sequence is reached, returning
|
||||
// the number of characters transfered.
|
||||
|
||||
// The implementation is complicated by the need to handle smart adapters
|
||||
// and direct devices.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_COPY_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_COPY_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> // Make sure ptrdiff_t is in std.
|
||||
#include <algorithm> // copy, min.
|
||||
#include <cstddef> // ptrdiff_t.
|
||||
#include <utility> // pair.
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/iostreams/chain.hpp>
|
||||
#include <boost/iostreams/constants.hpp>
|
||||
#include <boost/iostreams/detail/adapter/non_blocking_adapter.hpp>
|
||||
#include <boost/iostreams/detail/buffer.hpp>
|
||||
#include <boost/iostreams/detail/enable_if_stream.hpp>
|
||||
#include <boost/iostreams/detail/execute.hpp>
|
||||
#include <boost/iostreams/detail/functional.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // failure, streamsize.
|
||||
#include <boost/iostreams/detail/resolve.hpp>
|
||||
#include <boost/iostreams/detail/wrap_unwrap.hpp>
|
||||
#include <boost/iostreams/operations.hpp> // read, write, close.
|
||||
#include <boost/iostreams/pipeline.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
namespace detail {
|
||||
|
||||
// The following four overloads of copy_impl() optimize
|
||||
// copying in the case that one or both of the two devices
|
||||
// models Direct (see
|
||||
// http://www.boost.org/libs/iostreams/doc/index.html?path=4.1.1.4)
|
||||
|
||||
// Copy from a direct source to a direct sink
|
||||
template<typename Source, typename Sink>
|
||||
std::streamsize copy_impl( Source& src, Sink& snk,
|
||||
std::streamsize /* buffer_size */,
|
||||
mpl::true_, mpl::true_ )
|
||||
{
|
||||
using namespace std;
|
||||
typedef typename char_type_of<Source>::type char_type;
|
||||
typedef std::pair<char_type*, char_type*> pair_type;
|
||||
pair_type p1 = iostreams::input_sequence(src);
|
||||
pair_type p2 = iostreams::output_sequence(snk);
|
||||
std::streamsize total =
|
||||
static_cast<std::streamsize>(
|
||||
(std::min)(p1.second - p1.first, p2.second - p2.first)
|
||||
);
|
||||
std::copy(p1.first, p1.first + total, p2.first);
|
||||
return total;
|
||||
}
|
||||
|
||||
// Copy from a direct source to an indirect sink
|
||||
template<typename Source, typename Sink>
|
||||
std::streamsize copy_impl( Source& src, Sink& snk,
|
||||
std::streamsize /* buffer_size */,
|
||||
mpl::true_, mpl::false_ )
|
||||
{
|
||||
using namespace std;
|
||||
typedef typename char_type_of<Source>::type char_type;
|
||||
typedef std::pair<char_type*, char_type*> pair_type;
|
||||
pair_type p = iostreams::input_sequence(src);
|
||||
std::streamsize size, total;
|
||||
for ( total = 0, size = static_cast<std::streamsize>(p.second - p.first);
|
||||
total < size; )
|
||||
{
|
||||
std::streamsize amt =
|
||||
iostreams::write(snk, p.first + total, size - total);
|
||||
total += amt;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
// Copy from an indirect source to a direct sink
|
||||
template<typename Source, typename Sink>
|
||||
std::streamsize copy_impl( Source& src, Sink& snk,
|
||||
std::streamsize buffer_size,
|
||||
mpl::false_, mpl::true_ )
|
||||
{
|
||||
typedef typename char_type_of<Source>::type char_type;
|
||||
typedef std::pair<char_type*, char_type*> pair_type;
|
||||
detail::basic_buffer<char_type> buf(buffer_size);
|
||||
pair_type p = snk.output_sequence();
|
||||
std::streamsize total = 0;
|
||||
std::ptrdiff_t capacity = p.second - p.first;
|
||||
while (true) {
|
||||
std::streamsize amt =
|
||||
iostreams::read(
|
||||
src,
|
||||
buf.data(),
|
||||
buffer_size < capacity - total ?
|
||||
buffer_size :
|
||||
static_cast<std::streamsize>(capacity - total)
|
||||
);
|
||||
if (amt == -1)
|
||||
break;
|
||||
std::copy(buf.data(), buf.data() + amt, p.first + total);
|
||||
total += amt;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
// Copy from an indirect source to an indirect sink
|
||||
template<typename Source, typename Sink>
|
||||
std::streamsize copy_impl( Source& src, Sink& snk,
|
||||
std::streamsize buffer_size,
|
||||
mpl::false_, mpl::false_ )
|
||||
{
|
||||
typedef typename char_type_of<Source>::type char_type;
|
||||
detail::basic_buffer<char_type> buf(buffer_size);
|
||||
non_blocking_adapter<Sink> nb(snk);
|
||||
std::streamsize total = 0;
|
||||
bool done = false;
|
||||
while (!done) {
|
||||
std::streamsize amt;
|
||||
done = (amt = iostreams::read(src, buf.data(), buffer_size)) == -1;
|
||||
if (amt != -1) {
|
||||
iostreams::write(nb, buf.data(), amt);
|
||||
total += amt;
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
// The following function object is used with
|
||||
// boost::iostreams::detail::execute() in the primary
|
||||
// overload of copy_impl(), below
|
||||
|
||||
// Function object that delegates to one of the above four
|
||||
// overloads of compl_impl()
|
||||
template<typename Source, typename Sink>
|
||||
class copy_operation {
|
||||
public:
|
||||
typedef std::streamsize result_type;
|
||||
copy_operation(Source& src, Sink& snk, std::streamsize buffer_size)
|
||||
: src_(src), snk_(snk), buffer_size_(buffer_size)
|
||||
{ }
|
||||
std::streamsize operator()()
|
||||
{
|
||||
return copy_impl( src_, snk_, buffer_size_,
|
||||
is_direct<Source>(), is_direct<Sink>() );
|
||||
}
|
||||
private:
|
||||
copy_operation& operator=(const copy_operation&);
|
||||
Source& src_;
|
||||
Sink& snk_;
|
||||
std::streamsize buffer_size_;
|
||||
};
|
||||
|
||||
// Primary overload of copy_impl. Delegates to one of the above four
|
||||
// overloads of compl_impl(), depending on which of the two given
|
||||
// devices, if any, models Direct (see
|
||||
// http://www.boost.org/libs/iostreams/doc/index.html?path=4.1.1.4)
|
||||
template<typename Source, typename Sink>
|
||||
std::streamsize copy_impl(Source src, Sink snk, std::streamsize buffer_size)
|
||||
{
|
||||
using namespace std;
|
||||
typedef typename char_type_of<Source>::type src_char;
|
||||
typedef typename char_type_of<Sink>::type snk_char;
|
||||
BOOST_STATIC_ASSERT((is_same<src_char, snk_char>::value));
|
||||
return detail::execute_all(
|
||||
copy_operation<Source, Sink>(src, snk, buffer_size),
|
||||
detail::call_close_all(src),
|
||||
detail::call_close_all(snk)
|
||||
);
|
||||
}
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
//------------------Definition of copy----------------------------------------//
|
||||
|
||||
// Overload of copy() for the case where neither the source nor the sink is
|
||||
// a standard stream or stream buffer
|
||||
template<typename Source, typename Sink>
|
||||
std::streamsize
|
||||
copy( const Source& src, const Sink& snk,
|
||||
std::streamsize buffer_size = default_device_buffer_size
|
||||
BOOST_IOSTREAMS_DISABLE_IF_STREAM(Source)
|
||||
BOOST_IOSTREAMS_DISABLE_IF_STREAM(Sink) )
|
||||
{
|
||||
typedef typename char_type_of<Source>::type char_type;
|
||||
return detail::copy_impl( detail::resolve<input, char_type>(src),
|
||||
detail::resolve<output, char_type>(snk),
|
||||
buffer_size );
|
||||
}
|
||||
|
||||
// Overload of copy() for the case where the source, but not the sink, is
|
||||
// a standard stream or stream buffer
|
||||
template<typename Source, typename Sink>
|
||||
std::streamsize
|
||||
copy( Source& src, const Sink& snk,
|
||||
std::streamsize buffer_size = default_device_buffer_size
|
||||
BOOST_IOSTREAMS_ENABLE_IF_STREAM(Source)
|
||||
BOOST_IOSTREAMS_DISABLE_IF_STREAM(Sink) )
|
||||
{
|
||||
typedef typename char_type_of<Source>::type char_type;
|
||||
return detail::copy_impl( detail::wrap(src),
|
||||
detail::resolve<output, char_type>(snk),
|
||||
buffer_size );
|
||||
}
|
||||
|
||||
// Overload of copy() for the case where the sink, but not the source, is
|
||||
// a standard stream or stream buffer
|
||||
template<typename Source, typename Sink>
|
||||
std::streamsize
|
||||
copy( const Source& src, Sink& snk,
|
||||
std::streamsize buffer_size = default_device_buffer_size
|
||||
BOOST_IOSTREAMS_DISABLE_IF_STREAM(Source)
|
||||
BOOST_IOSTREAMS_ENABLE_IF_STREAM(Sink) )
|
||||
{
|
||||
typedef typename char_type_of<Source>::type char_type;
|
||||
return detail::copy_impl( detail::resolve<input, char_type>(src),
|
||||
detail::wrap(snk), buffer_size );
|
||||
}
|
||||
|
||||
// Overload of copy() for the case where neither the source nor the sink is
|
||||
// a standard stream or stream buffer
|
||||
template<typename Source, typename Sink>
|
||||
std::streamsize
|
||||
copy( Source& src, Sink& snk,
|
||||
std::streamsize buffer_size = default_device_buffer_size
|
||||
BOOST_IOSTREAMS_ENABLE_IF_STREAM(Source)
|
||||
BOOST_IOSTREAMS_ENABLE_IF_STREAM(Sink) )
|
||||
{
|
||||
return detail::copy_impl(detail::wrap(src), detail::wrap(snk), buffer_size);
|
||||
}
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_COPY_HPP_INCLUDED
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
* Date: Thu Dec 06 13:21:54 MST 2007
|
||||
* Copyright: 2007-2008 CodeRage, LLC
|
||||
* Author: Jonathan Turkanis
|
||||
* Contact: turkanis at coderage dot com
|
||||
*
|
||||
* Defines the function boost::iostreams::detail::absolute_path, used for
|
||||
* debug output for mapped files.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <boost/iostreams/detail/config/windows_posix.hpp>
|
||||
#ifdef BOOST_IOSTREAMS_WINDOWS
|
||||
# include <cctype>
|
||||
#endif
|
||||
#include <boost/iostreams/detail/current_directory.hpp>
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
// Resolves the given path relative to the current working directory
|
||||
inline std::string absolute_path(const std::string& path)
|
||||
{
|
||||
#ifdef BOOST_IOSTREAMS_WINDOWS
|
||||
return path.size() && (path[0] == '/' || path[0] == '\\') ||
|
||||
path.size() > 1 && std::isalpha(path[0]) && path[1] == ':' ?
|
||||
path :
|
||||
current_directory() + '\\' + path;
|
||||
#else // #ifdef BOOST_IOSTREAMS_WINDOWS
|
||||
return path.size() && (path[0] == '/') ?
|
||||
path :
|
||||
current_directory() + '/' + path;
|
||||
#endif // #ifdef BOOST_IOSTREAMS_WINDOWS
|
||||
}
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED
|
@ -1,87 +0,0 @@
|
||||
// (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
|
||||
// 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.
|
||||
|
||||
// Contains the definition of the class template access_control, which
|
||||
// allows the type of inheritance from a provided base class to be specified
|
||||
// using a template parameter.
|
||||
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/iostreams/detail/select.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
struct protected_ { }; // Represents protected inheritance.
|
||||
struct public_ { }; // Represents public inheritance.
|
||||
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Implements protected inheritance.
|
||||
template<typename U>
|
||||
struct prot_ : protected U
|
||||
{
|
||||
prot_() { }
|
||||
template<typename V> prot_(V v) : U(v) { }
|
||||
};
|
||||
|
||||
// Implements public inheritance.
|
||||
template<typename U> struct pub_ : public U {
|
||||
pub_() { }
|
||||
template<typename V> pub_(V v) : U(v) { }
|
||||
};
|
||||
|
||||
//
|
||||
// Used to deduce the base type for the template access_control.
|
||||
//
|
||||
template<typename T, typename Access>
|
||||
struct access_control_base {
|
||||
typedef int bad_access_specifier;
|
||||
typedef typename
|
||||
iostreams::select< // Disambiguation for Tru64
|
||||
::boost::is_same<
|
||||
Access, protected_
|
||||
>, prot_<T>,
|
||||
::boost::is_same<
|
||||
Access, public_
|
||||
>, pub_<T>,
|
||||
else_, bad_access_specifier
|
||||
>::type type;
|
||||
};
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
//
|
||||
// Template name: access_control.
|
||||
// Description: Allows the type of inheritance from a provided base class
|
||||
// to be specified using an int template parameter.
|
||||
// Template parameters:
|
||||
// Base - The class from which to inherit (indirectly.)
|
||||
// Access - The type of access desired. Must be one of the
|
||||
// values access_base::prot or access_base::pub.
|
||||
//
|
||||
template< typename T, typename Access,
|
||||
typename Base = // VC6 workaraound (Compiler Error C2516)
|
||||
typename detail::access_control_base<T, Access>::type >
|
||||
struct access_control : public Base {
|
||||
access_control() { }
|
||||
template<typename U> explicit access_control(U u) : Base(u) { }
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Defines the class template boost::iostreams::detail::device_adapter,
|
||||
* a convenience base class for device adapters.
|
||||
*
|
||||
* File: boost/iostreams/detail/adapter/filter_adapter.hpp
|
||||
* Date: Mon Nov 26 14:35:48 MST 2007
|
||||
*
|
||||
* Copyright: 2007-2008 CodeRage, LLC
|
||||
* Author: Jonathan Turkanis
|
||||
* Contact: turkanis at coderage dot com
|
||||
*
|
||||
* 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_DETAIL_DEVICE_ADAPTER_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_DEVICE_ADAPTER_HPP_INCLUDED
|
||||
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/detail/call_traits.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp>
|
||||
#include <boost/iostreams/operations.hpp>
|
||||
#include <boost/iostreams/traits.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
template<typename T>
|
||||
class device_adapter {
|
||||
private:
|
||||
typedef typename detail::value_type<T>::type value_type;
|
||||
typedef typename detail::param_type<T>::type param_type;
|
||||
public:
|
||||
explicit device_adapter(param_type t) : t_(t) { }
|
||||
T& component() { return t_; }
|
||||
|
||||
void close()
|
||||
{
|
||||
detail::close_all(t_);
|
||||
}
|
||||
|
||||
void close(BOOST_IOS::openmode which)
|
||||
{
|
||||
iostreams::close(t_, which);
|
||||
}
|
||||
|
||||
bool flush()
|
||||
{
|
||||
return iostreams::flush(t_);
|
||||
}
|
||||
|
||||
template<typename Locale> // Avoid dependency on <locale>
|
||||
void imbue(const Locale& loc) { iostreams::imbue(t_, loc); }
|
||||
|
||||
std::streamsize optimal_buffer_size() const
|
||||
{ return iostreams::optimal_buffer_size(t_); }
|
||||
public:
|
||||
value_type t_;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_DEVICE_ADAPTER_HPP_INCLUDED
|
@ -1,282 +0,0 @@
|
||||
// (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
|
||||
// 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_DETAIL_DIRECT_ADAPTER_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_DIRECT_ADAPTER_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> // SFINAE, MSVC, put ptrdiff_t in std.
|
||||
#include <algorithm> // copy, min.
|
||||
#include <cstddef> // ptrdiff_t.
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/detail/config/limits.hpp> // forwarding.
|
||||
#include <boost/iostreams/detail/config/wide_streams.hpp> // locale.
|
||||
#include <boost/iostreams/detail/double_object.hpp>
|
||||
#include <boost/iostreams/detail/error.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // openmode, seekdir, int types.
|
||||
#include <boost/iostreams/traits.hpp> // mode_of, is_direct.
|
||||
#include <boost/iostreams/operations.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/preprocessor/iteration/local.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
// Must come last.
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp> // VC7.1
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
//------------------Definition of direct_adapter_base-------------------------//
|
||||
|
||||
// Put all initialization in base class to faciliate forwarding.
|
||||
template<typename Direct>
|
||||
class direct_adapter_base {
|
||||
public:
|
||||
typedef typename char_type_of<Direct>::type char_type;
|
||||
typedef typename mode_of<Direct>::type mode_type;
|
||||
struct category
|
||||
: mode_type,
|
||||
device_tag,
|
||||
closable_tag
|
||||
#ifndef BOOST_IOSTREAMS_NO_LOCALE
|
||||
, localizable_tag
|
||||
#endif
|
||||
{ };
|
||||
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_);
|
||||
void init_input(mpl::false_) { }
|
||||
void init_output(mpl::true_);
|
||||
void init_output(mpl::false_) { }
|
||||
double_object<pointers, is_double> ptrs_;
|
||||
Direct d_;
|
||||
};
|
||||
|
||||
template<typename Direct>
|
||||
class direct_adapter : private direct_adapter_base<Direct> {
|
||||
private:
|
||||
typedef direct_adapter_base<Direct> base_type;
|
||||
typedef typename base_type::pointers pointers;
|
||||
typedef typename base_type::is_double is_double;
|
||||
using base_type::ptrs_;
|
||||
using base_type::d_;
|
||||
public:
|
||||
typedef typename base_type::char_type char_type;
|
||||
typedef typename base_type::category category;
|
||||
|
||||
// Constructors
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
|
||||
direct_adapter(const Direct& d) : base_type(d) { }
|
||||
direct_adapter(const direct_adapter& d) : base_type(d) { }
|
||||
# define BOOST_PP_LOCAL_LIMITS (1, BOOST_IOSTREAMS_MAX_FORWARDING_ARITY)
|
||||
#else
|
||||
template<typename U>
|
||||
struct is_direct
|
||||
: mpl::or_<
|
||||
is_same<U, direct_adapter<Direct> >,
|
||||
is_same<U, Direct>
|
||||
>
|
||||
{ };
|
||||
template<typename U>
|
||||
direct_adapter(const U& u)
|
||||
: base_type(forward(u, is_direct<U>()))
|
||||
{ }
|
||||
# define BOOST_PP_LOCAL_LIMITS (2, BOOST_IOSTREAMS_MAX_FORWARDING_ARITY)
|
||||
#endif
|
||||
|
||||
#define BOOST_PP_LOCAL_MACRO(n) \
|
||||
template<BOOST_PP_ENUM_PARAMS(n, typename P)> \
|
||||
direct_adapter(BOOST_PP_ENUM_BINARY_PARAMS(n, const P, &p)) \
|
||||
: base_type(Direct(BOOST_PP_ENUM_PARAMS(n, p))) \
|
||||
{ } \
|
||||
/**/
|
||||
#include BOOST_PP_LOCAL_ITERATE()
|
||||
#undef BOOST_PP_LOCAL_MACRO
|
||||
|
||||
// Device interface.
|
||||
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
std::streamsize write(const char_type* s, std::streamsize n);
|
||||
std::streampos seek( stream_offset, BOOST_IOS::seekdir,
|
||||
BOOST_IOS::openmode = BOOST_IOS::in | BOOST_IOS::out );
|
||||
void close();
|
||||
void close(BOOST_IOS::openmode which);
|
||||
#ifndef BOOST_IOSTREAMS_NO_LOCALE
|
||||
void imbue(const std::locale&);
|
||||
#endif
|
||||
|
||||
// Direct device access.
|
||||
|
||||
Direct& operator*() { return d_; }
|
||||
Direct* operator->() { return &d_; }
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
|
||||
private:
|
||||
template<typename U>
|
||||
static Direct forward(const U& u, mpl::true_) { return u; }
|
||||
template<typename U>
|
||||
static Direct forward(const U& u, mpl::false_) { return Direct(u); }
|
||||
#endif
|
||||
};
|
||||
|
||||
//--------------Definition of wrap_direct and unwrap_direct-------------------//
|
||||
|
||||
template<typename Device>
|
||||
struct wrap_direct_traits
|
||||
: mpl::if_<
|
||||
is_direct<Device>,
|
||||
direct_adapter<Device>,
|
||||
Device
|
||||
>
|
||||
{ };
|
||||
|
||||
template<typename Device>
|
||||
typename wrap_direct_traits<Device>::type
|
||||
inline wrap_direct(Device dev)
|
||||
{
|
||||
typedef typename wrap_direct_traits<Device>::type type;
|
||||
return type(dev);
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
inline Device& unwrap_direct(Device& d) { return d; }
|
||||
|
||||
template<typename Device>
|
||||
inline Device& unwrap_direct(direct_adapter<Device>& d) { return *d; }
|
||||
|
||||
//--------------Implementation of direct_adapter_base-------------------------//
|
||||
|
||||
template<typename Direct>
|
||||
direct_adapter_base<Direct>::direct_adapter_base(const Direct& d) : d_(d)
|
||||
{
|
||||
init_input(is_convertible<category, input>());
|
||||
init_output(is_convertible<category, output>());
|
||||
}
|
||||
|
||||
template<typename Direct>
|
||||
void direct_adapter_base<Direct>::init_input(mpl::true_)
|
||||
{
|
||||
std::pair<char_type*, char_type*> seq = iostreams::input_sequence(d_);
|
||||
ptrs_.first().beg = seq.first;
|
||||
ptrs_.first().ptr = seq.first;
|
||||
ptrs_.first().end = seq.second;
|
||||
}
|
||||
|
||||
template<typename Direct>
|
||||
void direct_adapter_base<Direct>::init_output(mpl::true_)
|
||||
{
|
||||
std::pair<char_type*, char_type*> seq = iostreams::output_sequence(d_);
|
||||
ptrs_.second().beg = seq.first;
|
||||
ptrs_.second().ptr = seq.first;
|
||||
ptrs_.second().end = seq.second;
|
||||
}
|
||||
|
||||
//--------------Implementation of direct_adapter------------------------------//
|
||||
|
||||
template<typename Direct>
|
||||
inline std::streamsize direct_adapter<Direct>::read
|
||||
(char_type* s, std::streamsize n)
|
||||
{
|
||||
using namespace std;
|
||||
pointers& get = ptrs_.first();
|
||||
std::streamsize avail =
|
||||
static_cast<std::streamsize>(get.end - get.ptr);
|
||||
std::streamsize result = (std::min)(n, avail);
|
||||
std::copy(get.ptr, get.ptr + result, s);
|
||||
get.ptr += result;
|
||||
return result != 0 ? result : -1;
|
||||
}
|
||||
|
||||
template<typename Direct>
|
||||
inline std::streamsize direct_adapter<Direct>::write
|
||||
(const char_type* s, std::streamsize n)
|
||||
{
|
||||
using namespace std;
|
||||
pointers& put = ptrs_.second();
|
||||
if (n > static_cast<std::streamsize>(put.end - put.ptr))
|
||||
boost::throw_exception(write_area_exhausted());
|
||||
std::copy(s, s + n, put.ptr);
|
||||
put.ptr += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
template<typename Direct>
|
||||
inline std::streampos direct_adapter<Direct>::seek
|
||||
( stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which )
|
||||
{
|
||||
using namespace std;
|
||||
pointers& get = ptrs_.first();
|
||||
pointers& put = ptrs_.second();
|
||||
if (way == BOOST_IOS::cur && get.ptr != put.ptr)
|
||||
boost::throw_exception(bad_seek());
|
||||
ptrdiff_t next = 0;
|
||||
if ((which & BOOST_IOS::in) || !is_double::value) {
|
||||
if (way == BOOST_IOS::beg)
|
||||
next = off;
|
||||
else if (way == BOOST_IOS::cur)
|
||||
next = get.ptr - get.beg + off;
|
||||
else
|
||||
next = get.end - get.beg + off;
|
||||
if (next >= 0 && next <= get.end - get.beg)
|
||||
get.ptr = get.beg + next;
|
||||
else
|
||||
boost::throw_exception(bad_seek());
|
||||
}
|
||||
if ((which & BOOST_IOS::out) && is_double::value) {
|
||||
if (way == BOOST_IOS::beg)
|
||||
next = off;
|
||||
else if (way == BOOST_IOS::cur)
|
||||
next = put.ptr - put.beg + off;
|
||||
else
|
||||
next = put.end - put.beg + off;
|
||||
if (next >= 0 && next <= put.end - put.beg)
|
||||
put.ptr = put.beg + next;
|
||||
else
|
||||
boost::throw_exception(bad_seek());
|
||||
}
|
||||
return offset_to_position(next);
|
||||
}
|
||||
|
||||
template<typename Direct>
|
||||
void direct_adapter<Direct>::close()
|
||||
{
|
||||
BOOST_STATIC_ASSERT((!is_convertible<category, two_sequence>::value));
|
||||
detail::close_all(d_);
|
||||
}
|
||||
|
||||
template<typename Direct>
|
||||
void direct_adapter<Direct>::close(BOOST_IOS::openmode which)
|
||||
{
|
||||
BOOST_STATIC_ASSERT((is_convertible<category, two_sequence>::value));
|
||||
boost::iostreams::close(d_, which);
|
||||
}
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_NO_LOCALE
|
||||
template<typename Direct>
|
||||
void direct_adapter<Direct>::imbue(const std::locale& loc)
|
||||
{ boost::iostreams::imbue(d_, loc); }
|
||||
#endif
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_DIRECT_ADAPTER_HPP_INCLUDED
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Defines the class template boost::iostreams::detail::filter_adapter,
|
||||
* a convenience base class for filter adapters.
|
||||
*
|
||||
* File: boost/iostreams/detail/adapter/filter_adapter.hpp
|
||||
* Date: Mon Nov 26 14:35:48 MST 2007
|
||||
* Copyright: 2007-2008 CodeRage, LLC
|
||||
* Author: Jonathan Turkanis
|
||||
* Contact: turkanis at coderage dot com
|
||||
*
|
||||
* 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_DETAIL_FILTER_ADAPTER_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED
|
||||
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/detail/call_traits.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp>
|
||||
#include <boost/iostreams/operations.hpp>
|
||||
#include <boost/iostreams/traits.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
template<typename T>
|
||||
class filter_adapter {
|
||||
private:
|
||||
typedef typename detail::value_type<T>::type value_type;
|
||||
typedef typename detail::param_type<T>::type param_type;
|
||||
public:
|
||||
explicit filter_adapter(param_type t) : t_(t) { }
|
||||
T& component() { return t_; }
|
||||
|
||||
template<typename Device>
|
||||
void close(Device& dev)
|
||||
{
|
||||
detail::close_all(t_, dev);
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
void close(Device& dev, BOOST_IOS::openmode which)
|
||||
{
|
||||
iostreams::close(t_, dev, which);
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
void flush(Device& dev)
|
||||
{
|
||||
return iostreams::flush(t_, dev);
|
||||
}
|
||||
|
||||
template<typename Locale> // Avoid dependency on <locale>
|
||||
void imbue(const Locale& loc) { iostreams::imbue(t_, loc); }
|
||||
|
||||
std::streamsize optimal_buffer_size() const
|
||||
{ return iostreams::optimal_buffer_size(t_); }
|
||||
public:
|
||||
value_type t_;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED
|
@ -1,49 +0,0 @@
|
||||
// (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
|
||||
// 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.
|
||||
|
||||
// Borrowed from <boost/archive/add_facet.hpp>
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_DETAIL_ADD_FACET_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_ADD_FACET_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> // BOOST_DINKUMWARE_STDLIB.
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
//------------------Definition of add_facet-----------------------------------//
|
||||
|
||||
// Does STLport uses old Dinkumware locale?
|
||||
#if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && \
|
||||
defined(_STLP_NO_OWN_IOSTREAMS) \
|
||||
/**/
|
||||
# if (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)
|
||||
# define BOOST_IOSTREMS_STLPORT_WITH_OLD_DINKUMWARE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
template<class Facet>
|
||||
inline std::locale add_facet(const std::locale &l, Facet * f)
|
||||
{
|
||||
return
|
||||
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) || \
|
||||
defined(BOOST_IOSTREMS_STLPORT_WITH_OLD_DINKUMWARE) \
|
||||
/**/
|
||||
std::locale(std::_Addfac(l, f));
|
||||
#else
|
||||
// standard compatible
|
||||
std::locale(l, f);
|
||||
#endif
|
||||
}
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_ADD_FACET_HPP_INCLUDED
|
@ -1,214 +0,0 @@
|
||||
// (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
|
||||
// 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.
|
||||
|
||||
// Contains the definition of the template codecvt_helper, useful for
|
||||
// defining specializations of std::codecvt where state_type != mbstate_t.
|
||||
// Compensates for the fact that some standard library implementations
|
||||
// do not derive the primiary codecvt template from locale::facet or
|
||||
// provide the correct member types and functions.
|
||||
|
||||
// Usage:
|
||||
//
|
||||
// // In global namespace:
|
||||
// BOOST_IOSTREAMS_CODECVT_SPEC(mystate)
|
||||
//
|
||||
// // In user namespace:
|
||||
// template<typename Intern, typename Extern>
|
||||
// struct mycodecvt : codecvt_helper<Intern, Extern, State> { ... };
|
||||
//
|
||||
// // Or:
|
||||
// struct mycodecvt : codecvt_helper<wchar_t, char, State> { ... };
|
||||
//
|
||||
// Etc.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_DETAIL_CODECVT_HELPER_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_CODECVT_HELPER_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> // Put size_t in std, BOOST_MSVC, Dinkum.
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <algorithm> // min.
|
||||
#include <cstddef> // size_t.
|
||||
#include <locale> // locale, codecvt_base, codecvt.
|
||||
#include <boost/iostreams/detail/config/codecvt.hpp>
|
||||
|
||||
//------------------Definition of traits--------------------------------------//
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) //-----------------------//
|
||||
|
||||
template<typename T>
|
||||
struct codecvt_intern { typedef typename T::intern_type type; };
|
||||
|
||||
template<typename T>
|
||||
struct codecvt_extern { typedef typename T::extern_type type; };
|
||||
|
||||
#else // #if !BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) //--------------//
|
||||
|
||||
template<typename T>
|
||||
struct codecvt_intern { typedef typename T::from_type type; };
|
||||
|
||||
template<typename T>
|
||||
struct codecvt_extern { typedef typename T::to_type type; };
|
||||
|
||||
#endif // #if !BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) //-------------//
|
||||
|
||||
template<typename T>
|
||||
struct codecvt_state { typedef typename T::state_type type; };
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
//------------------Definition of codecvt_impl--------------------------------//
|
||||
|
||||
#if defined(BOOST_IOSTREAMS_NO_PRIMARY_CODECVT_DEFINITION) || \
|
||||
defined(BOOST_IOSTREAMS_EMPTY_PRIMARY_CODECVT_DEFINITION) || \
|
||||
defined(BOOST_IOSTREAMS_NO_LOCALE) \
|
||||
/**/
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
template<typename Intern, typename Extern, typename State>
|
||||
struct codecvt_impl : std::locale::facet, std::codecvt_base {
|
||||
public:
|
||||
typedef Intern intern_type;
|
||||
typedef Extern extern_type;
|
||||
typedef State state_type;
|
||||
|
||||
codecvt_impl(std::size_t refs = 0) : std::locale::facet(refs) { }
|
||||
|
||||
std::codecvt_base::result
|
||||
in( State& state, const Extern* first1, const Extern* last1,
|
||||
const Extern*& next1, Intern* first2, Intern* last2,
|
||||
Intern*& next2 ) const
|
||||
{
|
||||
return do_in(state, first1, last1, next1, first2, last2, next2);
|
||||
}
|
||||
|
||||
std::codecvt_base::result
|
||||
out( State& state, const Intern* first1, const Intern* last1,
|
||||
const Intern*& next1, Extern* first2, Extern* last2,
|
||||
Extern*& next2 ) const
|
||||
{
|
||||
return do_out(state, first1, last1, next1, first2, last2, next2);
|
||||
}
|
||||
|
||||
std::codecvt_base::result
|
||||
unshift(State& state, Extern* first2, Extern* last2, Extern*& next2) const
|
||||
{
|
||||
return do_unshift(state, first2, last2, next2);
|
||||
}
|
||||
|
||||
bool always_noconv() const throw() { return do_always_noconv(); }
|
||||
|
||||
int max_length() const throw() { return do_max_length(); }
|
||||
|
||||
int encoding() const throw() { return do_encoding(); }
|
||||
|
||||
int length( BOOST_IOSTREAMS_CODECVT_CV_QUALIFIER State& state,
|
||||
const Extern* first1, const Extern* last1,
|
||||
std::size_t len2 ) const throw()
|
||||
{
|
||||
return do_length(state, first1, last1, len2);
|
||||
}
|
||||
protected:
|
||||
std::codecvt_base::result
|
||||
virtual do_in( State&, const Extern*, const Extern*, const Extern*&,
|
||||
Intern*, Intern*, Intern*& ) const
|
||||
{
|
||||
return std::codecvt_base::noconv;
|
||||
}
|
||||
|
||||
std::codecvt_base::result
|
||||
virtual do_out( State&, const Intern*, const Intern*, const Intern*&,
|
||||
Extern*, Extern*, Extern*& ) const
|
||||
{
|
||||
return std::codecvt_base::noconv;
|
||||
}
|
||||
|
||||
std::codecvt_base::result
|
||||
virtual do_unshift(State&, Extern*, Extern*, Extern*&) const
|
||||
{
|
||||
return std::codecvt_base::ok;
|
||||
}
|
||||
|
||||
virtual bool do_always_noconv() const throw() { return true; }
|
||||
|
||||
virtual int do_max_length() const throw() { return 1; }
|
||||
|
||||
virtual int do_encoding() const throw() { return 1; }
|
||||
|
||||
virtual int do_length( BOOST_IOSTREAMS_CODECVT_CV_QUALIFIER State&,
|
||||
const Extern* first1, const Extern* last1,
|
||||
std::size_t len2 ) const throw()
|
||||
{
|
||||
return (std::min)(static_cast<std::size_t>(last1 - first1), len2);
|
||||
}
|
||||
};
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
#endif // no primary codecvt definition, empty definition.
|
||||
|
||||
//------------------Definition of BOOST_IOSTREAMS_CODECVT_SPEC----------------//
|
||||
|
||||
#if defined(BOOST_IOSTREAMS_NO_PRIMARY_CODECVT_DEFINITION) || \
|
||||
defined(BOOST_IOSTREAMS_EMPTY_PRIMARY_CODECVT_DEFINITION) \
|
||||
/**/
|
||||
# define BOOST_IOSTREAMS_CODECVT_SPEC(state) \
|
||||
namespace std { \
|
||||
template<typename Intern, typename Extern> \
|
||||
class codecvt<Intern, Extern, state> \
|
||||
: public ::boost::iostreams::detail::codecvt_impl< \
|
||||
Intern, Extern, state \
|
||||
> \
|
||||
{ \
|
||||
public: \
|
||||
codecvt(std::size_t refs = 0) \
|
||||
: ::boost::iostreams::detail::codecvt_impl< \
|
||||
Intern, Extern, state \
|
||||
>(refs) \
|
||||
{ } \
|
||||
static std::locale::id id; \
|
||||
}; \
|
||||
template<typename Intern, typename Extern> \
|
||||
std::locale::id codecvt<Intern, Extern, state>::id; \
|
||||
} \
|
||||
/**/
|
||||
#else
|
||||
# define BOOST_IOSTREAMS_CODECVT_SPEC(state)
|
||||
#endif // no primary codecvt definition, or empty definition.
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
//------------------Definition of codecvt_helper------------------------------//
|
||||
|
||||
template<typename Intern, typename Extern, typename State>
|
||||
struct codecvt_helper : std::codecvt<Intern, Extern, State> {
|
||||
typedef Intern intern_type;
|
||||
typedef Extern extern_type;
|
||||
typedef State state_type;
|
||||
codecvt_helper(std::size_t refs = 0)
|
||||
#if !defined(BOOST_IOSTREAMS_NO_CODECVT_CTOR_FROM_SIZE_T)
|
||||
: std::codecvt<Intern, Extern, State>(refs)
|
||||
#else
|
||||
: std::codecvt<Intern, Extern, State>()
|
||||
#endif
|
||||
{ }
|
||||
#ifdef BOOST_IOSTREAMS_NO_CODECVT_MAX_LENGTH
|
||||
int max_length() const throw() { return do_max_length(); }
|
||||
protected:
|
||||
virtual int do_max_length() const throw() { return 1; }
|
||||
#endif
|
||||
};
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_CODECVT_HELPER_HPP_INCLUDED
|
@ -1,63 +0,0 @@
|
||||
// (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
|
||||
// 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.
|
||||
|
||||
// Contains machinery for performing code conversion.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <cwchar> // mbstate_t.
|
||||
#include <locale> // codecvt, locale.
|
||||
#include <boost/config.hpp> // HAS_MACRO_USE_FACET.
|
||||
#include <boost/iostreams/detail/config/codecvt.hpp>
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
struct default_codecvt {
|
||||
typedef wchar_t intern_type, from_type;
|
||||
typedef char extern_type, to_type;
|
||||
typedef std::mbstate_t state_type;
|
||||
};
|
||||
|
||||
template<typename Codecvt>
|
||||
struct codecvt_holder {
|
||||
typedef Codecvt codecvt_type;
|
||||
const codecvt_type& get() const { return codecvt_; }
|
||||
void imbue(const std::locale&) { }
|
||||
Codecvt codecvt_;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct codecvt_holder<default_codecvt> {
|
||||
typedef std::codecvt<wchar_t, char, std::mbstate_t> codecvt_type;
|
||||
codecvt_holder() { reset_codecvt(); }
|
||||
const codecvt_type& get() const { return *codecvt_; }
|
||||
void imbue(const std::locale& loc)
|
||||
{
|
||||
loc_ = loc;
|
||||
reset_codecvt();
|
||||
}
|
||||
void reset_codecvt()
|
||||
{
|
||||
using namespace std;
|
||||
#ifndef BOOST_HAS_MACRO_USE_FACET
|
||||
codecvt_ = & use_facet< codecvt_type >(loc_);
|
||||
#else
|
||||
codecvt_ = & _USE(loc_, codecvt_type);
|
||||
#endif
|
||||
}
|
||||
std::locale loc_; // Prevent codecvt_ from being freed.
|
||||
const codecvt_type* codecvt_;
|
||||
};
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED
|
@ -1,74 +0,0 @@
|
||||
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
|
||||
// (C) Copyright 2005-2007 Jonathan Turkanis
|
||||
// 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_DETAIL_COUNTED_ARRAY_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_COUNTED_ARRAY_HPP_INCLUDED
|
||||
|
||||
#include <algorithm> // min.
|
||||
#include <cstddef> // size_t
|
||||
#include <string> // char_traits
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/detail/char_traits.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // streamsize.
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
template<typename Ch>
|
||||
class counted_array_source {
|
||||
public:
|
||||
typedef Ch char_type;
|
||||
typedef source_tag category;
|
||||
counted_array_source(const Ch* buf, std::streamsize size)
|
||||
: buf_(buf), ptr_(0), end_(size)
|
||||
{ }
|
||||
std::streamsize read(Ch* s, std::streamsize n)
|
||||
{
|
||||
using namespace std;
|
||||
streamsize result = (std::min)(n, end_ - ptr_);
|
||||
char_traits<char_type>::copy(
|
||||
s,
|
||||
buf_ + ptr_,
|
||||
static_cast<size_t>(result)
|
||||
);
|
||||
ptr_ += result;
|
||||
return result;
|
||||
}
|
||||
std::streamsize count() const { return ptr_; }
|
||||
private:
|
||||
const Ch* buf_;
|
||||
std::streamsize ptr_, end_;
|
||||
};
|
||||
|
||||
template<typename Ch>
|
||||
struct counted_array_sink {
|
||||
public:
|
||||
typedef Ch char_type;
|
||||
typedef sink_tag category;
|
||||
counted_array_sink(Ch* buf, std::streamsize size)
|
||||
: buf_(buf), ptr_(0), end_(size)
|
||||
{ }
|
||||
std::streamsize write(const Ch* s, std::streamsize n)
|
||||
{
|
||||
using namespace std;
|
||||
std::streamsize result = (std::min)(n, end_ - ptr_);
|
||||
char_traits<char_type>::copy(
|
||||
buf_ + ptr_,
|
||||
s,
|
||||
static_cast<size_t>(result)
|
||||
);
|
||||
ptr_ += result;
|
||||
return result;
|
||||
}
|
||||
std::streamsize count() const { return ptr_; }
|
||||
private:
|
||||
Ch* buf_;
|
||||
std::streamsize ptr_, end_;
|
||||
};
|
||||
|
||||
} } } // End namespaces iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_COUNTED_ARRAY_HPP_INCLUDED
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
* Date: Thu Dec 06 13:21:54 MST 2007
|
||||
* Copyright: 2007-2008 CodeRage, LLC
|
||||
* Author: Jonathan Turkanis
|
||||
* Contact: turkanis at coderage dot com
|
||||
*
|
||||
* Defines the function boost::iostreams::detail::current_directory, used by
|
||||
* boost::iostreams::detail::absolute_path.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_DETAIL_CURRENT_DIRECTORY_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_CURRENT_DIRECTORY_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp> // make sure size_t is in std.
|
||||
#include <cstddef> // size_t
|
||||
#include <string>
|
||||
#include <boost/iostreams/detail/buffer.hpp>
|
||||
#include <boost/iostreams/detail/config/windows_posix.hpp>
|
||||
#include <boost/iostreams/detail/system_failure.hpp>
|
||||
#ifdef BOOST_IOSTREAMS_WINDOWS
|
||||
# define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h> // sysconf.
|
||||
#endif
|
||||
|
||||
// Must come last.
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp>
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
// Returns the current working directory
|
||||
inline std::string current_directory()
|
||||
{
|
||||
#ifdef BOOST_IOSTREAMS_WINDOWS
|
||||
DWORD length;
|
||||
basic_buffer<char> buf(MAX_PATH);
|
||||
while (true) {
|
||||
length = ::GetCurrentDirectoryA(buf.size(), buf.data());
|
||||
if (!length)
|
||||
throw_system_failure("failed determining current directory");
|
||||
if (length < static_cast<DWORD>(buf.size()))
|
||||
break;
|
||||
buf.resize(buf.size() * 2);
|
||||
}
|
||||
return std::string(buf.data(), length);
|
||||
#else // #ifdef BOOST_IOSTREAMS_WINDOWS
|
||||
basic_buffer<char> buf(pathconf(".", _PC_PATH_MAX));
|
||||
if (!getcwd(buf.data(), static_cast<size_t>(buf.size())))
|
||||
throw_system_failure("failed determining current directory");
|
||||
return std::string(buf.data());
|
||||
#endif // #ifdef BOOST_IOSTREAMS_WINDOWS
|
||||
}
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_CURRENT_DIRECTORY_HPP_INCLUDED
|
@ -1,33 +0,0 @@
|
||||
// (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
|
||||
// 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_DETAIL_FSTREAM_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_FSTREAM_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/iostreams/detail/config/wide_streams.hpp>
|
||||
#ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES
|
||||
# include <fstream>
|
||||
#else
|
||||
# include <fstream.h>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES
|
||||
# define BOOST_IOSTREAMS_BASIC_IFSTREAM(Ch, Tr) std::basic_ifstream<Ch, Tr>
|
||||
# define BOOST_IOSTREAMS_BASIC_OFSTREAM(Ch, Tr) std::basic_ofstream<Ch, Tr>
|
||||
# define BOOST_IOSTREAMS_BASIC_FSTREAM(Ch, Tr) std::basic_fstream<Ch, Tr>
|
||||
# define BOOST_IOSTREAMS_BASIC_FILEBUF(Ch) std::basic_filebuf<Ch>
|
||||
#else
|
||||
# define BOOST_IOSTREAMS_BASIC_IFSTREAM(Ch, Tr) std::ifstream
|
||||
# define BOOST_IOSTREAMS_BASIC_OFSTREAM(Ch, Tr) std::ofstream
|
||||
# define BOOST_IOSTREAMS_BASIC_FILEBUF(Ch) std::filebuf
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_FSTREAM_HPP_INCLUDED
|
@ -1,32 +0,0 @@
|
||||
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
|
||||
// (C) Copyright 2005-2007 Jonathan Turkanis
|
||||
// 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_DETAIL_NEWLINE_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_NEWLINE_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
template<typename Ch>
|
||||
struct newline;
|
||||
|
||||
template<>
|
||||
struct newline<char> {
|
||||
BOOST_STATIC_CONSTANT(char, value = '\n');
|
||||
};
|
||||
|
||||
template<>
|
||||
struct newline<wchar_t> {
|
||||
BOOST_STATIC_CONSTANT(wchar_t, value = L'\n');
|
||||
};
|
||||
|
||||
} } } // End namespaces detaill, iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_NEWLINE_HPP_INCLUDED
|
@ -1,27 +0,0 @@
|
||||
// (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
|
||||
// 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_DETAIL_PARAM_TYPE_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_PARAM_TYPE_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/iostreams/traits.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
template<typename T>
|
||||
struct param_type {
|
||||
typedef typename mpl::if_<is_std_io<T>, T&, const T&>::type type;
|
||||
};
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_PARAM_TYPE_HPP_INCLUDED //-----------//
|
@ -1,483 +0,0 @@
|
||||
/*
|
||||
* 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/restrict_impl.hpp
|
||||
* Date: Sun Jan 06 12:57:30 MST 2008
|
||||
* Copyright: 2007-2008 CodeRage, LLC
|
||||
* Author: Jonathan Turkanis
|
||||
* Contact: turkanis at coderage dot com
|
||||
*
|
||||
* If included with the macro BOOST_IOSTREAMS_RESTRICT undefined, defines the
|
||||
* class template boost::iostreams::restriction. If included with the macro
|
||||
* BOOST_IOSTREAMS_RESTRICT defined as an identifier, defines the overloaded
|
||||
* function template boost::iostreams::BOOST_IOSTREAMS_RESTRICT, and object
|
||||
* generator for boost::iostreams::restriction.
|
||||
*
|
||||
* This design allows <boost/iostreams/restrict.hpp> and
|
||||
* <boost/iostreams/slice.hpp> to share an implementation.
|
||||
*/
|
||||
|
||||
#if !defined(BOOST_IOSTREAMS_RESTRICT_IMPL_HPP_INCLUDED) && \
|
||||
!defined(BOOST_IOSTREAMS_RESTRICT)
|
||||
# define BOOST_IOSTREAMS_RESTRICT_IMPL_HPP_INCLUDED
|
||||
|
||||
//------------------Implementation of restriction-----------------------------//
|
||||
|
||||
# include <algorithm> // min.
|
||||
# include <utility> // pair.
|
||||
# include <boost/cstdint.hpp> // intmax_t.
|
||||
# include <boost/config.hpp> // DEDUCED_TYPENAME.
|
||||
# include <boost/iostreams/categories.hpp>
|
||||
# include <boost/iostreams/char_traits.hpp>
|
||||
# include <boost/iostreams/detail/adapter/device_adapter.hpp>
|
||||
# include <boost/iostreams/detail/adapter/filter_adapter.hpp>
|
||||
# include <boost/iostreams/detail/call_traits.hpp>
|
||||
# include <boost/iostreams/detail/enable_if_stream.hpp>
|
||||
# include <boost/iostreams/detail/error.hpp>
|
||||
# include <boost/iostreams/detail/ios.hpp> // failure.
|
||||
# include <boost/iostreams/detail/select.hpp>
|
||||
# include <boost/iostreams/operations.hpp>
|
||||
# include <boost/iostreams/skip.hpp>
|
||||
# include <boost/iostreams/traits.hpp> // mode_of, is_direct.
|
||||
# include <boost/mpl/bool.hpp>
|
||||
# include <boost/static_assert.hpp>
|
||||
# include <boost/throw_exception.hpp>
|
||||
# include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
# include <boost/iostreams/detail/config/disable_warnings.hpp>
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
namespace detail {
|
||||
|
||||
//
|
||||
// Template name: restricted_indirect_device.
|
||||
// Description: Provides an restricted view of an indirect Device.
|
||||
// Template parameters:
|
||||
// Device - An indirect model of Device that models either Source or
|
||||
// SeekableDevice.
|
||||
//
|
||||
template<typename Device>
|
||||
class restricted_indirect_device : public device_adapter<Device> {
|
||||
private:
|
||||
typedef typename detail::param_type<Device>::type param_type;
|
||||
public:
|
||||
typedef typename char_type_of<Device>::type char_type;
|
||||
typedef typename mode_of<Device>::type mode;
|
||||
BOOST_STATIC_ASSERT(!(is_convertible<mode, detail::two_sequence>::value));
|
||||
struct category
|
||||
: mode,
|
||||
device_tag,
|
||||
closable_tag,
|
||||
flushable_tag,
|
||||
localizable_tag,
|
||||
optimally_buffered_tag
|
||||
{ };
|
||||
restricted_indirect_device( param_type dev, stream_offset off,
|
||||
stream_offset len = -1 );
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
std::streamsize write(const char_type* s, std::streamsize n);
|
||||
std::streampos seek(stream_offset off, BOOST_IOS::seekdir way);
|
||||
private:
|
||||
stream_offset beg_, pos_, end_;
|
||||
};
|
||||
|
||||
//
|
||||
// Template name: restricted_direct_device.
|
||||
// Description: Provides an restricted view of a Direct Device.
|
||||
// Template parameters:
|
||||
// Device - A model of Direct and Device.
|
||||
//
|
||||
template<typename Device>
|
||||
class restricted_direct_device : public device_adapter<Device> {
|
||||
public:
|
||||
typedef typename char_type_of<Device>::type char_type;
|
||||
typedef std::pair<char_type*, char_type*> pair_type;
|
||||
typedef typename mode_of<Device>::type mode;
|
||||
BOOST_STATIC_ASSERT(!(is_convertible<mode, detail::two_sequence>::value));
|
||||
struct category
|
||||
: mode_of<Device>::type,
|
||||
device_tag,
|
||||
direct_tag,
|
||||
closable_tag,
|
||||
localizable_tag
|
||||
{ };
|
||||
restricted_direct_device( const Device& dev, stream_offset off,
|
||||
stream_offset len = -1 );
|
||||
pair_type input_sequence();
|
||||
pair_type output_sequence();
|
||||
private:
|
||||
pair_type sequence(mpl::true_);
|
||||
pair_type sequence(mpl::false_);
|
||||
char_type *beg_, *end_;
|
||||
};
|
||||
|
||||
//
|
||||
// Template name: restricted_filter.
|
||||
// Description: Provides an restricted view of a Filter.
|
||||
// Template parameters:
|
||||
// Filter - An indirect model of Filter.
|
||||
//
|
||||
template<typename Filter>
|
||||
class restricted_filter : public filter_adapter<Filter> {
|
||||
public:
|
||||
typedef typename char_type_of<Filter>::type char_type;
|
||||
typedef typename mode_of<Filter>::type mode;
|
||||
BOOST_STATIC_ASSERT(!(is_convertible<mode, detail::two_sequence>::value));
|
||||
struct category
|
||||
: mode,
|
||||
filter_tag,
|
||||
multichar_tag,
|
||||
closable_tag,
|
||||
localizable_tag,
|
||||
optimally_buffered_tag
|
||||
{ };
|
||||
restricted_filter( const Filter& flt, stream_offset off,
|
||||
stream_offset len = -1 );
|
||||
|
||||
template<typename Source>
|
||||
std::streamsize read(Source& src, char_type* s, std::streamsize n)
|
||||
{
|
||||
using namespace std;
|
||||
if (!open_)
|
||||
open(src, BOOST_IOS::in);
|
||||
std::streamsize amt =
|
||||
end_ != -1 ?
|
||||
(std::min) (n, static_cast<std::streamsize>(end_ - pos_)) :
|
||||
n;
|
||||
std::streamsize result =
|
||||
iostreams::read(this->component(), src, s, amt);
|
||||
if (result != -1)
|
||||
pos_ += result;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
std::streamsize write(Sink& snk, const char_type* s, std::streamsize n)
|
||||
{
|
||||
if (!open_)
|
||||
open(snk, BOOST_IOS::out);
|
||||
if (end_ != -1 && pos_ + n >= end_) {
|
||||
if(pos_ < end_)
|
||||
pos_ += iostreams::write(this->component(),
|
||||
snk, s, end_ - pos_);
|
||||
boost::throw_exception(bad_write());
|
||||
}
|
||||
std::streamsize result =
|
||||
iostreams::write(this->component(), snk, s, n);
|
||||
pos_ += result;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
std::streampos seek(Device& dev, stream_offset off, BOOST_IOS::seekdir way)
|
||||
{
|
||||
stream_offset next;
|
||||
if (way == BOOST_IOS::beg) {
|
||||
next = beg_ + off;
|
||||
} else if (way == BOOST_IOS::cur) {
|
||||
next = pos_ + off;
|
||||
} else if (end_ != -1) {
|
||||
next = end_ + off;
|
||||
} else {
|
||||
// Restriction is half-open; seek relative to the actual end.
|
||||
pos_ = this->component().seek(dev, off, BOOST_IOS::end);
|
||||
if (pos_ < beg_)
|
||||
boost::throw_exception(bad_seek());
|
||||
return offset_to_position(pos_ - beg_);
|
||||
}
|
||||
if (next < beg_ || (end_ != -1 && next >= end_))
|
||||
boost::throw_exception(bad_seek());
|
||||
pos_ = this->component().seek(dev, next, BOOST_IOS::cur);
|
||||
return offset_to_position(pos_ - beg_);
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
void close(Device& dev)
|
||||
{
|
||||
open_ = false;
|
||||
detail::close_all(this->component(), dev);
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
void close(Device& dev, BOOST_IOS::openmode which)
|
||||
{
|
||||
open_ = false;
|
||||
iostreams::close(this->component(), dev, which);
|
||||
}
|
||||
private:
|
||||
template<typename Device>
|
||||
void open(Device& dev, BOOST_IOS::openmode which)
|
||||
{
|
||||
typedef typename is_convertible<mode, dual_use>::type is_dual_use;
|
||||
open_ = true;
|
||||
which = is_dual_use() ? which : (BOOST_IOS::in | BOOST_IOS::out);
|
||||
iostreams::skip(this->component(), dev, beg_, which);
|
||||
}
|
||||
|
||||
stream_offset beg_, pos_, end_;
|
||||
bool open_;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct restriction_traits
|
||||
: iostreams::select< // Disambiguation for Tru64.
|
||||
is_filter<T>, restricted_filter<T>,
|
||||
is_direct<T>, restricted_direct_device<T>,
|
||||
else_, restricted_indirect_device<T>
|
||||
>
|
||||
{ };
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
template<typename T>
|
||||
struct restriction : public detail::restriction_traits<T>::type {
|
||||
typedef typename detail::param_type<T>::type param_type;
|
||||
typedef typename detail::restriction_traits<T>::type base_type;
|
||||
restriction(param_type t, stream_offset off, stream_offset len = -1)
|
||||
: base_type(t, off, len)
|
||||
{ }
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
//--------------Implementation of restricted_indirect_device------------------//
|
||||
|
||||
template<typename Device>
|
||||
restricted_indirect_device<Device>::restricted_indirect_device
|
||||
(param_type dev, stream_offset off, stream_offset len)
|
||||
: device_adapter<Device>(dev), beg_(off), pos_(off),
|
||||
end_(len != -1 ? off + len : -1)
|
||||
{
|
||||
if (len < -1 || off < 0)
|
||||
boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad offset"));
|
||||
iostreams::skip(this->component(), off);
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
inline std::streamsize restricted_indirect_device<Device>::read
|
||||
(char_type* s, std::streamsize n)
|
||||
{
|
||||
using namespace std;
|
||||
std::streamsize amt =
|
||||
end_ != -1 ?
|
||||
(std::min) (n, static_cast<std::streamsize>(end_ - pos_)) :
|
||||
n;
|
||||
std::streamsize result = iostreams::read(this->component(), s, amt);
|
||||
if (result != -1)
|
||||
pos_ += result;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
inline std::streamsize restricted_indirect_device<Device>::write
|
||||
(const char_type* s, std::streamsize n)
|
||||
{
|
||||
if (end_ != -1 && pos_ + n >= end_) {
|
||||
if(pos_ < end_)
|
||||
pos_ += iostreams::write(this->component(), s, end_ - pos_);
|
||||
boost::throw_exception(bad_write());
|
||||
}
|
||||
std::streamsize result = iostreams::write(this->component(), s, n);
|
||||
pos_ += result;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
std::streampos restricted_indirect_device<Device>::seek
|
||||
(stream_offset off, BOOST_IOS::seekdir way)
|
||||
{
|
||||
stream_offset next;
|
||||
if (way == BOOST_IOS::beg) {
|
||||
next = beg_ + off;
|
||||
} else if (way == BOOST_IOS::cur) {
|
||||
next = pos_ + off;
|
||||
} else if (end_ != -1) {
|
||||
next = end_ + off;
|
||||
} else {
|
||||
// Restriction is half-open; seek relative to the actual end.
|
||||
pos_ = iostreams::seek(this->component(), off, BOOST_IOS::end);
|
||||
if (pos_ < beg_)
|
||||
boost::throw_exception(bad_seek());
|
||||
return offset_to_position(pos_ - beg_);
|
||||
}
|
||||
if (next < beg_ || (end_ != -1 && next > end_))
|
||||
boost::throw_exception(bad_seek());
|
||||
pos_ = iostreams::seek(this->component(), next - pos_, BOOST_IOS::cur);
|
||||
return offset_to_position(pos_ - beg_);
|
||||
}
|
||||
|
||||
//--------------Implementation of restricted_direct_device--------------------//
|
||||
|
||||
template<typename Device>
|
||||
restricted_direct_device<Device>::restricted_direct_device
|
||||
(const Device& dev, stream_offset off, stream_offset len)
|
||||
: device_adapter<Device>(dev), beg_(0), end_(0)
|
||||
{
|
||||
std::pair<char_type*, char_type*> seq =
|
||||
sequence(is_convertible<category, input>());
|
||||
if ( off < 0 || len < -1 ||
|
||||
(len != -1 && off + len > seq.second - seq.first) )
|
||||
{
|
||||
boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad offset"));
|
||||
}
|
||||
beg_ = seq.first + off;
|
||||
end_ = len != -1 ?
|
||||
seq.first + off + len :
|
||||
seq.second;
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
typename restricted_direct_device<Device>::pair_type
|
||||
restricted_direct_device<Device>::input_sequence()
|
||||
{
|
||||
BOOST_STATIC_ASSERT((is_convertible<category, input>::value));
|
||||
return std::make_pair(beg_, end_);
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
typename restricted_direct_device<Device>::pair_type
|
||||
restricted_direct_device<Device>::output_sequence()
|
||||
{
|
||||
BOOST_STATIC_ASSERT((is_convertible<category, output>::value));
|
||||
return std::make_pair(beg_, end_);
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
typename restricted_direct_device<Device>::pair_type
|
||||
restricted_direct_device<Device>::sequence(mpl::true_)
|
||||
{ return iostreams::input_sequence(this->component()); }
|
||||
|
||||
template<typename Device>
|
||||
typename restricted_direct_device<Device>::pair_type
|
||||
restricted_direct_device<Device>::sequence(mpl::false_)
|
||||
{ return iostreams::output_sequence(this->component()); }
|
||||
|
||||
//--------------Implementation of restricted_filter---------------------------//
|
||||
|
||||
template<typename Filter>
|
||||
restricted_filter<Filter>::restricted_filter
|
||||
(const Filter& flt, stream_offset off, stream_offset len)
|
||||
: filter_adapter<Filter>(flt), beg_(off),
|
||||
pos_(off), end_(len != -1 ? off + len : -1), open_(false)
|
||||
{
|
||||
if (len < -1 || off < 0)
|
||||
boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad offset"));
|
||||
}
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#elif defined(BOOST_IOSTREAMS_RESTRICT)
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
//--------------Implementation of restrict/slice------------------------------//
|
||||
|
||||
// Note: The following workarounds are patterned after resolve.hpp. It has not
|
||||
// yet been confirmed that they are necessary.
|
||||
|
||||
# ifndef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //------------------------//
|
||||
# ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //------------------------------//
|
||||
|
||||
template<typename T>
|
||||
restriction<T>
|
||||
BOOST_IOSTREAMS_RESTRICT( const T& t, stream_offset off, stream_offset len = -1
|
||||
BOOST_IOSTREAMS_DISABLE_IF_STREAM(T) )
|
||||
{ return restriction<T>(t, off, len); }
|
||||
|
||||
template<typename Ch, typename Tr>
|
||||
restriction< std::basic_streambuf<Ch, Tr> >
|
||||
BOOST_IOSTREAMS_RESTRICT( std::basic_streambuf<Ch, Tr>& sb, stream_offset off,
|
||||
stream_offset len = -1 )
|
||||
{ return restriction< std::basic_streambuf<Ch, Tr> >(sb, off, len); }
|
||||
|
||||
template<typename Ch, typename Tr>
|
||||
restriction< std::basic_istream<Ch, Tr> >
|
||||
BOOST_IOSTREAMS_RESTRICT
|
||||
(std::basic_istream<Ch, Tr>& is, stream_offset off, stream_offset len = -1)
|
||||
{ return restriction< std::basic_istream<Ch, Tr> >(is, off, len); }
|
||||
|
||||
template<typename Ch, typename Tr>
|
||||
restriction< std::basic_ostream<Ch, Tr> >
|
||||
BOOST_IOSTREAMS_RESTRICT
|
||||
(std::basic_ostream<Ch, Tr>& os, stream_offset off, stream_offset len = -1)
|
||||
{ return restriction< std::basic_ostream<Ch, Tr> >(os, off, len); }
|
||||
|
||||
template<typename Ch, typename Tr>
|
||||
restriction< std::basic_iostream<Ch, Tr> >
|
||||
BOOST_IOSTREAMS_RESTRICT
|
||||
(std::basic_iostream<Ch, Tr>& io, stream_offset off, stream_offset len = -1)
|
||||
{ return restriction< std::basic_iostream<Ch, Tr> >(io, off, len); }
|
||||
|
||||
# else // # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //--------------------//
|
||||
|
||||
template<typename T>
|
||||
restriction<T>
|
||||
BOOST_IOSTREAMS_RESTRICT( const T& t, stream_offset off, stream_offset len = -1
|
||||
BOOST_IOSTREAMS_DISABLE_IF_STREAM(T) )
|
||||
{ return restriction<T>(t, off, len); }
|
||||
|
||||
restriction<std::streambuf>
|
||||
BOOST_IOSTREAMS_RESTRICT
|
||||
(std::streambuf& sb, stream_offset off, stream_offset len = -1)
|
||||
{ return restriction<std::streambuf>(sb, off, len); }
|
||||
|
||||
restriction<std::istream>
|
||||
BOOST_IOSTREAMS_RESTRICT
|
||||
(std::istream<Ch, Tr>& is, stream_offset off, stream_offset len = -1)
|
||||
{ return restriction<std::istream>(is, off, len); }
|
||||
|
||||
restriction<std::ostream>
|
||||
BOOST_IOSTREAMS_RESTRICT
|
||||
(std::ostream<Ch, Tr>& os, stream_offset off, stream_offset len = -1)
|
||||
{ return restriction<std::ostream>(os, off, len); }
|
||||
|
||||
restriction<std::iostream>
|
||||
BOOST_IOSTREAMS_RESTRICT
|
||||
(std::iostream<Ch, Tr>& io, stream_offset off, stream_offset len = -1)
|
||||
{ return restriction<std::iostream>(io, off, len); }
|
||||
|
||||
# endif // # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //-------------------//
|
||||
# else // #ifndef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //---------------//
|
||||
|
||||
template<typename T>
|
||||
restriction<T>
|
||||
BOOST_IOSTREAMS_RESTRICT
|
||||
(const T& t, stream_offset off, stream_offset len, mpl::true_)
|
||||
{ // Bad overload resolution.
|
||||
return restriction<T>(const_cast<T&>(t, off, len));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
restriction<T>
|
||||
BOOST_IOSTREAMS_RESTRICT
|
||||
(const T& t, stream_offset off, stream_offset len, mpl::false_)
|
||||
{ return restriction<T>(t, off, len); }
|
||||
|
||||
template<typename T>
|
||||
restriction<T>
|
||||
BOOST_IOSTREAMS_RESTRICT( const T& t, stream_offset off, stream_offset len = -1
|
||||
BOOST_IOSTREAMS_DISABLE_IF_STREAM(T) )
|
||||
{ return BOOST_IOSTREAMS_RESTRICT(t, off, len, is_std_io<T>()); }
|
||||
|
||||
# if !BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600) && \
|
||||
!defined(__GNUC__) // ---------------------------------------------------//
|
||||
|
||||
template<typename T>
|
||||
restriction<T>
|
||||
BOOST_IOSTREAMS_RESTRICT(T& t, stream_offset off, stream_offset len = -1)
|
||||
{ return restriction<T>(t, off, len); }
|
||||
|
||||
# endif // Borland 5.x or GCC //-------------------------------//
|
||||
# endif // #ifndef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION //--------------//
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
# include <boost/iostreams/detail/config/enable_warnings.hpp>
|
||||
|
||||
#endif // #if !defined(BOOST_IOSTREAMS_RESTRICT_IMPL_HPP_INCLUDED) ...
|
@ -1,113 +0,0 @@
|
||||
// (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
|
||||
// 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_DETAIL_CHAINBUF_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_CHAINBUF_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> // BOOST_MSVC, template friends.
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/iostreams/chain.hpp>
|
||||
#include <boost/iostreams/detail/access_control.hpp>
|
||||
#include <boost/iostreams/detail/config/wide_streams.hpp>
|
||||
#include <boost/iostreams/detail/streambuf.hpp>
|
||||
#include <boost/iostreams/detail/streambuf/linked_streambuf.hpp>
|
||||
#include <boost/iostreams/detail/translate_int_type.hpp>
|
||||
#include <boost/iostreams/traits.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
//--------------Definition of chainbuf----------------------------------------//
|
||||
|
||||
//
|
||||
// Template name: chainbuf.
|
||||
// Description: Stream buffer which operates by delegating to the first
|
||||
// linked_streambuf in a chain.
|
||||
// Template parameters:
|
||||
// Chain - The chain type.
|
||||
//
|
||||
template<typename Chain, typename Mode, typename Access>
|
||||
class chainbuf
|
||||
: public BOOST_IOSTREAMS_BASIC_STREAMBUF(
|
||||
typename Chain::char_type,
|
||||
typename Chain::traits_type
|
||||
),
|
||||
public access_control<typename Chain::client_type, Access>,
|
||||
private noncopyable
|
||||
{
|
||||
private:
|
||||
typedef access_control<chain_client<Chain>, Access> client_type;
|
||||
public:
|
||||
typedef typename Chain::char_type char_type;
|
||||
BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(typename Chain::traits_type)
|
||||
protected:
|
||||
typedef linked_streambuf<char_type, traits_type> delegate_type;
|
||||
chainbuf() { client_type::set_chain(&chain_); }
|
||||
int_type underflow()
|
||||
{ sentry t(this); return translate(delegate().underflow()); }
|
||||
int_type pbackfail(int_type c)
|
||||
{ sentry t(this); return translate(delegate().pbackfail(c)); }
|
||||
std::streamsize xsgetn(char_type* s, std::streamsize n)
|
||||
{ sentry t(this); return delegate().xsgetn(s, n); }
|
||||
int_type overflow(int_type c)
|
||||
{ sentry t(this); return translate(delegate().overflow(c)); }
|
||||
std::streamsize xsputn(const char_type* s, std::streamsize n)
|
||||
{ sentry t(this); return delegate().xsputn(s, n); }
|
||||
int sync() { sentry t(this); return delegate().sync(); }
|
||||
pos_type seekoff( off_type off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which =
|
||||
BOOST_IOS::in | BOOST_IOS::out )
|
||||
{ sentry t(this); return delegate().seekoff(off, way, which); }
|
||||
pos_type seekpos( pos_type sp,
|
||||
BOOST_IOS::openmode which =
|
||||
BOOST_IOS::in | BOOST_IOS::out )
|
||||
{ sentry t(this); return delegate().seekpos(sp, which); }
|
||||
protected:
|
||||
typedef BOOST_IOSTREAMS_BASIC_STREAMBUF(
|
||||
typename Chain::char_type,
|
||||
typename Chain::traits_type
|
||||
) base_type;
|
||||
private:
|
||||
|
||||
// Translate from std int_type to chain's int_type.
|
||||
typedef BOOST_IOSTREAMS_CHAR_TRAITS(char_type) std_traits;
|
||||
typedef typename Chain::traits_type chain_traits;
|
||||
static typename chain_traits::int_type
|
||||
translate(typename std_traits::int_type c)
|
||||
{ return translate_int_type<std_traits, chain_traits>(c); }
|
||||
|
||||
delegate_type& delegate()
|
||||
{ return static_cast<delegate_type&>(chain_.front()); }
|
||||
void get_pointers()
|
||||
{
|
||||
this->setg(delegate().eback(), delegate().gptr(), delegate().egptr());
|
||||
this->setp(delegate().pbase(), delegate().epptr());
|
||||
this->pbump((int) (delegate().pptr() - delegate().pbase()));
|
||||
}
|
||||
void set_pointers()
|
||||
{
|
||||
delegate().setg(this->eback(), this->gptr(), this->egptr());
|
||||
delegate().setp(this->pbase(), this->epptr());
|
||||
delegate().pbump((int) (this->pptr() - this->pbase()));
|
||||
}
|
||||
struct sentry {
|
||||
sentry(chainbuf<Chain, Mode, Access>* buf) : buf_(buf)
|
||||
{ buf_->set_pointers(); }
|
||||
~sentry() { buf_->get_pointers(); }
|
||||
chainbuf<Chain, Mode, Access>* buf_;
|
||||
};
|
||||
friend struct sentry;
|
||||
Chain chain_;
|
||||
};
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_CHAINBUF_HPP_INCLUDED
|
@ -1,62 +0,0 @@
|
||||
// (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
|
||||
// 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_DETAIL_TRANSLATE_INT_TYPE_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_DETAIL_TRANSLATE_INT_TYPE_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace iostreams { namespace detail {
|
||||
|
||||
template<bool IsSame>
|
||||
struct translate_int_type_impl;
|
||||
|
||||
//
|
||||
// Template name: translate_char.
|
||||
// Description: Translates a character or an end-of-file indicator from the
|
||||
// int_type of one character traits type to the int_type of another.
|
||||
//
|
||||
template<typename SourceTr, typename TargetTr>
|
||||
typename TargetTr::int_type
|
||||
translate_int_type(typename SourceTr::int_type c)
|
||||
{
|
||||
typedef translate_int_type_impl<is_same<SourceTr, TargetTr>::value> impl;
|
||||
return impl::template inner<SourceTr, TargetTr>::translate(c);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
template<>
|
||||
struct translate_int_type_impl<true> {
|
||||
template<typename SourceTr, typename TargetTr>
|
||||
struct inner {
|
||||
static typename TargetTr::int_type
|
||||
translate(typename SourceTr::int_type c) { return c; }
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct translate_int_type_impl<false> {
|
||||
template<typename SourceTr, typename TargetTr>
|
||||
struct inner {
|
||||
static typename TargetTr::int_type
|
||||
translate(typename SourceTr::int_type c)
|
||||
{
|
||||
return SourceTr::eq_int_type(SourceTr::eof()) ?
|
||||
TargetTr::eof() :
|
||||
TargetTr::to_int_type(SourceTr::to_char_type(c));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} } } // End namespaces detail, iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_DETAIL_TRANSLATE_INT_TYPE_HPP_INCLUDED
|
@ -1,191 +0,0 @@
|
||||
// (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
|
||||
// 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_FILE_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_FILE_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/iostreams/detail/config/wide_streams.hpp>
|
||||
#ifndef BOOST_IOSTREAMS_NO_LOCALE
|
||||
# include <locale>
|
||||
#endif
|
||||
#include <string> // pathnames, char_traits.
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // openmode, seekdir, int types.
|
||||
#include <boost/iostreams/detail/fstream.hpp>
|
||||
#include <boost/iostreams/operations.hpp> // seek.
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
// Must come last.
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
template<typename Ch>
|
||||
class basic_file {
|
||||
public:
|
||||
typedef Ch char_type;
|
||||
struct category
|
||||
: public seekable_device_tag,
|
||||
public closable_tag,
|
||||
public localizable_tag,
|
||||
public flushable_tag
|
||||
{ };
|
||||
basic_file( const std::string& path,
|
||||
BOOST_IOS::openmode mode =
|
||||
BOOST_IOS::in | BOOST_IOS::out,
|
||||
BOOST_IOS::openmode base_mode =
|
||||
BOOST_IOS::in | BOOST_IOS::out );
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
bool putback(char_type c);
|
||||
std::streamsize write(const char_type* s, std::streamsize n);
|
||||
std::streampos seek( stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which =
|
||||
BOOST_IOS::in | BOOST_IOS::out );
|
||||
void open( const std::string& path,
|
||||
BOOST_IOS::openmode mode =
|
||||
BOOST_IOS::in | BOOST_IOS::out,
|
||||
BOOST_IOS::openmode base_mode =
|
||||
BOOST_IOS::in | BOOST_IOS::out );
|
||||
bool is_open() const;
|
||||
void close();
|
||||
bool flush();
|
||||
#ifndef BOOST_IOSTREAMS_NO_LOCALE
|
||||
void imbue(const std::locale& loc) { pimpl_->file_.pubimbue(loc); }
|
||||
#endif
|
||||
private:
|
||||
struct impl {
|
||||
impl(const std::string& path, BOOST_IOS::openmode mode)
|
||||
{ file_.open(path.c_str(), mode); }
|
||||
~impl() { if (file_.is_open()) file_.close(); }
|
||||
BOOST_IOSTREAMS_BASIC_FILEBUF(Ch) file_;
|
||||
};
|
||||
shared_ptr<impl> pimpl_;
|
||||
};
|
||||
|
||||
typedef basic_file<char> file;
|
||||
typedef basic_file<wchar_t> wfile;
|
||||
|
||||
template<typename Ch>
|
||||
struct basic_file_source : private basic_file<Ch> {
|
||||
typedef Ch char_type;
|
||||
struct category
|
||||
: input_seekable,
|
||||
device_tag,
|
||||
closable_tag
|
||||
{ };
|
||||
using basic_file<Ch>::read;
|
||||
using basic_file<Ch>::putback;
|
||||
using basic_file<Ch>::seek;
|
||||
using basic_file<Ch>::is_open;
|
||||
using basic_file<Ch>::close;
|
||||
basic_file_source( const std::string& path,
|
||||
BOOST_IOS::openmode mode =
|
||||
BOOST_IOS::in )
|
||||
: basic_file<Ch>(path, mode & ~BOOST_IOS::out, BOOST_IOS::in)
|
||||
{ }
|
||||
void open( const std::string& path,
|
||||
BOOST_IOS::openmode mode = BOOST_IOS::in )
|
||||
{
|
||||
basic_file<Ch>::open(path, mode & ~BOOST_IOS::out, BOOST_IOS::in);
|
||||
}
|
||||
};
|
||||
|
||||
typedef basic_file_source<char> file_source;
|
||||
typedef basic_file_source<wchar_t> wfile_source;
|
||||
|
||||
template<typename Ch>
|
||||
struct basic_file_sink : private basic_file<Ch> {
|
||||
typedef Ch char_type;
|
||||
struct category
|
||||
: output_seekable,
|
||||
device_tag,
|
||||
closable_tag,
|
||||
flushable_tag
|
||||
{ };
|
||||
using basic_file<Ch>::write;
|
||||
using basic_file<Ch>::seek;
|
||||
using basic_file<Ch>::is_open;
|
||||
using basic_file<Ch>::close;
|
||||
using basic_file<Ch>::flush;
|
||||
basic_file_sink( const std::string& path,
|
||||
BOOST_IOS::openmode mode = BOOST_IOS::out )
|
||||
: basic_file<Ch>(path, mode & ~BOOST_IOS::in, BOOST_IOS::out)
|
||||
{ }
|
||||
void open( const std::string& path,
|
||||
BOOST_IOS::openmode mode = BOOST_IOS::out )
|
||||
{
|
||||
basic_file<Ch>::open(path, mode & ~BOOST_IOS::in, BOOST_IOS::out);
|
||||
}
|
||||
};
|
||||
|
||||
typedef basic_file_sink<char> file_sink;
|
||||
typedef basic_file_sink<wchar_t> wfile_sink;
|
||||
|
||||
//------------------Implementation of basic_file------------------------------//
|
||||
|
||||
template<typename Ch>
|
||||
basic_file<Ch>::basic_file
|
||||
( const std::string& path, BOOST_IOS::openmode mode,
|
||||
BOOST_IOS::openmode base_mode )
|
||||
{
|
||||
open(path, mode, base_mode);
|
||||
}
|
||||
|
||||
template<typename Ch>
|
||||
inline std::streamsize basic_file<Ch>::read
|
||||
(char_type* s, std::streamsize n)
|
||||
{
|
||||
std::streamsize result = pimpl_->file_.sgetn(s, n);
|
||||
return result != 0 ? result : -1;
|
||||
}
|
||||
|
||||
template<typename Ch>
|
||||
inline bool basic_file<Ch>::putback(char_type c)
|
||||
{
|
||||
return !!pimpl_->file_.sputbackc(c);
|
||||
}
|
||||
|
||||
template<typename Ch>
|
||||
inline std::streamsize basic_file<Ch>::write
|
||||
(const char_type* s, std::streamsize n)
|
||||
{ return pimpl_->file_.sputn(s, n); }
|
||||
|
||||
template<typename Ch>
|
||||
std::streampos basic_file<Ch>::seek
|
||||
( stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode )
|
||||
{ return iostreams::seek(pimpl_->file_, off, way); }
|
||||
|
||||
template<typename Ch>
|
||||
void basic_file<Ch>::open
|
||||
( const std::string& path, BOOST_IOS::openmode mode,
|
||||
BOOST_IOS::openmode base_mode )
|
||||
{
|
||||
pimpl_.reset(new impl(path, mode | base_mode));
|
||||
}
|
||||
|
||||
template<typename Ch>
|
||||
bool basic_file<Ch>::is_open() const { return pimpl_->file_.is_open(); }
|
||||
|
||||
template<typename Ch>
|
||||
void basic_file<Ch>::close() { pimpl_->file_.close(); }
|
||||
|
||||
template<typename Ch>
|
||||
bool basic_file<Ch>::flush()
|
||||
{ return pimpl_->file_.BOOST_IOSTREAMS_PUBSYNC() == 0; }
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp> // MSVC
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_FILE_HPP_INCLUDED
|
@ -1,168 +0,0 @@
|
||||
// (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
|
||||
// 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_AGGREGATE_FILTER_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_AGGREGATE_FILTER_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <algorithm> // copy, min.
|
||||
#include <boost/assert.hpp>
|
||||
#include <iterator> // back_inserter
|
||||
#include <vector>
|
||||
#include <boost/iostreams/constants.hpp> // default_device_buffer_size
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/detail/char_traits.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // openmode, streamsize.
|
||||
#include <boost/iostreams/pipeline.hpp>
|
||||
#include <boost/iostreams/read.hpp> // check_eof
|
||||
#include <boost/iostreams/write.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
// Must come last.
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
//
|
||||
// Template name: aggregate_filter.
|
||||
// Template parameters:
|
||||
// Ch - The character type.
|
||||
// Alloc - The allocator type.
|
||||
// Description: Utility for defining DualUseFilters which filter an
|
||||
// entire stream at once. To use, override the protected virtual
|
||||
// member do_filter.
|
||||
// Note: This filter should not be copied while it is in use.
|
||||
//
|
||||
template<typename Ch, typename Alloc = std::allocator<Ch> >
|
||||
class aggregate_filter {
|
||||
public:
|
||||
typedef Ch char_type;
|
||||
struct category
|
||||
: dual_use,
|
||||
filter_tag,
|
||||
multichar_tag,
|
||||
closable_tag
|
||||
{ };
|
||||
aggregate_filter() : ptr_(0), state_(0) { }
|
||||
virtual ~aggregate_filter() { }
|
||||
|
||||
template<typename Source>
|
||||
std::streamsize read(Source& src, char_type* s, std::streamsize n)
|
||||
{
|
||||
using namespace std;
|
||||
BOOST_ASSERT(!(state_ & f_write));
|
||||
state_ |= f_read;
|
||||
if (!(state_ & f_eof))
|
||||
do_read(src);
|
||||
std::streamsize amt =
|
||||
(std::min)(n, static_cast<std::streamsize>(data_.size() - ptr_));
|
||||
if (amt) {
|
||||
BOOST_IOSTREAMS_CHAR_TRAITS(char_type)::copy(s, &data_[ptr_], amt);
|
||||
ptr_ += amt;
|
||||
}
|
||||
return detail::check_eof(amt);
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
std::streamsize write(Sink&, const char_type* s, std::streamsize n)
|
||||
{
|
||||
BOOST_ASSERT(!(state_ & f_read));
|
||||
state_ |= f_write;
|
||||
data_.insert(data_.end(), s, s + n);
|
||||
return n;
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
void close(Sink& sink, BOOST_IOS::openmode which)
|
||||
{
|
||||
if ((state_ & f_read) != 0 && which == BOOST_IOS::in)
|
||||
close_impl();
|
||||
if ((state_ & f_write) != 0 && which == BOOST_IOS::out) {
|
||||
try {
|
||||
vector_type filtered;
|
||||
do_filter(data_, filtered);
|
||||
do_write(
|
||||
sink, &filtered[0],
|
||||
static_cast<std::streamsize>(filtered.size())
|
||||
);
|
||||
} catch (...) {
|
||||
close_impl();
|
||||
throw;
|
||||
}
|
||||
close_impl();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
typedef std::vector<Ch, Alloc> vector_type;
|
||||
typedef typename vector_type::size_type size_type;
|
||||
private:
|
||||
virtual void do_filter(const vector_type& src, vector_type& dest) = 0;
|
||||
virtual void do_close() { }
|
||||
|
||||
template<typename Source>
|
||||
void do_read(Source& src)
|
||||
{
|
||||
using std::streamsize;
|
||||
vector_type data;
|
||||
while (true) {
|
||||
const std::streamsize size = default_device_buffer_size;
|
||||
Ch buf[size];
|
||||
std::streamsize amt;
|
||||
if ((amt = boost::iostreams::read(src, buf, size)) == -1)
|
||||
break;
|
||||
data.insert(data.end(), buf, buf + amt);
|
||||
}
|
||||
do_filter(data, data_);
|
||||
state_ |= f_eof;
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
void do_write(Sink& sink, const char_type* s, std::streamsize n)
|
||||
{
|
||||
typedef typename iostreams::category_of<Sink>::type category;
|
||||
typedef is_convertible<category, output> can_write;
|
||||
do_write(sink, s, n, can_write());
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
void do_write(Sink& sink, const char_type* s, std::streamsize n, mpl::true_)
|
||||
{ iostreams::write(sink, s, n); }
|
||||
|
||||
template<typename Sink>
|
||||
void do_write(Sink&, const char_type*, std::streamsize, mpl::false_) { }
|
||||
|
||||
void close_impl()
|
||||
{
|
||||
data_.clear();
|
||||
ptr_ = 0;
|
||||
state_ = 0;
|
||||
do_close();
|
||||
}
|
||||
|
||||
enum flag_type {
|
||||
f_read = 1,
|
||||
f_write = f_read << 1,
|
||||
f_eof = f_write << 1
|
||||
};
|
||||
|
||||
// Note: typically will not be copied while vector contains data.
|
||||
vector_type data_;
|
||||
size_type ptr_;
|
||||
int state_;
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(aggregate_filter, 1)
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp> // MSVC.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_AGGREGATE_FILTER_HPP_INCLUDED
|
@ -1,82 +0,0 @@
|
||||
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
|
||||
// (C) Copyright 2005-2007 Jonathan Turkanis
|
||||
// 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_COUNTER_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_COUNTER_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <algorithm> // count.
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/char_traits.hpp>
|
||||
#include <boost/iostreams/operations.hpp>
|
||||
#include <boost/iostreams/pipeline.hpp>
|
||||
|
||||
// Must come last.
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp> // VC7.1 C4244.
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
//
|
||||
// Template name: basic_counter.
|
||||
// Template parameters:
|
||||
// Ch - The character type.
|
||||
// Description: Filter which counts lines and characters.
|
||||
//
|
||||
template<typename Ch>
|
||||
class basic_counter {
|
||||
public:
|
||||
typedef Ch char_type;
|
||||
struct category
|
||||
: dual_use,
|
||||
filter_tag,
|
||||
multichar_tag,
|
||||
optimally_buffered_tag
|
||||
{ };
|
||||
explicit basic_counter(int first_line = 0, int first_char = 0)
|
||||
: lines_(first_line), chars_(first_char)
|
||||
{ }
|
||||
int lines() const { return lines_; }
|
||||
int characters() const { return chars_; }
|
||||
std::streamsize optimal_buffer_size() const { return 0; }
|
||||
|
||||
template<typename Source>
|
||||
std::streamsize read(Source& src, char_type* s, std::streamsize n)
|
||||
{
|
||||
std::streamsize result = iostreams::read(src, s, n);
|
||||
if (result == -1)
|
||||
return -1;
|
||||
lines_ += std::count(s, s + result, char_traits<Ch>::newline());
|
||||
chars_ += result;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
std::streamsize write(Sink& snk, const char_type* s, std::streamsize n)
|
||||
{
|
||||
std::streamsize result = iostreams::write(snk, s, n);
|
||||
lines_ += std::count(s, s + result, char_traits<Ch>::newline());
|
||||
chars_ += result;
|
||||
return result;
|
||||
}
|
||||
private:
|
||||
int lines_;
|
||||
int chars_;
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(basic_counter, 1)
|
||||
|
||||
|
||||
typedef basic_counter<char> counter;
|
||||
typedef basic_counter<wchar_t> wcounter;
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_COUNTER_HPP_INCLUDED
|
@ -1,109 +0,0 @@
|
||||
/*
|
||||
* 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/filter/grep.hpp
|
||||
* Date: Mon May 26 17:48:45 MDT 2008
|
||||
* Copyright: 2008 CodeRage, LLC
|
||||
* Author: Jonathan Turkanis
|
||||
* Contact: turkanis at coderage dot com
|
||||
*
|
||||
* Defines the class template basic_grep_filter and its specializations
|
||||
* grep_filter and wgrep_filter.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_GREP_FILTER_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_GREP_FILTER_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <memory> // allocator.
|
||||
#include <boost/iostreams/char_traits.hpp>
|
||||
#include <boost/iostreams/filter/line.hpp>
|
||||
#include <boost/iostreams/pipeline.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
namespace grep {
|
||||
|
||||
const int invert = 1;
|
||||
const int whole_line = invert << 1;
|
||||
|
||||
} // End namespace grep.
|
||||
|
||||
template< typename Ch,
|
||||
typename Tr = regex_traits<Ch>,
|
||||
typename Alloc = std::allocator<Ch> >
|
||||
class basic_grep_filter : public basic_line_filter<Ch, Alloc> {
|
||||
private:
|
||||
typedef basic_line_filter<Ch, Alloc> base_type;
|
||||
public:
|
||||
typedef typename base_type::char_type char_type;
|
||||
typedef typename base_type::category category;
|
||||
typedef char_traits<char_type> traits_type;
|
||||
typedef typename base_type::string_type string_type;
|
||||
typedef basic_regex<Ch, Tr> regex_type;
|
||||
typedef regex_constants::match_flag_type match_flag_type;
|
||||
basic_grep_filter( const regex_type& re,
|
||||
match_flag_type match_flags =
|
||||
regex_constants::match_default,
|
||||
int options = 0 );
|
||||
int count() const { return count_; }
|
||||
|
||||
template<typename Sink>
|
||||
void close(Sink& snk, BOOST_IOS::openmode which)
|
||||
{
|
||||
base_type::close(snk, which);
|
||||
options_ &= ~f_initialized;
|
||||
}
|
||||
private:
|
||||
virtual string_type do_filter(const string_type& line)
|
||||
{
|
||||
if ((options_ & f_initialized) == 0) {
|
||||
options_ |= f_initialized;
|
||||
count_ = 0;
|
||||
}
|
||||
bool matches = (options_ & grep::whole_line) ?
|
||||
regex_match(line, re_, match_flags_) :
|
||||
regex_search(line, re_, match_flags_);
|
||||
if (options_ & grep::invert)
|
||||
matches = !matches;
|
||||
if (matches)
|
||||
++count_;
|
||||
return matches ? line + traits_type::newline() : string_type();
|
||||
}
|
||||
|
||||
// Private flags bitwise OR'd with constants from namespace grep
|
||||
enum flags_ {
|
||||
f_initialized = 65536
|
||||
};
|
||||
|
||||
regex_type re_;
|
||||
match_flag_type match_flags_;
|
||||
int options_;
|
||||
int count_;
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(basic_grep_filter, 3)
|
||||
|
||||
typedef basic_grep_filter<char> grep_filter;
|
||||
typedef basic_grep_filter<wchar_t> wgrep_filter;
|
||||
|
||||
//------------------Implementation of basic_grep_filter-----------------------//
|
||||
|
||||
template<typename Ch, typename Tr, typename Alloc>
|
||||
basic_grep_filter<Ch, Tr, Alloc>::basic_grep_filter
|
||||
(const regex_type& re, match_flag_type match_flags, int options)
|
||||
: base_type(true), re_(re), match_flags_(match_flags),
|
||||
options_(options), count_(0)
|
||||
{ }
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_REGEX_FILTER_HPP_INCLUDED
|
@ -1,221 +0,0 @@
|
||||
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
|
||||
// (C) Copyright 2005-2007 Jonathan Turkanis
|
||||
// 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_LINE_FILTER_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_LINE_FILTER_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <algorithm> // min.
|
||||
#include <boost/assert.hpp>
|
||||
#include <memory> // allocator.
|
||||
#include <string>
|
||||
#include <boost/config.hpp> // BOOST_STATIC_CONSTANT.
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/checked_operations.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // openmode, streamsize.
|
||||
#include <boost/iostreams/read.hpp> // check_eof
|
||||
#include <boost/iostreams/pipeline.hpp>
|
||||
#include <boost/iostreams/write.hpp>
|
||||
|
||||
// Must come last.
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp> // VC7.1 C4244.
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
//
|
||||
// Template name: line_filter.
|
||||
// Template parameters:
|
||||
// Ch - The character type.
|
||||
// Alloc - The allocator type.
|
||||
// Description: Filter which processes data one line at a time.
|
||||
//
|
||||
template< typename Ch,
|
||||
typename Alloc = std::allocator<Ch> >
|
||||
class basic_line_filter {
|
||||
private:
|
||||
typedef typename std::basic_string<Ch>::traits_type string_traits;
|
||||
public:
|
||||
typedef Ch char_type;
|
||||
typedef char_traits<char_type> traits_type;
|
||||
typedef std::basic_string<
|
||||
Ch,
|
||||
string_traits,
|
||||
Alloc
|
||||
> string_type;
|
||||
struct category
|
||||
: dual_use,
|
||||
filter_tag,
|
||||
multichar_tag,
|
||||
closable_tag
|
||||
{ };
|
||||
protected:
|
||||
basic_line_filter(bool suppress_newlines = false)
|
||||
: pos_(string_type::npos),
|
||||
flags_(suppress_newlines ? f_suppress : 0)
|
||||
{ }
|
||||
public:
|
||||
virtual ~basic_line_filter() { }
|
||||
|
||||
template<typename Source>
|
||||
std::streamsize read(Source& src, char_type* s, std::streamsize n)
|
||||
{
|
||||
using namespace std;
|
||||
BOOST_ASSERT(!(flags_ & f_write));
|
||||
flags_ |= f_read;
|
||||
|
||||
// Handle unfinished business.
|
||||
std::streamsize result = 0;
|
||||
if (!cur_line_.empty() && (result = read_line(s, n)) == n)
|
||||
return n;
|
||||
|
||||
typename traits_type::int_type status = traits_type::good();
|
||||
while (result < n && !traits_type::is_eof(status)) {
|
||||
|
||||
// Call next_line() to retrieve a line of filtered text, and
|
||||
// read_line() to copy it into buffer s.
|
||||
if (traits_type::would_block(status = next_line(src)))
|
||||
return result;
|
||||
result += read_line(s + result, n - result);
|
||||
}
|
||||
|
||||
return detail::check_eof(result);
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
std::streamsize write(Sink& snk, const char_type* s, std::streamsize n)
|
||||
{
|
||||
using namespace std;
|
||||
BOOST_ASSERT(!(flags_ & f_read));
|
||||
flags_ |= f_write;
|
||||
|
||||
// Handle unfinished business.
|
||||
if (pos_ != string_type::npos && !write_line(snk))
|
||||
return 0;
|
||||
|
||||
const char_type *cur = s, *next;
|
||||
while (true) {
|
||||
|
||||
// Search for the next full line in [cur, s + n), filter it
|
||||
// and write it to snk.
|
||||
typename string_type::size_type rest = n - (cur - s);
|
||||
if ((next = traits_type::find(cur, rest, traits_type::newline()))) {
|
||||
cur_line_.append(cur, next - cur);
|
||||
cur = next + 1;
|
||||
if (!write_line(snk))
|
||||
return static_cast<std::streamsize>(cur - s);
|
||||
} else {
|
||||
cur_line_.append(cur, rest);
|
||||
return n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
void close(Sink& snk, BOOST_IOS::openmode which)
|
||||
{
|
||||
if ((flags_ & f_read) && which == BOOST_IOS::in)
|
||||
close_impl();
|
||||
|
||||
if ((flags_ & f_write) && which == BOOST_IOS::out) {
|
||||
try {
|
||||
if (!cur_line_.empty())
|
||||
write_line(snk);
|
||||
} catch (...) {
|
||||
try {
|
||||
close_impl();
|
||||
} catch (...) { }
|
||||
throw;
|
||||
}
|
||||
close_impl();
|
||||
}
|
||||
}
|
||||
private:
|
||||
virtual string_type do_filter(const string_type& line) = 0;
|
||||
|
||||
// Copies filtered characters fron the current line into
|
||||
// the given buffer.
|
||||
std::streamsize read_line(char_type* s, std::streamsize n)
|
||||
{
|
||||
using namespace std;
|
||||
std::streamsize result =
|
||||
(std::min) (n, static_cast<std::streamsize>(cur_line_.size()));
|
||||
traits_type::copy(s, cur_line_.data(), result);
|
||||
cur_line_.erase(0, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Attempts to retrieve a line of text from the given source; returns
|
||||
// an int_type as a good/eof/would_block status code.
|
||||
template<typename Source>
|
||||
typename traits_type::int_type next_line(Source& src)
|
||||
{
|
||||
using namespace std;
|
||||
typename traits_type::int_type c;
|
||||
while ( traits_type::is_good(c = iostreams::get(src)) &&
|
||||
c != traits_type::newline() )
|
||||
{
|
||||
cur_line_ += traits_type::to_int_type(c);
|
||||
}
|
||||
if (!traits_type::would_block(c)) {
|
||||
if (!cur_line_.empty() || c == traits_type::newline())
|
||||
cur_line_ = do_filter(cur_line_);
|
||||
if (c == traits_type::newline() && (flags_ & f_suppress) == 0)
|
||||
cur_line_ += c;
|
||||
}
|
||||
return c; // status indicator.
|
||||
}
|
||||
|
||||
// Filters the current line and attemps to write it to the given sink.
|
||||
// Returns true for success.
|
||||
template<typename Sink>
|
||||
bool write_line(Sink& snk)
|
||||
{
|
||||
string_type line = do_filter(cur_line_);
|
||||
if ((flags_ & f_suppress) == 0)
|
||||
line += traits_type::newline();
|
||||
std::streamsize amt = static_cast<std::streamsize>(line.size());
|
||||
bool result = iostreams::write_if(snk, line.data(), amt) == amt;
|
||||
if (result)
|
||||
clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
void close_impl()
|
||||
{
|
||||
clear();
|
||||
flags_ &= f_suppress;
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
cur_line_.erase();
|
||||
pos_ = string_type::npos;
|
||||
}
|
||||
|
||||
enum flag_type {
|
||||
f_read = 1,
|
||||
f_write = f_read << 1,
|
||||
f_suppress = f_write << 1
|
||||
};
|
||||
|
||||
string_type cur_line_;
|
||||
typename string_type::size_type pos_;
|
||||
int flags_;
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(basic_line_filter, 2)
|
||||
|
||||
typedef basic_line_filter<char> line_filter;
|
||||
typedef basic_line_filter<wchar_t> wline_filter;
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_LINE_FILTER_HPP_INCLUDED
|
@ -1,443 +0,0 @@
|
||||
// (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
|
||||
// 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: I hope to replace the current implementation with a much simpler
|
||||
// one.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_NEWLINE_FILTER_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_NEWLINE_FILTER_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstdio>
|
||||
#include <stdexcept> // logic_error.
|
||||
#include <boost/config.hpp> // BOOST_STATIC_CONSTANT.
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/detail/char_traits.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // BOOST_IOSTREAMS_FAILURE
|
||||
#include <boost/iostreams/read.hpp> // get
|
||||
#include <boost/iostreams/write.hpp> // put
|
||||
#include <boost/iostreams/pipeline.hpp>
|
||||
#include <boost/iostreams/putback.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
// Must come last.
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp>
|
||||
|
||||
#define BOOST_IOSTREAMS_ASSERT_UNREACHABLE(val) \
|
||||
(BOOST_ASSERT("unreachable code" == 0), val) \
|
||||
/**/
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
namespace newline {
|
||||
|
||||
const char CR = 0x0D;
|
||||
const char LF = 0x0A;
|
||||
|
||||
// Flags for configuring newline_filter.
|
||||
|
||||
// Exactly one of the following three flags must be present.
|
||||
|
||||
const int posix = 1; // Use CR as line separator.
|
||||
const int mac = 2; // Use LF as line separator.
|
||||
const int dos = 4; // Use CRLF as line separator.
|
||||
const int mixed = 8; // Mixed line endings.
|
||||
const int final_newline = 16;
|
||||
const int platform_mask = posix | dos | mac;
|
||||
|
||||
} // End namespace newline.
|
||||
|
||||
namespace detail {
|
||||
|
||||
class newline_base {
|
||||
public:
|
||||
bool is_posix() const
|
||||
{
|
||||
return !is_mixed() && (flags_ & newline::posix) != 0;
|
||||
}
|
||||
bool is_dos() const
|
||||
{
|
||||
return !is_mixed() && (flags_ & newline::dos) != 0;
|
||||
}
|
||||
bool is_mac() const
|
||||
{
|
||||
return !is_mixed() && (flags_ & newline::mac) != 0;
|
||||
}
|
||||
bool is_mixed_posix() const { return (flags_ & newline::posix) != 0; }
|
||||
bool is_mixed_dos() const { return (flags_ & newline::dos) != 0; }
|
||||
bool is_mixed_mac() const { return (flags_ & newline::mac) != 0; }
|
||||
bool is_mixed() const
|
||||
{
|
||||
int platform =
|
||||
(flags_ & newline::posix) != 0 ?
|
||||
newline::posix :
|
||||
(flags_ & newline::dos) != 0 ?
|
||||
newline::dos :
|
||||
(flags_ & newline::mac) != 0 ?
|
||||
newline::mac :
|
||||
0;
|
||||
return (flags_ & ~platform & newline::platform_mask) != 0;
|
||||
}
|
||||
bool has_final_newline() const
|
||||
{
|
||||
return (flags_ & newline::final_newline) != 0;
|
||||
}
|
||||
protected:
|
||||
newline_base(int flags) : flags_(flags) { }
|
||||
int flags_;
|
||||
};
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
class newline_error
|
||||
: public BOOST_IOSTREAMS_FAILURE, public detail::newline_base
|
||||
{
|
||||
private:
|
||||
friend class newline_checker;
|
||||
newline_error(int flags)
|
||||
: BOOST_IOSTREAMS_FAILURE("bad line endings"),
|
||||
detail::newline_base(flags)
|
||||
{ }
|
||||
};
|
||||
|
||||
class newline_filter {
|
||||
public:
|
||||
typedef char char_type;
|
||||
struct category
|
||||
: dual_use,
|
||||
filter_tag,
|
||||
closable_tag
|
||||
{ };
|
||||
|
||||
explicit newline_filter(int target) : flags_(target)
|
||||
{
|
||||
if ( target != iostreams::newline::posix &&
|
||||
target != iostreams::newline::dos &&
|
||||
target != iostreams::newline::mac )
|
||||
{
|
||||
boost::throw_exception(std::logic_error("bad flags"));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Source>
|
||||
int get(Source& src)
|
||||
{
|
||||
using iostreams::newline::CR;
|
||||
using iostreams::newline::LF;
|
||||
|
||||
BOOST_ASSERT((flags_ & f_write) == 0);
|
||||
flags_ |= f_read;
|
||||
|
||||
if (flags_ & (f_has_LF | f_has_EOF)) {
|
||||
if (flags_ & f_has_LF)
|
||||
return newline();
|
||||
else
|
||||
return EOF;
|
||||
}
|
||||
|
||||
int c =
|
||||
(flags_ & f_has_CR) == 0 ?
|
||||
iostreams::get(src) :
|
||||
CR;
|
||||
|
||||
if (c == WOULD_BLOCK )
|
||||
return WOULD_BLOCK;
|
||||
|
||||
if (c == CR) {
|
||||
flags_ |= f_has_CR;
|
||||
|
||||
int d = iostreams::get(src);
|
||||
if (d == WOULD_BLOCK)
|
||||
return WOULD_BLOCK;
|
||||
|
||||
if (d == LF) {
|
||||
flags_ &= ~f_has_CR;
|
||||
return newline();
|
||||
}
|
||||
|
||||
if (d == EOF) {
|
||||
flags_ |= f_has_EOF;
|
||||
} else {
|
||||
iostreams::putback(src, d);
|
||||
}
|
||||
|
||||
flags_ &= ~f_has_CR;
|
||||
return newline();
|
||||
}
|
||||
|
||||
if (c == LF)
|
||||
return newline();
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
bool put(Sink& dest, char c)
|
||||
{
|
||||
using iostreams::newline::CR;
|
||||
using iostreams::newline::LF;
|
||||
|
||||
BOOST_ASSERT((flags_ & f_read) == 0);
|
||||
flags_ |= f_write;
|
||||
|
||||
if ((flags_ & f_has_LF) != 0)
|
||||
return c == LF ?
|
||||
newline(dest) :
|
||||
newline(dest) && this->put(dest, c);
|
||||
|
||||
if (c == LF)
|
||||
return newline(dest);
|
||||
|
||||
if ((flags_ & f_has_CR) != 0)
|
||||
return newline(dest) ?
|
||||
this->put(dest, c) :
|
||||
false;
|
||||
|
||||
if (c == CR) {
|
||||
flags_ |= f_has_CR;
|
||||
return true;
|
||||
}
|
||||
|
||||
return iostreams::put(dest, c);
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
void close(Sink& dest, BOOST_IOS::openmode)
|
||||
{
|
||||
if ((flags_ & f_write) != 0 && (flags_ & f_has_CR) != 0)
|
||||
newline_if_sink(dest);
|
||||
flags_ &= ~f_has_LF; // Restore original flags.
|
||||
}
|
||||
private:
|
||||
|
||||
// Returns the appropriate element of a newline sequence.
|
||||
int newline()
|
||||
{
|
||||
using iostreams::newline::CR;
|
||||
using iostreams::newline::LF;
|
||||
|
||||
switch (flags_ & iostreams::newline::platform_mask) {
|
||||
case iostreams::newline::posix:
|
||||
return LF;
|
||||
case iostreams::newline::mac:
|
||||
return CR;
|
||||
case iostreams::newline::dos:
|
||||
if (flags_ & f_has_LF) {
|
||||
flags_ &= ~f_has_LF;
|
||||
return LF;
|
||||
} else {
|
||||
flags_ |= f_has_LF;
|
||||
return CR;
|
||||
}
|
||||
}
|
||||
return BOOST_IOSTREAMS_ASSERT_UNREACHABLE(0);
|
||||
}
|
||||
|
||||
// Writes a newline sequence.
|
||||
template<typename Sink>
|
||||
bool newline(Sink& dest)
|
||||
{
|
||||
using iostreams::newline::CR;
|
||||
using iostreams::newline::LF;
|
||||
|
||||
bool success = false;
|
||||
switch (flags_ & iostreams::newline::platform_mask) {
|
||||
case iostreams::newline::posix:
|
||||
success = boost::iostreams::put(dest, LF);
|
||||
break;
|
||||
case iostreams::newline::mac:
|
||||
success = boost::iostreams::put(dest, CR);
|
||||
break;
|
||||
case iostreams::newline::dos:
|
||||
if ((flags_ & f_has_LF) != 0) {
|
||||
success = boost::iostreams::put(dest, LF);
|
||||
if (success)
|
||||
flags_ &= ~f_has_LF;
|
||||
} else if (boost::iostreams::put(dest, CR)) {
|
||||
success = boost::iostreams::put(dest, LF);
|
||||
if (!success)
|
||||
flags_ |= f_has_LF;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (success)
|
||||
flags_ &= ~f_has_CR;
|
||||
return success;
|
||||
}
|
||||
|
||||
// Writes a newline sequence if the given device is a Sink.
|
||||
template<typename Device>
|
||||
void newline_if_sink(Device& dest)
|
||||
{
|
||||
typedef typename iostreams::category_of<Device>::type category;
|
||||
newline_if_sink(dest, is_convertible<category, output>());
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
void newline_if_sink(Sink& dest, mpl::true_) { newline(dest); }
|
||||
|
||||
template<typename Source>
|
||||
void newline_if_sink(Source&, mpl::false_) { }
|
||||
|
||||
enum flags {
|
||||
f_has_LF = 32768,
|
||||
f_has_CR = f_has_LF << 1,
|
||||
f_has_newline = f_has_CR << 1,
|
||||
f_has_EOF = f_has_newline << 1,
|
||||
f_read = f_has_EOF << 1,
|
||||
f_write = f_read << 1
|
||||
};
|
||||
int flags_;
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(newline_filter, 0)
|
||||
|
||||
class newline_checker : public detail::newline_base {
|
||||
public:
|
||||
typedef char char_type;
|
||||
struct category
|
||||
: dual_use_filter_tag,
|
||||
closable_tag
|
||||
{ };
|
||||
explicit newline_checker(int target = newline::mixed)
|
||||
: detail::newline_base(0), target_(target), open_(false)
|
||||
{ }
|
||||
template<typename Source>
|
||||
int get(Source& src)
|
||||
{
|
||||
using newline::CR;
|
||||
using newline::LF;
|
||||
|
||||
if (!open_) {
|
||||
open_ = true;
|
||||
source() = 0;
|
||||
}
|
||||
|
||||
int c;
|
||||
if ((c = iostreams::get(src)) == WOULD_BLOCK)
|
||||
return WOULD_BLOCK;
|
||||
|
||||
// Update source flags.
|
||||
if (c != EOF)
|
||||
source() &= ~f_line_complete;
|
||||
if ((source() & f_has_CR) != 0) {
|
||||
if (c == LF) {
|
||||
source() |= newline::dos;
|
||||
source() |= f_line_complete;
|
||||
} else {
|
||||
source() |= newline::mac;
|
||||
if (c == EOF)
|
||||
source() |= f_line_complete;
|
||||
}
|
||||
} else if (c == LF) {
|
||||
source() |= newline::posix;
|
||||
source() |= f_line_complete;
|
||||
}
|
||||
source() = (source() & ~f_has_CR) | (c == CR ? f_has_CR : 0);
|
||||
|
||||
// Check for errors.
|
||||
if ( c == EOF &&
|
||||
(target_ & newline::final_newline) != 0 &&
|
||||
(source() & f_line_complete) == 0 )
|
||||
{
|
||||
fail();
|
||||
}
|
||||
if ( (target_ & newline::platform_mask) != 0 &&
|
||||
(source() & ~target_ & newline::platform_mask) != 0 )
|
||||
{
|
||||
fail();
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
bool put(Sink& dest, int c)
|
||||
{
|
||||
using iostreams::newline::CR;
|
||||
using iostreams::newline::LF;
|
||||
|
||||
if (!open_) {
|
||||
open_ = true;
|
||||
source() = 0;
|
||||
}
|
||||
|
||||
if (!iostreams::put(dest, c))
|
||||
return false;
|
||||
|
||||
// Update source flags.
|
||||
source() &= ~f_line_complete;
|
||||
if ((source() & f_has_CR) != 0) {
|
||||
if (c == LF) {
|
||||
source() |= newline::dos;
|
||||
source() |= f_line_complete;
|
||||
} else {
|
||||
source() |= newline::mac;
|
||||
}
|
||||
} else if (c == LF) {
|
||||
source() |= newline::posix;
|
||||
source() |= f_line_complete;
|
||||
}
|
||||
source() = (source() & ~f_has_CR) | (c == CR ? f_has_CR : 0);
|
||||
|
||||
// Check for errors.
|
||||
if ( (target_ & newline::platform_mask) != 0 &&
|
||||
(source() & ~target_ & newline::platform_mask) != 0 )
|
||||
{
|
||||
fail();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
void close(Sink&, BOOST_IOS::openmode)
|
||||
{
|
||||
using iostreams::newline::final_newline;
|
||||
|
||||
// Update final_newline flag.
|
||||
if ( (source() & f_has_CR) != 0 ||
|
||||
(source() & f_line_complete) != 0 )
|
||||
{
|
||||
source() |= final_newline;
|
||||
}
|
||||
|
||||
// Clear non-sticky flags.
|
||||
source() &= ~(f_has_CR | f_line_complete);
|
||||
|
||||
// Check for errors.
|
||||
if ( (target_ & final_newline) != 0 &&
|
||||
(source() & final_newline) == 0 )
|
||||
{
|
||||
fail();
|
||||
}
|
||||
}
|
||||
private:
|
||||
void fail() { boost::throw_exception(newline_error(source())); }
|
||||
int& source() { return flags_; }
|
||||
int source() const { return flags_; }
|
||||
|
||||
enum flags {
|
||||
f_has_CR = 32768,
|
||||
f_line_complete = f_has_CR << 1
|
||||
};
|
||||
|
||||
int target_; // Represents expected input.
|
||||
bool open_;
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(newline_checker, 0)
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_NEWLINE_FILTER_HPP_INCLUDED
|
@ -1,98 +0,0 @@
|
||||
// (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
|
||||
// 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_REGEX_FILTER_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_REGEX_FILTER_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <memory> // allocator.
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/iostreams/filter/aggregate.hpp>
|
||||
#include <boost/iostreams/pipeline.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
template< typename Ch,
|
||||
typename Tr = regex_traits<Ch>,
|
||||
typename Alloc = std::allocator<Ch> >
|
||||
class basic_regex_filter : public aggregate_filter<Ch, Alloc> {
|
||||
private:
|
||||
typedef aggregate_filter<Ch, Alloc> base_type;
|
||||
public:
|
||||
typedef typename base_type::char_type char_type;
|
||||
typedef typename base_type::category category;
|
||||
typedef std::basic_string<Ch> string_type;
|
||||
typedef basic_regex<Ch, Tr> regex_type;
|
||||
typedef regex_constants::match_flag_type flag_type;
|
||||
typedef match_results<const Ch*> match_type;
|
||||
typedef function1<string_type, const match_type&> formatter;
|
||||
|
||||
basic_regex_filter( const regex_type& re,
|
||||
const formatter& replace,
|
||||
flag_type flags = regex_constants::match_default )
|
||||
: re_(re), replace_(replace), flags_(flags) { }
|
||||
basic_regex_filter( const regex_type& re,
|
||||
const string_type& fmt,
|
||||
flag_type flags = regex_constants::match_default,
|
||||
flag_type fmt_flags = regex_constants::format_default )
|
||||
: re_(re), replace_(simple_formatter(fmt, fmt_flags)), flags_(flags) { }
|
||||
basic_regex_filter( const regex_type& re,
|
||||
const char_type* fmt,
|
||||
flag_type flags = regex_constants::match_default,
|
||||
flag_type fmt_flags = regex_constants::format_default )
|
||||
: re_(re), replace_(simple_formatter(fmt, fmt_flags)), flags_(flags) { }
|
||||
private:
|
||||
typedef typename base_type::vector_type vector_type;
|
||||
void do_filter(const vector_type& src, vector_type& dest)
|
||||
{
|
||||
typedef regex_iterator<const Ch*, Ch, Tr> iterator;
|
||||
if (src.empty())
|
||||
return;
|
||||
iterator first(&src[0], &src[0] + src.size(), re_, flags_);
|
||||
iterator last;
|
||||
const Ch* suffix = 0;
|
||||
for (; first != last; ++first) {
|
||||
dest.insert( dest.end(),
|
||||
first->prefix().first,
|
||||
first->prefix().second );
|
||||
string_type replacement = replace_(*first);
|
||||
dest.insert( dest.end(),
|
||||
replacement.begin(),
|
||||
replacement.end() );
|
||||
suffix = first->suffix().first;
|
||||
}
|
||||
if (suffix) {
|
||||
dest.insert(dest.end(), suffix, &src[0] + src.size());
|
||||
} else {
|
||||
dest.insert(dest.end(), &src[0], &src[0] + src.size());
|
||||
}
|
||||
}
|
||||
struct simple_formatter {
|
||||
simple_formatter(const string_type& fmt, flag_type fmt_flags)
|
||||
: fmt_(fmt), fmt_flags_(fmt_flags) { }
|
||||
string_type operator() (const match_type& match) const
|
||||
{ return match.format(fmt_, fmt_flags_); }
|
||||
string_type fmt_;
|
||||
flag_type fmt_flags_;
|
||||
};
|
||||
regex_type re_;
|
||||
formatter replace_;
|
||||
flag_type flags_;
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(basic_regex_filter, 3)
|
||||
|
||||
typedef basic_regex_filter<char> regex_filter;
|
||||
typedef basic_regex_filter<wchar_t> wregex_filter;
|
||||
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_REGEX_FILTER_HPP_INCLUDED
|
@ -1,84 +0,0 @@
|
||||
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
|
||||
// (C) Copyright 2005-2007 Jonathan Turkanis
|
||||
// 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.
|
||||
|
||||
// Based on the work of Christopher Diggins.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_STDIO_FILTER_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_STDIO_FILTER_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <memory> // allocator.
|
||||
#include <vector>
|
||||
#include <boost/iostreams/detail/config/wide_streams.hpp>
|
||||
#include <boost/iostreams/detail/char_traits.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp>
|
||||
#include <boost/iostreams/device/array.hpp>
|
||||
#include <boost/iostreams/device/back_inserter.hpp>
|
||||
#include <boost/iostreams/filter/aggregate.hpp>
|
||||
#include <boost/iostreams/pipeline.hpp>
|
||||
#include <boost/iostreams/stream_buffer.hpp>
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
namespace detail {
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
template<typename Ch, typename Alloc = std::allocator<Ch> >
|
||||
class basic_stdio_filter : public aggregate_filter<Ch, Alloc> {
|
||||
private:
|
||||
typedef aggregate_filter<Ch, Alloc> base_type;
|
||||
public:
|
||||
typedef typename base_type::char_type char_type;
|
||||
typedef typename base_type::category category;
|
||||
typedef typename base_type::vector_type vector_type;
|
||||
private:
|
||||
static std::istream& standard_input(char*) { return std::cin; }
|
||||
static std::ostream& standard_output(char*) { return std::cout; }
|
||||
#ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS
|
||||
static std::wistream& standard_input(wchar_t*) { return std::wcin; }
|
||||
static std::wostream& standard_output(wchar_t*) { return std::wcout; }
|
||||
#endif // BOOST_IOSTREAMS_NO_WIDE_STREAMS
|
||||
|
||||
struct scoped_redirector { // Thanks to Maxim Egorushkin.
|
||||
typedef BOOST_IOSTREAMS_CHAR_TRAITS(Ch) traits_type;
|
||||
typedef BOOST_IOSTREAMS_BASIC_IOS(Ch, traits_type) ios_type;
|
||||
typedef BOOST_IOSTREAMS_BASIC_STREAMBUF(Ch, traits_type) streambuf_type;
|
||||
scoped_redirector( ios_type& ios,
|
||||
streambuf_type* newbuf )
|
||||
: ios_(ios), old_(ios.rdbuf(newbuf))
|
||||
{ }
|
||||
~scoped_redirector() { ios_.rdbuf(old_); }
|
||||
scoped_redirector& operator=(const scoped_redirector&);
|
||||
ios_type& ios_;
|
||||
streambuf_type* old_;
|
||||
};
|
||||
|
||||
virtual void do_filter() = 0;
|
||||
virtual void do_filter(const vector_type& src, vector_type& dest)
|
||||
{
|
||||
stream_buffer< basic_array_source<Ch> >
|
||||
srcbuf(&src[0], &src[0] + src.size());
|
||||
stream_buffer< back_insert_device<vector_type> >
|
||||
destbuf(iostreams::back_inserter(dest));
|
||||
scoped_redirector redirect_input(standard_input((Ch*)0), &srcbuf);
|
||||
scoped_redirector redirect_output(standard_output((Ch*)0), &destbuf);
|
||||
do_filter();
|
||||
}
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(basic_stdio_filter, 2)
|
||||
|
||||
typedef basic_stdio_filter<char> stdio_filter;
|
||||
typedef basic_stdio_filter<wchar_t> wstdio_wfilter;
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_STDIO_FILTER_HPP_INCLUDED
|
@ -1,319 +0,0 @@
|
||||
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
|
||||
// (C) Copyright 2005-2007 Jonathan Turkanis
|
||||
// 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_FILTER_TEST_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> // BOOST_MSVC,put size_t in std.
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <algorithm> // min.
|
||||
#include <cstddef> // size_t.
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) || \
|
||||
BOOST_WORKAROUND(__MWERKS__, <= 0x3003) \
|
||||
/**/
|
||||
# include <cstdlib> // rand.
|
||||
#endif
|
||||
#include <cstring> // memcpy, strlen.
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__MWERKS__, <= 0x3003) \
|
||||
/**/
|
||||
# include <boost/random/linear_congruential.hpp>
|
||||
# include <boost/random/uniform_smallint.hpp>
|
||||
#endif
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/compose.hpp>
|
||||
#include <boost/iostreams/copy.hpp>
|
||||
#include <boost/iostreams/detail/bool_trait_def.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp>
|
||||
#include <boost/iostreams/device/array.hpp>
|
||||
#include <boost/iostreams/device/back_inserter.hpp>
|
||||
#include <boost/iostreams/operations.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#undef memcpy
|
||||
#undef rand
|
||||
#undef strlen
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE) && !defined(__LIBCOMO__)
|
||||
namespace std {
|
||||
using ::memcpy;
|
||||
using ::strlen;
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) || \
|
||||
BOOST_WORKAROUND(__MWERKS__, <= 0x3003) \
|
||||
/**/
|
||||
using ::rand;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_string, std::basic_string, 3)
|
||||
|
||||
const std::streamsize default_increment = 5;
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__MWERKS__, <= 0x3003) \
|
||||
/**/
|
||||
std::streamsize rand(std::streamsize inc)
|
||||
{
|
||||
static rand48 random_gen;
|
||||
static uniform_smallint<int> random_dist(0, static_cast<int>(inc));
|
||||
return random_dist(random_gen);
|
||||
}
|
||||
#else
|
||||
std::streamsize rand(std::streamsize inc)
|
||||
{
|
||||
return (std::rand() * inc + 1) / RAND_MAX;
|
||||
}
|
||||
#endif
|
||||
|
||||
class non_blocking_source {
|
||||
public:
|
||||
typedef char char_type;
|
||||
struct category
|
||||
: source_tag,
|
||||
peekable_tag
|
||||
{ };
|
||||
explicit non_blocking_source( const std::string& data,
|
||||
std::streamsize inc = default_increment )
|
||||
: data_(data), inc_(inc), pos_(0)
|
||||
{ }
|
||||
std::streamsize read(char* s, std::streamsize n)
|
||||
{
|
||||
using namespace std;
|
||||
if (pos_ == static_cast<streamsize>(data_.size()))
|
||||
return -1;
|
||||
streamsize avail =
|
||||
(std::min) (n, static_cast<streamsize>(data_.size() - pos_));
|
||||
streamsize amt = (std::min) (rand(inc_), avail);
|
||||
if (amt)
|
||||
memcpy(s, data_.c_str() + pos_, static_cast<size_t>(amt));
|
||||
pos_ += amt;
|
||||
return amt;
|
||||
}
|
||||
|
||||
bool putback(char c)
|
||||
{
|
||||
if (pos_ > 0) {
|
||||
data_[static_cast<std::string::size_type>(--pos_)] = c;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
std::string data_;
|
||||
std::streamsize inc_, pos_;
|
||||
};
|
||||
|
||||
class non_blocking_sink : public sink {
|
||||
public:
|
||||
non_blocking_sink( std::string& dest,
|
||||
std::streamsize inc = default_increment )
|
||||
: dest_(dest), inc_(inc)
|
||||
{ }
|
||||
std::streamsize write(const char* s, std::streamsize n)
|
||||
{
|
||||
std::streamsize amt = (std::min) (rand(inc_), n);
|
||||
dest_.insert(dest_.end(), s, s + amt);
|
||||
return amt;
|
||||
}
|
||||
private:
|
||||
non_blocking_sink& operator=(const non_blocking_sink&);
|
||||
std::string& dest_;
|
||||
std::streamsize inc_;
|
||||
};
|
||||
|
||||
//--------------Definition of test_input_filter-------------------------------//
|
||||
|
||||
template<typename Filter>
|
||||
bool test_input_filter( Filter filter,
|
||||
const std::string& input,
|
||||
const std::string& output,
|
||||
mpl::true_ )
|
||||
{
|
||||
for ( int inc = default_increment;
|
||||
inc < default_increment * 40;
|
||||
inc += default_increment )
|
||||
{
|
||||
non_blocking_source src(input, inc);
|
||||
std::string dest;
|
||||
iostreams::copy(compose(filter, src), iostreams::back_inserter(dest));
|
||||
if (dest != output)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename Filter, typename Source1, typename Source2>
|
||||
bool test_input_filter( Filter filter,
|
||||
const Source1& input,
|
||||
const Source2& output,
|
||||
mpl::false_ )
|
||||
{
|
||||
std::string in;
|
||||
std::string out;
|
||||
iostreams::copy(input, iostreams::back_inserter(in));
|
||||
iostreams::copy(output, iostreams::back_inserter(out));
|
||||
return test_input_filter(filter, in, out);
|
||||
}
|
||||
|
||||
template<typename Filter, typename Source1, typename Source2>
|
||||
bool test_input_filter( Filter filter,
|
||||
const Source1& input,
|
||||
const Source2& output )
|
||||
{
|
||||
// Use tag dispatch to compensate for bad overload resolution.
|
||||
return test_input_filter( filter, input, output,
|
||||
is_string<Source1>() );
|
||||
}
|
||||
|
||||
//--------------Definition of test_output_filter------------------------------//
|
||||
|
||||
template<typename Filter>
|
||||
bool test_output_filter( Filter filter,
|
||||
const std::string& input,
|
||||
const std::string& output,
|
||||
mpl::true_ )
|
||||
{
|
||||
for ( int inc = default_increment;
|
||||
inc < default_increment * 40;
|
||||
inc += default_increment )
|
||||
{
|
||||
array_source src(input.data(), input.data() + input.size());
|
||||
std::string dest;
|
||||
iostreams::copy(src, compose(filter, non_blocking_sink(dest, inc)));
|
||||
if (dest != output )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename Filter, typename Source1, typename Source2>
|
||||
bool test_output_filter( Filter filter,
|
||||
const Source1& input,
|
||||
const Source2& output,
|
||||
mpl::false_ )
|
||||
{
|
||||
std::string in;
|
||||
std::string out;
|
||||
iostreams::copy(input, iostreams::back_inserter(in));
|
||||
iostreams::copy(output, iostreams::back_inserter(out));
|
||||
return test_output_filter(filter, in, out);
|
||||
}
|
||||
|
||||
template<typename Filter, typename Source1, typename Source2>
|
||||
bool test_output_filter( Filter filter,
|
||||
const Source1& input,
|
||||
const Source2& output )
|
||||
{
|
||||
// Use tag dispatch to compensate for bad overload resolution.
|
||||
return test_output_filter( filter, input, output,
|
||||
is_string<Source1>() );
|
||||
}
|
||||
|
||||
//--------------Definition of test_filter_pair--------------------------------//
|
||||
|
||||
template<typename OutputFilter, typename InputFilter>
|
||||
bool test_filter_pair( OutputFilter out,
|
||||
InputFilter in,
|
||||
const std::string& data,
|
||||
mpl::true_ )
|
||||
{
|
||||
for ( int inc = default_increment;
|
||||
inc <= default_increment * 40;
|
||||
inc += default_increment )
|
||||
{
|
||||
{
|
||||
array_source src(data.data(), data.data() + data.size());
|
||||
std::string temp;
|
||||
std::string dest;
|
||||
iostreams::copy(src, compose(out, non_blocking_sink(temp, inc)));
|
||||
iostreams::copy(
|
||||
compose(in, non_blocking_source(temp, inc)),
|
||||
iostreams::back_inserter(dest)
|
||||
);
|
||||
if (dest != data)
|
||||
return false;
|
||||
}
|
||||
{
|
||||
array_source src(data.data(), data.data() + data.size());
|
||||
std::string temp;
|
||||
std::string dest;
|
||||
iostreams::copy(src, compose(out, non_blocking_sink(temp, inc)));
|
||||
// truncate the file, this should not loop, it may throw
|
||||
// std::ios_base::failure, which we swallow.
|
||||
try {
|
||||
temp.resize(temp.size() / 2);
|
||||
iostreams::copy(
|
||||
compose(in, non_blocking_source(temp, inc)),
|
||||
iostreams::back_inserter(dest)
|
||||
);
|
||||
} catch(std::ios_base::failure&) {}
|
||||
}
|
||||
{
|
||||
array_source src(data.data(), data.data() + data.size());
|
||||
std::string temp;
|
||||
std::string dest;
|
||||
iostreams::copy(compose(out, src), non_blocking_sink(temp, inc));
|
||||
iostreams::copy(
|
||||
non_blocking_source(temp, inc),
|
||||
compose(in, iostreams::back_inserter(dest))
|
||||
);
|
||||
if (dest != data)
|
||||
return false;
|
||||
}
|
||||
{
|
||||
array_source src(data.data(), data.data() + data.size());
|
||||
std::string temp;
|
||||
std::string dest;
|
||||
iostreams::copy(compose(out, src), non_blocking_sink(temp, inc));
|
||||
// truncate the file, this should not loop, it may throw
|
||||
// std::ios_base::failure, which we swallow.
|
||||
try {
|
||||
temp.resize(temp.size() / 2);
|
||||
iostreams::copy(
|
||||
non_blocking_source(temp, inc),
|
||||
compose(in, iostreams::back_inserter(dest))
|
||||
);
|
||||
} catch(std::ios_base::failure&) {}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename OutputFilter, typename InputFilter, typename Source>
|
||||
bool test_filter_pair( OutputFilter out,
|
||||
InputFilter in,
|
||||
const Source& data,
|
||||
mpl::false_ )
|
||||
{
|
||||
std::string str;
|
||||
iostreams::copy(data, iostreams::back_inserter(str));
|
||||
return test_filter_pair(out, in, str);
|
||||
}
|
||||
|
||||
template<typename OutputFilter, typename InputFilter, typename Source>
|
||||
bool test_filter_pair( OutputFilter out,
|
||||
InputFilter in,
|
||||
const Source& data )
|
||||
{
|
||||
// Use tag dispatch to compensate for bad overload resolution.
|
||||
return test_filter_pair(out, in, data, is_string<Source>());
|
||||
}
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_FILTER_TEST_HPP_INCLUDED
|
@ -1,187 +0,0 @@
|
||||
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
|
||||
// (C) Copyright 2004-2007 Jonathan Turkanis
|
||||
// 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_FILTER_STREAM_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_FILTER_STREAM_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <memory> // allocator.
|
||||
#include <boost/iostreams/detail/access_control.hpp>
|
||||
#include <boost/iostreams/detail/char_traits.hpp>
|
||||
#include <boost/iostreams/detail/iostream.hpp> // standard streams.
|
||||
#include <boost/iostreams/detail/push.hpp>
|
||||
#include <boost/iostreams/detail/select.hpp>
|
||||
#include <boost/iostreams/detail/streambuf.hpp> // pubsync.
|
||||
#include <boost/iostreams/filtering_streambuf.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
// Must come last.
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
//--------------Definition of filtered_istream--------------------------------//
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename Mode, typename Ch, typename Tr>
|
||||
struct filtering_stream_traits {
|
||||
typedef typename
|
||||
iostreams::select< // Disambiguation for Tru64
|
||||
mpl::and_<
|
||||
is_convertible<Mode, input>,
|
||||
is_convertible<Mode, output>
|
||||
>,
|
||||
BOOST_IOSTREAMS_BASIC_IOSTREAM(Ch, Tr),
|
||||
is_convertible<Mode, input>,
|
||||
BOOST_IOSTREAMS_BASIC_ISTREAM(Ch, Tr),
|
||||
else_,
|
||||
BOOST_IOSTREAMS_BASIC_OSTREAM(Ch, Tr)
|
||||
>::type stream_type;
|
||||
typedef typename
|
||||
iostreams::select< // Dismbiguation required for Tru64.
|
||||
mpl::and_<
|
||||
is_convertible<Mode, input>,
|
||||
is_convertible<Mode, output>
|
||||
>,
|
||||
iostream_tag,
|
||||
is_convertible<Mode, input>,
|
||||
istream_tag,
|
||||
else_,
|
||||
ostream_tag
|
||||
>::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<
|
||||
boost::iostreams::detail::chain_client<Chain>,
|
||||
Access
|
||||
>,
|
||||
public filtering_stream_traits<
|
||||
typename Chain::mode,
|
||||
typename Chain::char_type,
|
||||
typename Chain::traits_type
|
||||
>::stream_type
|
||||
{
|
||||
public:
|
||||
typedef Chain chain_type;
|
||||
typedef access_control<
|
||||
boost::iostreams::detail::chain_client<Chain>,
|
||||
Access
|
||||
> client_type;
|
||||
protected:
|
||||
typedef typename
|
||||
filtering_stream_traits<
|
||||
typename Chain::mode,
|
||||
typename Chain::char_type,
|
||||
typename Chain::traits_type
|
||||
>::stream_type stream_type;
|
||||
filtering_stream_base() : stream_type(0) { this->set_chain(&chain_); }
|
||||
private:
|
||||
void notify() { this->rdbuf(chain_.empty() ? 0 : &chain_.front()); }
|
||||
Chain chain_;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
//
|
||||
// Macro: BOOST_IOSTREAMS_DEFINE_FILTER_STREAM(name_, chain_type_, default_char_)
|
||||
// Description: Defines a template derived from std::basic_streambuf which uses
|
||||
// a chain to perform i/o. The template has the following parameters:
|
||||
// Mode - the i/o mode.
|
||||
// Ch - The character type.
|
||||
// Tr - The character traits type.
|
||||
// Alloc - The allocator type.
|
||||
// Access - Indicates accessibility of the chain interface; must be either
|
||||
// public_ or protected_; defaults to public_.
|
||||
// Macro parameters:
|
||||
// name_ - The name of the template to be defined.
|
||||
// chain_type_ - The name of the chain template.
|
||||
// default_char_ - The default value for the char template parameter.
|
||||
//
|
||||
#define BOOST_IOSTREAMS_DEFINE_FILTER_STREAM(name_, chain_type_, default_char_) \
|
||||
template< typename Mode, \
|
||||
typename Ch = default_char_, \
|
||||
typename Tr = BOOST_IOSTREAMS_CHAR_TRAITS(Ch), \
|
||||
typename Alloc = std::allocator<Ch>, \
|
||||
typename Access = public_ > \
|
||||
class name_ \
|
||||
: public boost::iostreams::detail::filtering_stream_base< \
|
||||
chain_type_<Mode, Ch, Tr, Alloc>, Access \
|
||||
> \
|
||||
{ \
|
||||
public: \
|
||||
typedef Ch char_type; \
|
||||
struct category \
|
||||
: Mode, \
|
||||
closable_tag, \
|
||||
detail::filtering_stream_traits<Mode, Ch, Tr>::stream_tag \
|
||||
{ }; \
|
||||
BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr) \
|
||||
typedef Mode mode; \
|
||||
typedef chain_type_<Mode, Ch, Tr, Alloc> chain_type; \
|
||||
name_() { } \
|
||||
BOOST_IOSTREAMS_DEFINE_PUSH_CONSTRUCTOR(name_, mode, Ch, push_impl) \
|
||||
~name_() { \
|
||||
if (this->is_complete()) \
|
||||
this->rdbuf()->BOOST_IOSTREAMS_PUBSYNC(); \
|
||||
} \
|
||||
private: \
|
||||
typedef access_control< \
|
||||
boost::iostreams::detail::chain_client< \
|
||||
chain_type_<Mode, Ch, Tr, Alloc> \
|
||||
>, \
|
||||
Access \
|
||||
> client_type; \
|
||||
template<typename T> \
|
||||
void push_impl(const T& t BOOST_IOSTREAMS_PUSH_PARAMS()) \
|
||||
{ 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;
|
||||
typedef wfiltering_stream<output> filtering_wostream;
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
} } // End namespace iostreams, boost
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp> // MSVC
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_FILTER_STREAM_HPP_INCLUDED
|
@ -1,70 +0,0 @@
|
||||
// (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
|
||||
// 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_FILTERING_STREAMBUF_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_FILTERING_STREAMBUF_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <exception>
|
||||
#include <memory> // allocator.
|
||||
#include <boost/iostreams/chain.hpp>
|
||||
#include <boost/iostreams/detail/access_control.hpp>
|
||||
#include <boost/iostreams/detail/char_traits.hpp>
|
||||
#include <boost/iostreams/detail/push.hpp>
|
||||
#include <boost/iostreams/detail/streambuf.hpp> // pubsync.
|
||||
#include <boost/iostreams/detail/streambuf/chainbuf.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
//
|
||||
// Macro: BOOST_IOSTREAMS_DEFINE_FILTERBUF(name_, chain_type_, default_char_)
|
||||
// Description: Defines a template derived from std::basic_streambuf which uses
|
||||
// a chain to perform i/o. The template has the following parameters:
|
||||
// Ch - The character type.
|
||||
// Tr - The character traits type.
|
||||
// Alloc - The allocator type.
|
||||
// Access - Indicates accessibility of the chain interface; must be either
|
||||
// public_ or protected_; defaults to public_.
|
||||
//
|
||||
#define BOOST_IOSTREAMS_DEFINE_FILTER_STREAMBUF(name_, chain_type_, default_char_) \
|
||||
template< typename Mode, \
|
||||
typename Ch = default_char_, \
|
||||
typename Tr = BOOST_IOSTREAMS_CHAR_TRAITS(Ch), \
|
||||
typename Alloc = std::allocator<Ch>, \
|
||||
typename Access = public_ > \
|
||||
class name_ : public boost::iostreams::detail::chainbuf< \
|
||||
chain_type_<Mode, Ch, Tr, Alloc>, Mode, Access \
|
||||
> \
|
||||
{ \
|
||||
public: \
|
||||
typedef Ch char_type; \
|
||||
struct category \
|
||||
: Mode, closable_tag, streambuf_tag \
|
||||
{ }; \
|
||||
BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr) \
|
||||
typedef Mode mode; \
|
||||
typedef chain_type_<Mode, Ch, Tr, Alloc> chain_type; \
|
||||
name_() { } \
|
||||
BOOST_IOSTREAMS_DEFINE_PUSH_CONSTRUCTOR(name_, mode, Ch, push_impl) \
|
||||
~name_() { if (this->is_complete()) this->BOOST_IOSTREAMS_PUBSYNC(); } \
|
||||
}; \
|
||||
/**/
|
||||
BOOST_IOSTREAMS_DEFINE_FILTER_STREAMBUF(filtering_streambuf, boost::iostreams::chain, char)
|
||||
BOOST_IOSTREAMS_DEFINE_FILTER_STREAMBUF(filtering_wstreambuf, boost::iostreams::chain, wchar_t)
|
||||
|
||||
typedef filtering_streambuf<input> filtering_istreambuf;
|
||||
typedef filtering_streambuf<output> filtering_ostreambuf;
|
||||
typedef filtering_wstreambuf<input> filtering_wistreambuf;
|
||||
typedef filtering_wstreambuf<output> filtering_wostreambuf;
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_FILTERING_STREAMBUF_HPP_INCLUDED
|
@ -1,167 +0,0 @@
|
||||
// (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
|
||||
// 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_INVERT_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_INVERT_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <algorithm> // copy, min.
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp> // BOOST_DEDUCED_TYPENAME.
|
||||
#include <boost/detail/workaround.hpp> // default_filter_buffer_size.
|
||||
#include <boost/iostreams/char_traits.hpp>
|
||||
#include <boost/iostreams/compose.hpp>
|
||||
#include <boost/iostreams/constants.hpp>
|
||||
#include <boost/iostreams/device/array.hpp>
|
||||
#include <boost/iostreams/detail/buffer.hpp>
|
||||
#include <boost/iostreams/detail/counted_array.hpp>
|
||||
#include <boost/iostreams/detail/execute.hpp>
|
||||
#include <boost/iostreams/detail/functional.hpp> // clear_flags, call_reset
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
// Must come last.
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
//
|
||||
// Template name: inverse.
|
||||
// Template parameters:
|
||||
// Filter - A model of InputFilter or OutputFilter.
|
||||
// Description: Generates an InputFilter from an OutputFilter or
|
||||
// vice versa.
|
||||
//
|
||||
template<typename Filter>
|
||||
class inverse {
|
||||
private:
|
||||
BOOST_STATIC_ASSERT(is_filter<Filter>::value);
|
||||
typedef typename category_of<Filter>::type base_category;
|
||||
typedef reference_wrapper<Filter> filter_ref;
|
||||
public:
|
||||
typedef typename char_type_of<Filter>::type char_type;
|
||||
typedef typename int_type_of<Filter>::type int_type;
|
||||
typedef char_traits<char_type> traits_type;
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
is_convertible<
|
||||
base_category,
|
||||
input
|
||||
>,
|
||||
output,
|
||||
input
|
||||
>::type mode;
|
||||
struct category
|
||||
: mode,
|
||||
filter_tag,
|
||||
multichar_tag,
|
||||
closable_tag
|
||||
{ };
|
||||
explicit inverse( const Filter& filter,
|
||||
std::streamsize buffer_size =
|
||||
default_filter_buffer_size)
|
||||
: pimpl_(new impl(filter, buffer_size))
|
||||
{ }
|
||||
|
||||
template<typename Source>
|
||||
std::streamsize read(Source& src, char_type* s, std::streamsize n)
|
||||
{
|
||||
typedef detail::counted_array_sink<char_type> array_sink;
|
||||
typedef composite<filter_ref, array_sink> filtered_array_sink;
|
||||
|
||||
BOOST_ASSERT((flags() & f_write) == 0);
|
||||
if (flags() == 0) {
|
||||
flags() = f_read;
|
||||
buf().set(0, 0);
|
||||
}
|
||||
|
||||
filtered_array_sink snk(filter(), array_sink(s, n));
|
||||
int_type status;
|
||||
for ( status = traits_type::good();
|
||||
snk.second().count() < n && status == traits_type::good(); )
|
||||
{
|
||||
status = buf().fill(src);
|
||||
buf().flush(snk);
|
||||
}
|
||||
return snk.second().count() == 0 &&
|
||||
status == traits_type::eof()
|
||||
?
|
||||
-1
|
||||
:
|
||||
snk.second().count();
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
std::streamsize write(Sink& dest, const char_type* s, std::streamsize n)
|
||||
{
|
||||
typedef detail::counted_array_source<char_type> array_source;
|
||||
typedef composite<filter_ref, array_source> filtered_array_source;
|
||||
|
||||
BOOST_ASSERT((flags() & f_read) == 0);
|
||||
if (flags() == 0) {
|
||||
flags() = f_write;
|
||||
buf().set(0, 0);
|
||||
}
|
||||
|
||||
filtered_array_source src(filter(), array_source(s, n));
|
||||
for (bool good = true; src.second().count() < n && good; ) {
|
||||
buf().fill(src);
|
||||
good = buf().flush(dest);
|
||||
}
|
||||
return src.second().count();
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
void close(Device& dev)
|
||||
{
|
||||
detail::execute_all(
|
||||
detail::flush_buffer(buf(), dev, (flags() & f_write) != 0),
|
||||
detail::call_close_all(pimpl_->filter_, dev),
|
||||
detail::clear_flags(flags())
|
||||
);
|
||||
}
|
||||
private:
|
||||
filter_ref filter() { return boost::ref(pimpl_->filter_); }
|
||||
detail::buffer<char_type>& buf() { return pimpl_->buf_; }
|
||||
int& flags() { return pimpl_->flags_; }
|
||||
|
||||
enum flags_ {
|
||||
f_read = 1, f_write = 2
|
||||
};
|
||||
|
||||
struct impl {
|
||||
impl(const Filter& filter, std::streamsize n)
|
||||
: filter_(filter), buf_(n), flags_(0)
|
||||
{ buf_.set(0, 0); }
|
||||
Filter filter_;
|
||||
detail::buffer<char_type> buf_;
|
||||
int flags_;
|
||||
};
|
||||
shared_ptr<impl> pimpl_;
|
||||
};
|
||||
|
||||
//
|
||||
// Template name: invert.
|
||||
// Template parameters:
|
||||
// Filter - A model of InputFilter or OutputFilter.
|
||||
// Description: Returns an instance of an appropriate specialization of inverse.
|
||||
//
|
||||
template<typename Filter>
|
||||
inverse<Filter> invert(const Filter& f) { return inverse<Filter>(f); }
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp> // MSVC.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_INVERT_HPP_INCLUDED
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* 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/restrict.hpp
|
||||
* Date: Sun Jan 06 12:57:30 MST 2008
|
||||
* Copyright: 2008 CodeRage, LLC
|
||||
2004-2007 Jonathan Turkanis
|
||||
* Author: Jonathan Turkanis
|
||||
* Contact: turkanis at coderage dot com
|
||||
*
|
||||
* Defines the class template boost::iostreams::restriction and the
|
||||
* overloaded function template boost::iostreams::restrict
|
||||
*/
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_RESTRICT_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_RESTRICT_HPP_INCLUDED
|
||||
|
||||
#include <boost/iostreams/detail/restrict_impl.hpp>
|
||||
#define BOOST_IOSTREAMS_RESTRICT restrict
|
||||
#include <boost/iostreams/detail/restrict_impl.hpp>
|
||||
#undef BOOST_IOSTREAMS_RESTRICT
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_RESTRICT_HPP_INCLUDED
|
@ -1,112 +0,0 @@
|
||||
// (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
|
||||
// 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.
|
||||
|
||||
// To do: handle bidirection streams and output-seekable components.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_SKIP_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_SKIP_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/iostreams/char_traits.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // failure.
|
||||
#include <boost/iostreams/operations.hpp>
|
||||
#include <boost/iostreams/seek.hpp>
|
||||
#include <boost/iostreams/traits.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename Device>
|
||||
void skip(Device& dev, stream_offset off, mpl::true_)
|
||||
{ iostreams::seek(dev, off, BOOST_IOS::cur); }
|
||||
|
||||
template<typename Device>
|
||||
void skip(Device& dev, stream_offset off, mpl::false_)
|
||||
{ // gcc 2.95 needs namespace qualification for char_traits.
|
||||
typedef typename char_type_of<Device>::type char_type;
|
||||
typedef iostreams::char_traits<char_type> traits_type;
|
||||
for (stream_offset z = 0; z < off; ) {
|
||||
typename traits_type::int_type c;
|
||||
if (traits_type::is_eof(c = iostreams::get(dev)))
|
||||
boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad skip offset"));
|
||||
if (!traits_type::would_block(c))
|
||||
++z;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Filter, typename Device>
|
||||
void skip( Filter& flt, Device& dev, stream_offset off,
|
||||
BOOST_IOS::openmode which, mpl::true_ )
|
||||
{ boost::iostreams::seek(flt, dev, off, BOOST_IOS::cur, which); }
|
||||
|
||||
template<typename Filter, typename Device>
|
||||
void skip( Filter& flt, Device& dev, stream_offset off,
|
||||
BOOST_IOS::openmode, mpl::false_ )
|
||||
{
|
||||
typedef typename char_type_of<Device>::type char_type;
|
||||
char_type c;
|
||||
for (stream_offset z = 0; z < off; ) {
|
||||
std::streamsize amt;
|
||||
if ((amt = iostreams::read(flt, dev, &c, 1)) == -1)
|
||||
boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad skip offset"));
|
||||
if (amt == 1)
|
||||
++z;
|
||||
}
|
||||
}
|
||||
|
||||
} // End namespace detail.
|
||||
|
||||
template<typename Device>
|
||||
void skip(Device& dev, stream_offset off)
|
||||
{
|
||||
typedef typename mode_of<Device>::type mode;
|
||||
typedef mpl::or_<
|
||||
is_convertible<mode, input_seekable>,
|
||||
is_convertible<mode, output_seekable>
|
||||
> can_seek;
|
||||
BOOST_STATIC_ASSERT(
|
||||
(can_seek::value || is_convertible<mode, input>::value)
|
||||
);
|
||||
detail::skip(dev, off, can_seek());
|
||||
}
|
||||
|
||||
template<typename Filter, typename Device>
|
||||
void skip( Filter& flt, Device& dev, stream_offset off,
|
||||
BOOST_IOS::openmode which = BOOST_IOS::in | BOOST_IOS::out )
|
||||
{
|
||||
typedef typename mode_of<Filter>::type filter_mode;
|
||||
typedef typename mode_of<Device>::type device_mode;
|
||||
typedef mpl::or_<
|
||||
mpl::and_<
|
||||
is_convertible<filter_mode, input_seekable>,
|
||||
is_convertible<device_mode, input_seekable>
|
||||
>,
|
||||
mpl::and_<
|
||||
is_convertible<filter_mode, output_seekable>,
|
||||
is_convertible<device_mode, output_seekable>
|
||||
>
|
||||
> can_seek;
|
||||
BOOST_STATIC_ASSERT(
|
||||
( can_seek::value ||
|
||||
(is_convertible<filter_mode, input>::value &&
|
||||
is_convertible<device_mode, input>::value) )
|
||||
);
|
||||
detail::skip(flt, dev, off, which, can_seek());
|
||||
}
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_SKIP_HPP_INCLUDED //------------------------//
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* 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/restrict.hpp
|
||||
* Date: Sun Jan 06 12:57:30 MST 2008
|
||||
* Copyright: 2008 CodeRage, LLC
|
||||
2004-2007 Jonathan Turkanis
|
||||
* Author: Jonathan Turkanis
|
||||
* Contact: turkanis at coderage dot com
|
||||
*
|
||||
* Defines the class template boost::iostreams::restriction and the
|
||||
* overloaded function template boost::iostreams::slice.
|
||||
*
|
||||
* This header is provided for platforms on which "restrict" is a keyword.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_RESTRICT_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_RESTRICT_HPP_INCLUDED
|
||||
|
||||
#include <boost/iostreams/detail/restrict_impl.hpp>
|
||||
#define BOOST_IOSTREAMS_RESTRICT slice
|
||||
#include <boost/iostreams/detail/restrict_impl.hpp>
|
||||
#undef BOOST_IOSTREAMS_RESTRICT
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_RESTRICT_HPP_INCLUDED
|
@ -1,232 +0,0 @@
|
||||
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
|
||||
// (C) Copyright 2005-2007 Jonathan Turkanis
|
||||
// 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_TEE_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_TEE_HPP_INCLUDED
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp> // BOOST_DEDUCE_TYPENAME.
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/detail/adapter/device_adapter.hpp>
|
||||
#include <boost/iostreams/detail/adapter/filter_adapter.hpp>
|
||||
#include <boost/iostreams/detail/call_traits.hpp>
|
||||
#include <boost/iostreams/detail/execute.hpp>
|
||||
#include <boost/iostreams/detail/functional.hpp> // call_close_all
|
||||
#include <boost/iostreams/operations.hpp>
|
||||
#include <boost/iostreams/pipeline.hpp>
|
||||
#include <boost/iostreams/traits.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
//
|
||||
// Template name: tee_filter.
|
||||
// Template parameters:
|
||||
// Device - A blocking Sink.
|
||||
//
|
||||
template<typename Device>
|
||||
class tee_filter : public detail::filter_adapter<Device> {
|
||||
public:
|
||||
typedef typename detail::param_type<Device>::type param_type;
|
||||
typedef typename char_type_of<Device>::type char_type;
|
||||
struct category
|
||||
: dual_use_filter_tag,
|
||||
multichar_tag,
|
||||
closable_tag,
|
||||
flushable_tag,
|
||||
localizable_tag,
|
||||
optimally_buffered_tag
|
||||
{ };
|
||||
|
||||
BOOST_STATIC_ASSERT(is_device<Device>::value);
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_convertible< // Using mode_of causes failures on VC6-7.0.
|
||||
BOOST_DEDUCED_TYPENAME iostreams::category_of<Device>::type, output
|
||||
>::value
|
||||
));
|
||||
|
||||
explicit tee_filter(param_type dev)
|
||||
: detail::filter_adapter<Device>(dev)
|
||||
{ }
|
||||
|
||||
template<typename Source>
|
||||
std::streamsize read(Source& src, char_type* s, std::streamsize n)
|
||||
{
|
||||
std::streamsize result = iostreams::read(src, s, n);
|
||||
if (result != -1) {
|
||||
std::streamsize result2 = iostreams::write(this->component(), s, result);
|
||||
(void) result2; // Suppress 'unused variable' warning.
|
||||
BOOST_ASSERT(result == result2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
std::streamsize write(Sink& snk, const char_type* s, std::streamsize n)
|
||||
{
|
||||
std::streamsize result = iostreams::write(snk, s, n);
|
||||
std::streamsize result2 = iostreams::write(this->component(), s, result);
|
||||
(void) result2; // Suppress 'unused variable' warning.
|
||||
BOOST_ASSERT(result == result2);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Next>
|
||||
void close(Next&, BOOST_IOS::openmode)
|
||||
{
|
||||
detail::close_all(this->component());
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
bool flush(Sink& snk)
|
||||
{
|
||||
bool r1 = iostreams::flush(snk);
|
||||
bool r2 = iostreams::flush(this->component());
|
||||
return r1 && r2;
|
||||
}
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(tee_filter, 1)
|
||||
|
||||
//
|
||||
// Template name: tee_device.
|
||||
// Template parameters:
|
||||
// Device - A blocking Device.
|
||||
// Sink - A blocking Sink.
|
||||
//
|
||||
template<typename Device, typename Sink>
|
||||
class tee_device {
|
||||
public:
|
||||
typedef typename detail::param_type<Device>::type device_param;
|
||||
typedef typename detail::param_type<Sink>::type sink_param;
|
||||
typedef typename detail::value_type<Device>::type device_value;
|
||||
typedef typename detail::value_type<Sink>::type sink_value;
|
||||
typedef typename char_type_of<Device>::type char_type;
|
||||
typedef typename
|
||||
mpl::if_<
|
||||
is_convertible<
|
||||
BOOST_DEDUCED_TYPENAME
|
||||
iostreams::category_of<Device>::type,
|
||||
output
|
||||
>,
|
||||
output,
|
||||
input
|
||||
>::type mode;
|
||||
BOOST_STATIC_ASSERT(is_device<Device>::value);
|
||||
BOOST_STATIC_ASSERT(is_device<Sink>::value);
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_same<
|
||||
char_type,
|
||||
BOOST_DEDUCED_TYPENAME char_type_of<Sink>::type
|
||||
>::value
|
||||
));
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_convertible<
|
||||
BOOST_DEDUCED_TYPENAME iostreams::category_of<Sink>::type,
|
||||
output
|
||||
>::value
|
||||
));
|
||||
struct category
|
||||
: mode,
|
||||
device_tag,
|
||||
closable_tag,
|
||||
flushable_tag,
|
||||
localizable_tag,
|
||||
optimally_buffered_tag
|
||||
{ };
|
||||
tee_device(device_param device, sink_param sink)
|
||||
: dev_(device), sink_(sink)
|
||||
{ }
|
||||
std::streamsize read(char_type* s, std::streamsize n)
|
||||
{
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_convertible<
|
||||
BOOST_DEDUCED_TYPENAME iostreams::category_of<Device>::type, input
|
||||
>::value
|
||||
));
|
||||
std::streamsize result1 = iostreams::read(dev_, s, n);
|
||||
if (result1 != -1) {
|
||||
std::streamsize result2 = iostreams::write(sink_, s, result1);
|
||||
(void) result1; // Suppress 'unused variable' warning.
|
||||
(void) result2;
|
||||
BOOST_ASSERT(result1 == result2);
|
||||
}
|
||||
return result1;
|
||||
}
|
||||
std::streamsize write(const char_type* s, std::streamsize n)
|
||||
{
|
||||
BOOST_STATIC_ASSERT((
|
||||
is_convertible<
|
||||
BOOST_DEDUCED_TYPENAME iostreams::category_of<Device>::type, output
|
||||
>::value
|
||||
));
|
||||
std::streamsize result1 = iostreams::write(dev_, s, n);
|
||||
std::streamsize result2 = iostreams::write(sink_, s, n);
|
||||
(void) result1; // Suppress 'unused variable' warning.
|
||||
(void) result2;
|
||||
BOOST_ASSERT(result1 == n && result2 == n);
|
||||
return n;
|
||||
}
|
||||
void close()
|
||||
{
|
||||
detail::execute_all( detail::call_close_all(dev_),
|
||||
detail::call_close_all(sink_) );
|
||||
}
|
||||
bool flush()
|
||||
{
|
||||
bool r1 = iostreams::flush(dev_);
|
||||
bool r2 = iostreams::flush(sink_);
|
||||
return r1 && r2;
|
||||
}
|
||||
template<typename Locale>
|
||||
void imbue(const Locale& loc)
|
||||
{
|
||||
iostreams::imbue(dev_, loc);
|
||||
iostreams::imbue(sink_, loc);
|
||||
}
|
||||
std::streamsize optimal_buffer_size() const
|
||||
{
|
||||
return (std::max) ( iostreams::optimal_buffer_size(dev_),
|
||||
iostreams::optimal_buffer_size(sink_) );
|
||||
}
|
||||
private:
|
||||
device_value dev_;
|
||||
sink_value sink_;
|
||||
};
|
||||
|
||||
template<typename Sink>
|
||||
tee_filter<Sink> tee(Sink& snk)
|
||||
{ return tee_filter<Sink>(snk); }
|
||||
|
||||
template<typename Sink>
|
||||
tee_filter<Sink> tee(const Sink& snk)
|
||||
{ return tee_filter<Sink>(snk); }
|
||||
|
||||
template<typename Device, typename Sink>
|
||||
tee_device<Device, Sink> tee(Device& dev, Sink& sink)
|
||||
{ return tee_device<Device, Sink>(dev, sink); }
|
||||
|
||||
template<typename Device, typename Sink>
|
||||
tee_device<Device, Sink> tee(const Device& dev, Sink& sink)
|
||||
{ return tee_device<Device, Sink>(dev, sink); }
|
||||
|
||||
template<typename Device, typename Sink>
|
||||
tee_device<Device, Sink> tee(Device& dev, const Sink& sink)
|
||||
{ return tee_device<Device, Sink>(dev, sink); }
|
||||
|
||||
template<typename Device, typename Sink>
|
||||
tee_device<Device, Sink> tee(const Device& dev, const Sink& sink)
|
||||
{ return tee_device<Device, Sink>(dev, sink); }
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_TEE_HPP_INCLUDED
|
40
boost/mpl/O1_size.hpp
Normal file
40
boost/mpl/O1_size.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
#ifndef BOOST_MPL_O1_SIZE_HPP_INCLUDED
|
||||
#define BOOST_MPL_O1_SIZE_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/O1_size_fwd.hpp>
|
||||
#include <boost/mpl/sequence_tag.hpp>
|
||||
#include <boost/mpl/aux_/O1_size_impl.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
// returns sequence size if it's an O(1) operation; otherwise returns -1
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
|
||||
>
|
||||
struct O1_size
|
||||
: O1_size_impl< typename sequence_tag<Sequence>::type >
|
||||
::template apply< Sequence >
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1, O1_size, (Sequence))
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC(1, O1_size)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_O1_SIZE_HPP_INCLUDED
|
24
boost/mpl/O1_size_fwd.hpp
Normal file
24
boost/mpl/O1_size_fwd.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
#ifndef BOOST_MPL_O1_SIZE_FWD_HPP_INCLUDED
|
||||
#define BOOST_MPL_O1_SIZE_FWD_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template< typename Tag > struct O1_size_impl;
|
||||
template< typename Sequence > struct O1_size;
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_O1_SIZE_FWD_HPP_INCLUDED
|
76
boost/mpl/advance.hpp
Normal file
76
boost/mpl/advance.hpp
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
#ifndef BOOST_MPL_ADVANCE_HPP_INCLUDED
|
||||
#define BOOST_MPL_ADVANCE_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/advance_fwd.hpp>
|
||||
#include <boost/mpl/less.hpp>
|
||||
#include <boost/mpl/negate.hpp>
|
||||
#include <boost/mpl/long.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/tag.hpp>
|
||||
#include <boost/mpl/apply_wrap.hpp>
|
||||
#include <boost/mpl/aux_/advance_forward.hpp>
|
||||
#include <boost/mpl/aux_/advance_backward.hpp>
|
||||
#include <boost/mpl/aux_/value_wknd.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/nttp_decl.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
// default implementation for forward/bidirectional iterators
|
||||
template< typename Tag >
|
||||
struct advance_impl
|
||||
{
|
||||
template< typename Iterator, typename N > struct apply
|
||||
{
|
||||
typedef typename less< N,long_<0> >::type backward_;
|
||||
typedef typename if_< backward_, negate<N>, N >::type offset_;
|
||||
|
||||
typedef typename if_<
|
||||
backward_
|
||||
, aux::advance_backward< BOOST_MPL_AUX_VALUE_WKND(offset_)::value >
|
||||
, aux::advance_forward< BOOST_MPL_AUX_VALUE_WKND(offset_)::value >
|
||||
>::type f_;
|
||||
|
||||
typedef typename apply_wrap1<f_,Iterator>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(Iterator)
|
||||
, typename BOOST_MPL_AUX_NA_PARAM(N)
|
||||
>
|
||||
struct advance
|
||||
: advance_impl< typename tag<Iterator>::type >
|
||||
::template apply<Iterator,N>
|
||||
{
|
||||
};
|
||||
|
||||
template<
|
||||
typename Iterator
|
||||
, BOOST_MPL_AUX_NTTP_DECL(long, N)
|
||||
>
|
||||
struct advance_c
|
||||
: advance_impl< typename tag<Iterator>::type >
|
||||
::template apply<Iterator,long_<N> >
|
||||
{
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC(2, advance)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_ADVANCE_HPP_INCLUDED
|
28
boost/mpl/advance_fwd.hpp
Normal file
28
boost/mpl/advance_fwd.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
#ifndef BOOST_MPL_ADVANCE_FWD_HPP_INCLUDED
|
||||
#define BOOST_MPL_ADVANCE_FWD_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/aux_/common_name_wknd.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
BOOST_MPL_AUX_COMMON_NAME_WKND(advance)
|
||||
|
||||
template< typename Tag > struct advance_impl;
|
||||
template< typename Iterator, typename N > struct advance;
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_ADVANCE_FWD_HPP_INCLUDED
|
87
boost/mpl/aux_/O1_size_impl.hpp
Normal file
87
boost/mpl/aux_/O1_size_impl.hpp
Normal file
@ -0,0 +1,87 @@
|
||||
|
||||
#ifndef BOOST_MPL_O1_SIZE_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_O1_SIZE_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/O1_size_fwd.hpp>
|
||||
#include <boost/mpl/long.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/aux_/has_size.hpp>
|
||||
#include <boost/mpl/aux_/config/forwarding.hpp>
|
||||
#include <boost/mpl/aux_/config/static_constant.hpp>
|
||||
#include <boost/mpl/aux_/config/msvc.hpp>
|
||||
#include <boost/mpl/aux_/config/workaround.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
// default implementation - returns 'Sequence::size' if sequence has a 'size'
|
||||
// member, and -1 otherwise; conrete sequences might override it by
|
||||
// specializing either the 'O1_size_impl' or the primary 'O1_size' template
|
||||
|
||||
# if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) \
|
||||
&& !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
|
||||
|
||||
namespace aux {
|
||||
template< typename Sequence > struct O1_size_impl
|
||||
: Sequence::size
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
template< typename Tag >
|
||||
struct O1_size_impl
|
||||
{
|
||||
template< typename Sequence > struct apply
|
||||
#if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
|
||||
: if_<
|
||||
aux::has_size<Sequence>
|
||||
, aux::O1_size_impl<Sequence>
|
||||
, long_<-1>
|
||||
>::type
|
||||
{
|
||||
#else
|
||||
{
|
||||
typedef typename if_<
|
||||
aux::has_size<Sequence>
|
||||
, aux::O1_size_impl<Sequence>
|
||||
, long_<-1>
|
||||
>::type type;
|
||||
|
||||
BOOST_STATIC_CONSTANT(long, value =
|
||||
(if_<
|
||||
aux::has_size<Sequence>
|
||||
, aux::O1_size_impl<Sequence>
|
||||
, long_<-1>
|
||||
>::type::value)
|
||||
);
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
# else // BOOST_MSVC
|
||||
|
||||
template< typename Tag >
|
||||
struct O1_size_impl
|
||||
{
|
||||
template< typename Sequence > struct apply
|
||||
: long_<-1>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
# endif
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_O1_SIZE_IMPL_HPP_INCLUDED
|
128
boost/mpl/aux_/advance_backward.hpp
Normal file
128
boost/mpl/aux_/advance_backward.hpp
Normal file
@ -0,0 +1,128 @@
|
||||
|
||||
#if !defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
///// header body
|
||||
|
||||
#ifndef BOOST_MPL_AUX778076_ADVANCE_BACKWARD_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX778076_ADVANCE_BACKWARD_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#if !defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
# include <boost/mpl/prior.hpp>
|
||||
# include <boost/mpl/apply_wrap.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/aux_/config/use_preprocessed.hpp>
|
||||
|
||||
#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
|
||||
&& !defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
|
||||
# define BOOST_MPL_PREPROCESSED_HEADER advance_backward.hpp
|
||||
# include <boost/mpl/aux_/include_preprocessed.hpp>
|
||||
|
||||
#else
|
||||
|
||||
# include <boost/mpl/limits/unrolling.hpp>
|
||||
# include <boost/mpl/aux_/nttp_decl.hpp>
|
||||
# include <boost/mpl/aux_/config/eti.hpp>
|
||||
|
||||
# include <boost/preprocessor/iterate.hpp>
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/preprocessor/inc.hpp>
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
|
||||
// forward declaration
|
||||
template< BOOST_MPL_AUX_NTTP_DECL(long, N) > struct advance_backward;
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 \
|
||||
(3,(0, BOOST_MPL_LIMIT_UNROLLING, <boost/mpl/aux_/advance_backward.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
// implementation for N that exceeds BOOST_MPL_LIMIT_UNROLLING
|
||||
template< BOOST_MPL_AUX_NTTP_DECL(long, N) >
|
||||
struct advance_backward
|
||||
{
|
||||
template< typename Iterator > struct apply
|
||||
{
|
||||
typedef typename apply_wrap1<
|
||||
advance_backward<BOOST_MPL_LIMIT_UNROLLING>
|
||||
, Iterator
|
||||
>::type chunk_result_;
|
||||
|
||||
typedef typename apply_wrap1<
|
||||
advance_backward<(
|
||||
(N - BOOST_MPL_LIMIT_UNROLLING) < 0
|
||||
? 0
|
||||
: N - BOOST_MPL_LIMIT_UNROLLING
|
||||
)>
|
||||
, chunk_result_
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
|
||||
#endif // BOOST_MPL_AUX778076_ADVANCE_BACKWARD_HPP_INCLUDED
|
||||
|
||||
///// iteration, depth == 1
|
||||
|
||||
// For gcc 4.4 compatability, we must include the
|
||||
// BOOST_PP_ITERATION_DEPTH test inside an #else clause.
|
||||
#else // BOOST_PP_IS_ITERATING
|
||||
#if BOOST_PP_ITERATION_DEPTH() == 1
|
||||
#define i_ BOOST_PP_FRAME_ITERATION(1)
|
||||
|
||||
template<>
|
||||
struct advance_backward< BOOST_PP_FRAME_ITERATION(1) >
|
||||
{
|
||||
template< typename Iterator > struct apply
|
||||
{
|
||||
typedef Iterator iter0;
|
||||
|
||||
#if i_ > 0
|
||||
# define BOOST_PP_ITERATION_PARAMS_2 \
|
||||
(3,(1, BOOST_PP_FRAME_ITERATION(1), <boost/mpl/aux_/advance_backward.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
#endif
|
||||
|
||||
typedef BOOST_PP_CAT(iter,BOOST_PP_FRAME_ITERATION(1)) type;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)
|
||||
/// ETI workaround
|
||||
template<> struct apply<int>
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
#undef i_
|
||||
|
||||
///// iteration, depth == 2
|
||||
|
||||
#elif BOOST_PP_ITERATION_DEPTH() == 2
|
||||
|
||||
# define AUX778076_ITER_0 BOOST_PP_CAT(iter,BOOST_PP_DEC(BOOST_PP_FRAME_ITERATION(2)))
|
||||
# define AUX778076_ITER_1 BOOST_PP_CAT(iter,BOOST_PP_FRAME_ITERATION(2))
|
||||
|
||||
typedef typename prior<AUX778076_ITER_0>::type AUX778076_ITER_1;
|
||||
|
||||
# undef AUX778076_ITER_1
|
||||
# undef AUX778076_ITER_0
|
||||
|
||||
#endif // BOOST_PP_ITERATION_DEPTH()
|
||||
#endif // BOOST_PP_IS_ITERATING
|
127
boost/mpl/aux_/advance_forward.hpp
Normal file
127
boost/mpl/aux_/advance_forward.hpp
Normal file
@ -0,0 +1,127 @@
|
||||
|
||||
#if !defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
///// header body
|
||||
|
||||
#ifndef BOOST_MPL_AUX_ADVANCE_FORWARD_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_ADVANCE_FORWARD_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#if !defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
# include <boost/mpl/next.hpp>
|
||||
# include <boost/mpl/apply_wrap.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/aux_/config/use_preprocessed.hpp>
|
||||
|
||||
#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
|
||||
&& !defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
|
||||
# define BOOST_MPL_PREPROCESSED_HEADER advance_forward.hpp
|
||||
# include <boost/mpl/aux_/include_preprocessed.hpp>
|
||||
|
||||
#else
|
||||
|
||||
# include <boost/mpl/limits/unrolling.hpp>
|
||||
# include <boost/mpl/aux_/nttp_decl.hpp>
|
||||
# include <boost/mpl/aux_/config/eti.hpp>
|
||||
|
||||
# include <boost/preprocessor/iterate.hpp>
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/preprocessor/inc.hpp>
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
|
||||
// forward declaration
|
||||
template< BOOST_MPL_AUX_NTTP_DECL(long, N) > struct advance_forward;
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 \
|
||||
(3,(0, BOOST_MPL_LIMIT_UNROLLING, <boost/mpl/aux_/advance_forward.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
// implementation for N that exceeds BOOST_MPL_LIMIT_UNROLLING
|
||||
template< BOOST_MPL_AUX_NTTP_DECL(long, N) >
|
||||
struct advance_forward
|
||||
{
|
||||
template< typename Iterator > struct apply
|
||||
{
|
||||
typedef typename apply_wrap1<
|
||||
advance_forward<BOOST_MPL_LIMIT_UNROLLING>
|
||||
, Iterator
|
||||
>::type chunk_result_;
|
||||
|
||||
typedef typename apply_wrap1<
|
||||
advance_forward<(
|
||||
(N - BOOST_MPL_LIMIT_UNROLLING) < 0
|
||||
? 0
|
||||
: N - BOOST_MPL_LIMIT_UNROLLING
|
||||
)>
|
||||
, chunk_result_
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
|
||||
#endif // BOOST_MPL_AUX_ADVANCE_FORWARD_HPP_INCLUDED
|
||||
|
||||
///// iteration, depth == 1
|
||||
|
||||
// For gcc 4.4 compatability, we must include the
|
||||
// BOOST_PP_ITERATION_DEPTH test inside an #else clause.
|
||||
#else // BOOST_PP_IS_ITERATING
|
||||
#if BOOST_PP_ITERATION_DEPTH() == 1
|
||||
#define i_ BOOST_PP_FRAME_ITERATION(1)
|
||||
|
||||
template<>
|
||||
struct advance_forward< BOOST_PP_FRAME_ITERATION(1) >
|
||||
{
|
||||
template< typename Iterator > struct apply
|
||||
{
|
||||
typedef Iterator iter0;
|
||||
|
||||
#if i_ > 0
|
||||
# define BOOST_PP_ITERATION_PARAMS_2 \
|
||||
(3,(1, i_, <boost/mpl/aux_/advance_forward.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
#endif
|
||||
typedef BOOST_PP_CAT(iter,i_) type;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)
|
||||
/// ETI workaround
|
||||
template<> struct apply<int>
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
#undef i_
|
||||
|
||||
///// iteration, depth == 2
|
||||
|
||||
#elif BOOST_PP_ITERATION_DEPTH() == 2
|
||||
|
||||
# define AUX778076_ITER_0 BOOST_PP_CAT(iter,BOOST_PP_DEC(BOOST_PP_FRAME_ITERATION(2)))
|
||||
# define AUX778076_ITER_1 BOOST_PP_CAT(iter,BOOST_PP_FRAME_ITERATION(2))
|
||||
|
||||
typedef typename next<AUX778076_ITER_0>::type AUX778076_ITER_1;
|
||||
|
||||
# undef AUX778076_ITER_1
|
||||
# undef AUX778076_ITER_0
|
||||
|
||||
#endif // BOOST_PP_ITERATION_DEPTH()
|
||||
#endif // BOOST_PP_IS_ITERATING
|
101
boost/mpl/aux_/begin_end_impl.hpp
Normal file
101
boost/mpl/aux_/begin_end_impl.hpp
Normal file
@ -0,0 +1,101 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/begin_end_fwd.hpp>
|
||||
#include <boost/mpl/sequence_tag_fwd.hpp>
|
||||
#include <boost/mpl/void.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/aux_/has_begin.hpp>
|
||||
#include <boost/mpl/aux_/na.hpp>
|
||||
#include <boost/mpl/aux_/traits_lambda_spec.hpp>
|
||||
#include <boost/mpl/aux_/config/eti.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
|
||||
namespace aux {
|
||||
|
||||
template< typename Sequence >
|
||||
struct begin_type
|
||||
{
|
||||
typedef typename Sequence::begin type;
|
||||
};
|
||||
template< typename Sequence >
|
||||
struct end_type
|
||||
{
|
||||
typedef typename Sequence::end type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// default implementation; conrete sequences might override it by
|
||||
// specializing either the 'begin_impl/end_impl' or the primary
|
||||
// 'begin/end' templates
|
||||
|
||||
template< typename Tag >
|
||||
struct begin_impl
|
||||
{
|
||||
template< typename Sequence > struct apply
|
||||
{
|
||||
typedef typename eval_if<aux::has_begin<Sequence, true_>,
|
||||
aux::begin_type<Sequence>, void_>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template< typename Tag >
|
||||
struct end_impl
|
||||
{
|
||||
template< typename Sequence > struct apply
|
||||
{
|
||||
typedef typename eval_if<aux::has_begin<Sequence, true_>,
|
||||
aux::end_type<Sequence>, void_>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
// specialize 'begin_trait/end_trait' for two pre-defined tags
|
||||
|
||||
# define AUX778076_IMPL_SPEC(name, tag, result) \
|
||||
template<> \
|
||||
struct name##_impl<tag> \
|
||||
{ \
|
||||
template< typename Sequence > struct apply \
|
||||
{ \
|
||||
typedef result type; \
|
||||
}; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
// a sequence with nested 'begin/end' typedefs; just query them
|
||||
AUX778076_IMPL_SPEC(begin, nested_begin_end_tag, typename Sequence::begin)
|
||||
AUX778076_IMPL_SPEC(end, nested_begin_end_tag, typename Sequence::end)
|
||||
|
||||
// if a type 'T' does not contain 'begin/end' or 'tag' members
|
||||
// and doesn't specialize either 'begin/end' or 'begin_impl/end_impl'
|
||||
// templates, then we end up here
|
||||
AUX778076_IMPL_SPEC(begin, non_sequence_tag, void_)
|
||||
AUX778076_IMPL_SPEC(end, non_sequence_tag, void_)
|
||||
AUX778076_IMPL_SPEC(begin, na, void_)
|
||||
AUX778076_IMPL_SPEC(end, na, void_)
|
||||
|
||||
# undef AUX778076_IMPL_SPEC
|
||||
|
||||
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(1,begin_impl)
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(1,end_impl)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|
35
boost/mpl/aux_/clear_impl.hpp
Normal file
35
boost/mpl/aux_/clear_impl.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_CLEAR_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_CLEAR_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/clear_fwd.hpp>
|
||||
#include <boost/mpl/aux_/traits_lambda_spec.hpp>
|
||||
#include <boost/mpl/aux_/config/eti.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
// no default implementation; the definition is needed to make MSVC happy
|
||||
|
||||
template< typename Tag >
|
||||
struct clear_impl
|
||||
{
|
||||
template< typename Sequence > struct apply;
|
||||
};
|
||||
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1, clear_impl)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_CLEAR_IMPL_HPP_INCLUDED
|
43
boost/mpl/aux_/empty_impl.hpp
Normal file
43
boost/mpl/aux_/empty_impl.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_EMPTY_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_EMPTY_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/empty_fwd.hpp>
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/aux_/traits_lambda_spec.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
// default implementation; conrete sequences might override it by
|
||||
// specializing either the 'empty_impl' or the primary 'empty' template
|
||||
|
||||
template< typename Tag >
|
||||
struct empty_impl
|
||||
{
|
||||
template< typename Sequence > struct apply
|
||||
: is_same<
|
||||
typename begin<Sequence>::type
|
||||
, typename end<Sequence>::type
|
||||
>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1,empty_impl)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_EMPTY_IMPL_HPP_INCLUDED
|
31
boost/mpl/aux_/find_if_pred.hpp
Normal file
31
boost/mpl/aux_/find_if_pred.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_FIND_IF_PRED_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_FIND_IF_PRED_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
// Copyright Eric Friedman 2002
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
#include <boost/mpl/aux_/iter_apply.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
|
||||
template< typename Predicate >
|
||||
struct find_if_pred
|
||||
{
|
||||
template< typename Iterator >
|
||||
struct apply
|
||||
{
|
||||
typedef not_< aux::iter_apply1<Predicate,Iterator> > type;
|
||||
};
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_FIND_IF_PRED_HPP_INCLUDED
|
43
boost/mpl/aux_/fold_impl.hpp
Normal file
43
boost/mpl/aux_/fold_impl.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_FOLD_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_FOLD_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#if !defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
# include <boost/mpl/next_prior.hpp>
|
||||
# include <boost/mpl/apply.hpp>
|
||||
# include <boost/mpl/deref.hpp>
|
||||
# include <boost/mpl/aux_/config/ctps.hpp>
|
||||
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
# include <boost/mpl/if.hpp>
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/aux_/config/use_preprocessed.hpp>
|
||||
|
||||
#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
|
||||
&& !defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
|
||||
# define BOOST_MPL_PREPROCESSED_HEADER fold_impl.hpp
|
||||
# include <boost/mpl/aux_/include_preprocessed.hpp>
|
||||
|
||||
#else
|
||||
|
||||
# define AUX778076_FOLD_IMPL_OP(iter) typename deref<iter>::type
|
||||
# define AUX778076_FOLD_IMPL_NAME_PREFIX fold
|
||||
# include <boost/mpl/aux_/fold_impl_body.hpp>
|
||||
|
||||
#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
|
||||
#endif // BOOST_MPL_AUX_FOLD_IMPL_HPP_INCLUDED
|
365
boost/mpl/aux_/fold_impl_body.hpp
Normal file
365
boost/mpl/aux_/fold_impl_body.hpp
Normal file
@ -0,0 +1,365 @@
|
||||
|
||||
// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
|
||||
|
||||
#if !defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
# include <boost/mpl/limits/unrolling.hpp>
|
||||
# include <boost/mpl/aux_/preprocessor/repeat.hpp>
|
||||
# include <boost/mpl/aux_/config/workaround.hpp>
|
||||
# include <boost/mpl/aux_/config/ctps.hpp>
|
||||
# include <boost/mpl/aux_/nttp_decl.hpp>
|
||||
# include <boost/mpl/aux_/config/eti.hpp>
|
||||
|
||||
# include <boost/preprocessor/iterate.hpp>
|
||||
# include <boost/preprocessor/dec.hpp>
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
|
||||
// local macros, #undef-ined at the end of the header
|
||||
|
||||
# define AUX778076_ITER_FOLD_STEP(unused, i, unused2) \
|
||||
typedef typename apply2< \
|
||||
ForwardOp \
|
||||
, BOOST_PP_CAT(state,i) \
|
||||
, AUX778076_FOLD_IMPL_OP(BOOST_PP_CAT(iter,i)) \
|
||||
>::type BOOST_PP_CAT(state,BOOST_PP_INC(i)); \
|
||||
typedef typename mpl::next<BOOST_PP_CAT(iter,i)>::type \
|
||||
BOOST_PP_CAT(iter,BOOST_PP_INC(i)); \
|
||||
/**/
|
||||
|
||||
# define AUX778076_FOLD_IMPL_NAME \
|
||||
BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_impl) \
|
||||
/**/
|
||||
|
||||
# define AUX778076_FOLD_CHUNK_NAME \
|
||||
BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_chunk) \
|
||||
/**/
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
|
||||
/// forward declaration
|
||||
template<
|
||||
BOOST_MPL_AUX_NTTP_DECL(int, N)
|
||||
, typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME;
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
# if !BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600)
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 \
|
||||
(3,(0, BOOST_MPL_LIMIT_UNROLLING, <boost/mpl/aux_/fold_impl_body.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
// implementation for N that exceeds BOOST_MPL_LIMIT_UNROLLING
|
||||
template<
|
||||
BOOST_MPL_AUX_NTTP_DECL(int, N)
|
||||
, typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME
|
||||
{
|
||||
typedef AUX778076_FOLD_IMPL_NAME<
|
||||
BOOST_MPL_LIMIT_UNROLLING
|
||||
, First
|
||||
, Last
|
||||
, State
|
||||
, ForwardOp
|
||||
> chunk_;
|
||||
|
||||
typedef AUX778076_FOLD_IMPL_NAME<
|
||||
( (N - BOOST_MPL_LIMIT_UNROLLING) < 0 ? 0 : N - BOOST_MPL_LIMIT_UNROLLING )
|
||||
, typename chunk_::iterator
|
||||
, Last
|
||||
, typename chunk_::state
|
||||
, ForwardOp
|
||||
> res_;
|
||||
|
||||
typedef typename res_::state state;
|
||||
typedef typename res_::iterator iterator;
|
||||
};
|
||||
|
||||
// fallback implementation for sequences of unknown size
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME<-1,First,Last,State,ForwardOp>
|
||||
: AUX778076_FOLD_IMPL_NAME<
|
||||
-1
|
||||
, typename mpl::next<First>::type
|
||||
, Last
|
||||
, typename apply2<ForwardOp,State,AUX778076_FOLD_IMPL_OP(First)>::type
|
||||
, ForwardOp
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
template<
|
||||
typename Last
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME<-1,Last,Last,State,ForwardOp>
|
||||
{
|
||||
typedef State state;
|
||||
typedef Last iterator;
|
||||
};
|
||||
|
||||
# else // BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600)
|
||||
|
||||
// Borland have some serious problems with the unrolled version, so
|
||||
// we always use a basic implementation
|
||||
template<
|
||||
BOOST_MPL_AUX_NTTP_DECL(int, N)
|
||||
, typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME
|
||||
{
|
||||
typedef AUX778076_FOLD_IMPL_NAME<
|
||||
-1
|
||||
, typename mpl::next<First>::type
|
||||
, Last
|
||||
, typename apply2<ForwardOp,State,AUX778076_FOLD_IMPL_OP(First)>::type
|
||||
, ForwardOp
|
||||
> res_;
|
||||
|
||||
typedef typename res_::state state;
|
||||
typedef typename res_::iterator iterator;
|
||||
typedef state type;
|
||||
};
|
||||
|
||||
template<
|
||||
BOOST_MPL_AUX_NTTP_DECL(int, N)
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME<N,Last,Last,State,ForwardOp >
|
||||
{
|
||||
typedef State state;
|
||||
typedef Last iterator;
|
||||
typedef state type;
|
||||
};
|
||||
|
||||
# endif // BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600)
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
template< BOOST_MPL_AUX_NTTP_DECL(int, N) >
|
||||
struct AUX778076_FOLD_CHUNK_NAME;
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 \
|
||||
(3,(0, BOOST_MPL_LIMIT_UNROLLING, <boost/mpl/aux_/fold_impl_body.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
// implementation for N that exceeds BOOST_MPL_LIMIT_UNROLLING
|
||||
template< BOOST_MPL_AUX_NTTP_DECL(int, N) >
|
||||
struct AUX778076_FOLD_CHUNK_NAME
|
||||
{
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef AUX778076_FOLD_IMPL_NAME<
|
||||
BOOST_MPL_LIMIT_UNROLLING
|
||||
, First
|
||||
, Last
|
||||
, State
|
||||
, ForwardOp
|
||||
> chunk_;
|
||||
|
||||
typedef AUX778076_FOLD_IMPL_NAME<
|
||||
( (N - BOOST_MPL_LIMIT_UNROLLING) < 0 ? 0 : N - BOOST_MPL_LIMIT_UNROLLING )
|
||||
, typename chunk_::iterator
|
||||
, Last
|
||||
, typename chunk_::state
|
||||
, ForwardOp
|
||||
> res_;
|
||||
|
||||
typedef typename res_::state state;
|
||||
typedef typename res_::iterator iterator;
|
||||
};
|
||||
};
|
||||
|
||||
// fallback implementation for sequences of unknown size
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_step);
|
||||
|
||||
template<
|
||||
typename Last
|
||||
, typename State
|
||||
>
|
||||
struct BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_null_step)
|
||||
{
|
||||
typedef Last iterator;
|
||||
typedef State state;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct AUX778076_FOLD_CHUNK_NAME<-1>
|
||||
{
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef typename if_<
|
||||
typename is_same<First,Last>::type
|
||||
, BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_null_step)<Last,State>
|
||||
, BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_step)<First,Last,State,ForwardOp>
|
||||
>::type res_;
|
||||
|
||||
typedef typename res_::state state;
|
||||
typedef typename res_::iterator iterator;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)
|
||||
/// ETI workaround
|
||||
template<> struct result_<int,int,int,int>
|
||||
{
|
||||
typedef int state;
|
||||
typedef int iterator;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_step)
|
||||
{
|
||||
// can't inherit here - it breaks MSVC 7.0
|
||||
typedef AUX778076_FOLD_CHUNK_NAME<-1>::template result_<
|
||||
typename mpl::next<First>::type
|
||||
, Last
|
||||
, typename apply2<ForwardOp,State,AUX778076_FOLD_IMPL_OP(First)>::type
|
||||
, ForwardOp
|
||||
> chunk_;
|
||||
|
||||
typedef typename chunk_::state state;
|
||||
typedef typename chunk_::iterator iterator;
|
||||
};
|
||||
|
||||
template<
|
||||
BOOST_MPL_AUX_NTTP_DECL(int, N)
|
||||
, typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME
|
||||
: AUX778076_FOLD_CHUNK_NAME<N>
|
||||
::template result_<First,Last,State,ForwardOp>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
}}}
|
||||
|
||||
# undef AUX778076_FOLD_IMPL_NAME
|
||||
# undef AUX778076_FOLD_CHUNK_NAME
|
||||
# undef AUX778076_ITER_FOLD_STEP
|
||||
|
||||
#undef AUX778076_FOLD_IMPL_OP
|
||||
#undef AUX778076_FOLD_IMPL_NAME_PREFIX
|
||||
|
||||
///// iteration
|
||||
|
||||
#else
|
||||
|
||||
# define n_ BOOST_PP_FRAME_ITERATION(1)
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME<n_,First,Last,State,ForwardOp>
|
||||
{
|
||||
typedef First iter0;
|
||||
typedef State state0;
|
||||
|
||||
BOOST_MPL_PP_REPEAT(n_, AUX778076_ITER_FOLD_STEP, unused)
|
||||
|
||||
typedef BOOST_PP_CAT(state,n_) state;
|
||||
typedef BOOST_PP_CAT(iter,n_) iterator;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template<> struct AUX778076_FOLD_CHUNK_NAME<n_>
|
||||
{
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef First iter0;
|
||||
typedef State state0;
|
||||
|
||||
BOOST_MPL_PP_REPEAT(n_, AUX778076_ITER_FOLD_STEP, unused)
|
||||
|
||||
typedef BOOST_PP_CAT(state,n_) state;
|
||||
typedef BOOST_PP_CAT(iter,n_) iterator;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)
|
||||
/// ETI workaround
|
||||
template<> struct result_<int,int,int,int>
|
||||
{
|
||||
typedef int state;
|
||||
typedef int iterator;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
# undef n_
|
||||
|
||||
#endif // BOOST_PP_IS_ITERATING
|
41
boost/mpl/aux_/front_impl.hpp
Normal file
41
boost/mpl/aux_/front_impl.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_FRONT_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_FRONT_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/front_fwd.hpp>
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/aux_/traits_lambda_spec.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
// default implementation; conrete sequences might override it by
|
||||
// specializing either the 'front_impl' or the primary 'front' template
|
||||
|
||||
template< typename Tag >
|
||||
struct front_impl
|
||||
{
|
||||
template< typename Sequence > struct apply
|
||||
{
|
||||
typedef typename begin<Sequence>::type iter_;
|
||||
typedef typename deref<iter_>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1,front_impl)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_FRONT_IMPL_HPP_INCLUDED
|
23
boost/mpl/aux_/has_begin.hpp
Normal file
23
boost/mpl/aux_/has_begin.hpp
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_HAS_BEGIN_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_HAS_BEGIN_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2002-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_begin, begin, true)
|
||||
}}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_HAS_BEGIN_HPP_INCLUDED
|
23
boost/mpl/aux_/has_size.hpp
Normal file
23
boost/mpl/aux_/has_size.hpp
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_HAS_SIZE_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_HAS_SIZE_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2002-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(size)
|
||||
}}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_HAS_SIZE_HPP_INCLUDED
|
68
boost/mpl/aux_/insert_impl.hpp
Normal file
68
boost/mpl/aux_/insert_impl.hpp
Normal file
@ -0,0 +1,68 @@
|
||||
|
||||
#ifndef BOOST_MPL_INSERT_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_INSERT_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/reverse_fold.hpp>
|
||||
#include <boost/mpl/iterator_range.hpp>
|
||||
#include <boost/mpl/clear.hpp>
|
||||
#include <boost/mpl/push_front.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/traits_lambda_spec.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
// default implementation; conrete sequences might override it by
|
||||
// specializing either the 'insert_impl' or the primary 'insert' template
|
||||
|
||||
template< typename Tag >
|
||||
struct insert_impl
|
||||
{
|
||||
template<
|
||||
typename Sequence
|
||||
, typename Pos
|
||||
, typename T
|
||||
>
|
||||
struct apply
|
||||
{
|
||||
typedef iterator_range<
|
||||
typename begin<Sequence>::type
|
||||
, Pos
|
||||
> first_half_;
|
||||
|
||||
typedef iterator_range<
|
||||
Pos
|
||||
, typename end<Sequence>::type
|
||||
> second_half_;
|
||||
|
||||
typedef typename reverse_fold<
|
||||
second_half_
|
||||
, typename clear<Sequence>::type
|
||||
, push_front<_,_>
|
||||
>::type half_sequence_;
|
||||
|
||||
typedef typename reverse_fold<
|
||||
first_half_
|
||||
, typename push_front<half_sequence_,T>::type
|
||||
, push_front<_,_>
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(3,insert_impl)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_INSERT_IMPL_HPP_INCLUDED
|
80
boost/mpl/aux_/insert_range_impl.hpp
Normal file
80
boost/mpl/aux_/insert_range_impl.hpp
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/mpl/fold.hpp>
|
||||
#include <boost/mpl/insert.hpp>
|
||||
#include <boost/mpl/clear.hpp>
|
||||
#include <boost/mpl/joint_view.hpp>
|
||||
#include <boost/mpl/iterator_range.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/iter_push_front.hpp>
|
||||
#include <boost/mpl/aux_/traits_lambda_spec.hpp>
|
||||
#include <boost/mpl/aux_/config/forwarding.hpp>
|
||||
|
||||
#include <boost/type_traits/same_traits.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
// default implementation; conrete sequences might override it by
|
||||
// specializing either the 'insert_range_impl' or the primary
|
||||
// 'insert_range' template
|
||||
|
||||
|
||||
template< typename Tag >
|
||||
struct insert_range_impl
|
||||
{
|
||||
template<
|
||||
typename Sequence
|
||||
, typename Pos
|
||||
, typename Range
|
||||
>
|
||||
struct apply
|
||||
#if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
|
||||
: reverse_fold<
|
||||
joint_view<
|
||||
iterator_range<typename begin<Sequence>::type,Pos>
|
||||
, joint_view<
|
||||
Range
|
||||
, iterator_range<Pos,typename end<Sequence>::type>
|
||||
>
|
||||
>
|
||||
, typename clear<Sequence>::type
|
||||
, insert<_1, begin<_1>, _2>
|
||||
>
|
||||
{
|
||||
#else
|
||||
{
|
||||
typedef typename reverse_fold<
|
||||
joint_view<
|
||||
iterator_range<typename begin<Sequence>::type,Pos>
|
||||
, joint_view<
|
||||
Range
|
||||
, iterator_range<Pos,typename end<Sequence>::type>
|
||||
>
|
||||
>
|
||||
, typename clear<Sequence>::type
|
||||
, insert<_1, begin<_1>, _2>
|
||||
>::type type;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(3,insert_range_impl)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED
|
159
boost/mpl/aux_/inserter_algorithm.hpp
Normal file
159
boost/mpl/aux_/inserter_algorithm.hpp
Normal file
@ -0,0 +1,159 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_INSERTER_ALGORITHM_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_INSERTER_ALGORITHM_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2003-2004
|
||||
// Copyright David Abrahams 2003-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/back_inserter.hpp>
|
||||
#include <boost/mpl/front_inserter.hpp>
|
||||
#include <boost/mpl/push_back.hpp>
|
||||
#include <boost/mpl/push_front.hpp>
|
||||
#include <boost/mpl/back_inserter.hpp>
|
||||
#include <boost/mpl/front_inserter.hpp>
|
||||
#include <boost/mpl/clear.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/aux_/na.hpp>
|
||||
#include <boost/mpl/aux_/common_name_wknd.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/preprocessor/params.hpp>
|
||||
#include <boost/mpl/aux_/preprocessor/default_params.hpp>
|
||||
#include <boost/mpl/aux_/config/ctps.hpp>
|
||||
|
||||
#include <boost/preprocessor/arithmetic/dec.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
# define BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(arity, name) \
|
||||
BOOST_MPL_AUX_COMMON_NAME_WKND(name) \
|
||||
template< \
|
||||
BOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \
|
||||
> \
|
||||
struct name \
|
||||
: aux::name##_impl<BOOST_MPL_PP_PARAMS(arity, P)> \
|
||||
{ \
|
||||
}; \
|
||||
\
|
||||
template< \
|
||||
BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), typename P) \
|
||||
> \
|
||||
struct name< BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P),na > \
|
||||
: if_< has_push_back< typename clear<P1>::type> \
|
||||
, aux::name##_impl< \
|
||||
BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
|
||||
, back_inserter< typename clear<P1>::type > \
|
||||
> \
|
||||
, aux::reverse_##name##_impl< \
|
||||
BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
|
||||
, front_inserter< typename clear<P1>::type > \
|
||||
> \
|
||||
>::type \
|
||||
{ \
|
||||
}; \
|
||||
\
|
||||
template< \
|
||||
BOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \
|
||||
> \
|
||||
struct reverse_##name \
|
||||
: aux::reverse_##name##_impl<BOOST_MPL_PP_PARAMS(arity, P)> \
|
||||
{ \
|
||||
}; \
|
||||
\
|
||||
template< \
|
||||
BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), typename P) \
|
||||
> \
|
||||
struct reverse_##name< BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P),na > \
|
||||
: if_< has_push_back<P1> \
|
||||
, aux::reverse_##name##_impl< \
|
||||
BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
|
||||
, back_inserter< typename clear<P1>::type > \
|
||||
> \
|
||||
, aux::name##_impl< \
|
||||
BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
|
||||
, front_inserter< typename clear<P1>::type > \
|
||||
> \
|
||||
>::type \
|
||||
{ \
|
||||
}; \
|
||||
BOOST_MPL_AUX_NA_SPEC(arity, name) \
|
||||
BOOST_MPL_AUX_NA_SPEC(arity, reverse_##name) \
|
||||
/**/
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(arity, name) \
|
||||
BOOST_MPL_AUX_COMMON_NAME_WKND(name) \
|
||||
template< \
|
||||
BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), typename P) \
|
||||
> \
|
||||
struct def_##name##_impl \
|
||||
: if_< has_push_back<P1> \
|
||||
, aux::name##_impl< \
|
||||
BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
|
||||
, back_inserter< typename clear<P1>::type > \
|
||||
> \
|
||||
, aux::reverse_##name##_impl< \
|
||||
BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
|
||||
, front_inserter< typename clear<P1>::type > \
|
||||
> \
|
||||
>::type \
|
||||
{ \
|
||||
}; \
|
||||
\
|
||||
template< \
|
||||
BOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \
|
||||
> \
|
||||
struct name \
|
||||
{ \
|
||||
typedef typename eval_if< \
|
||||
is_na<BOOST_PP_CAT(P, arity)> \
|
||||
, def_##name##_impl<BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P)> \
|
||||
, aux::name##_impl<BOOST_MPL_PP_PARAMS(arity, P)> \
|
||||
>::type type; \
|
||||
}; \
|
||||
\
|
||||
template< \
|
||||
BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), typename P) \
|
||||
> \
|
||||
struct def_reverse_##name##_impl \
|
||||
: if_< has_push_back<P1> \
|
||||
, aux::reverse_##name##_impl< \
|
||||
BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
|
||||
, back_inserter< typename clear<P1>::type > \
|
||||
> \
|
||||
, aux::name##_impl< \
|
||||
BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \
|
||||
, front_inserter< typename clear<P1>::type > \
|
||||
> \
|
||||
>::type \
|
||||
{ \
|
||||
}; \
|
||||
template< \
|
||||
BOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \
|
||||
> \
|
||||
struct reverse_##name \
|
||||
{ \
|
||||
typedef typename eval_if< \
|
||||
is_na<BOOST_PP_CAT(P, arity)> \
|
||||
, def_reverse_##name##_impl<BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P)> \
|
||||
, aux::reverse_##name##_impl<BOOST_MPL_PP_PARAMS(arity, P)> \
|
||||
>::type type; \
|
||||
}; \
|
||||
BOOST_MPL_AUX_NA_SPEC(arity, name) \
|
||||
BOOST_MPL_AUX_NA_SPEC(arity, reverse_##name) \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#endif // BOOST_MPL_AUX_INSERTER_ALGORITHM_HPP_INCLUDED
|
47
boost/mpl/aux_/iter_apply.hpp
Normal file
47
boost/mpl/aux_/iter_apply.hpp
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
#ifndef BOOST_MPL_ITER_APPLY_HPP_INCLUDED
|
||||
#define BOOST_MPL_ITER_APPLY_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2002-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
|
||||
template<
|
||||
typename F
|
||||
, typename Iterator
|
||||
>
|
||||
struct iter_apply1
|
||||
: apply1< F,typename deref<Iterator>::type >
|
||||
{
|
||||
};
|
||||
|
||||
template<
|
||||
typename F
|
||||
, typename Iterator1
|
||||
, typename Iterator2
|
||||
>
|
||||
struct iter_apply2
|
||||
: apply2<
|
||||
F
|
||||
, typename deref<Iterator1>::type
|
||||
, typename deref<Iterator2>::type
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif // BOOST_MPL_ITER_APPLY_HPP_INCLUDED
|
210
boost/mpl/aux_/iter_fold_if_impl.hpp
Normal file
210
boost/mpl/aux_/iter_fold_if_impl.hpp
Normal file
@ -0,0 +1,210 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_ITER_FOLD_IF_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_ITER_FOLD_IF_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2001-2004
|
||||
// Copyright David Abrahams 2001-2002
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#if !defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
# include <boost/mpl/identity.hpp>
|
||||
# include <boost/mpl/next.hpp>
|
||||
# include <boost/mpl/if.hpp>
|
||||
# include <boost/mpl/apply.hpp>
|
||||
# include <boost/mpl/aux_/value_wknd.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/aux_/config/use_preprocessed.hpp>
|
||||
|
||||
#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
|
||||
&& !defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
|
||||
# define BOOST_MPL_PREPROCESSED_HEADER iter_fold_if_impl.hpp
|
||||
# include <boost/mpl/aux_/include_preprocessed.hpp>
|
||||
|
||||
#else
|
||||
|
||||
# include <boost/mpl/limits/unrolling.hpp>
|
||||
# include <boost/preprocessor/arithmetic/sub.hpp>
|
||||
# include <boost/preprocessor/repeat.hpp>
|
||||
# include <boost/preprocessor/inc.hpp>
|
||||
# include <boost/preprocessor/dec.hpp>
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
|
||||
template< typename Iterator, typename State >
|
||||
struct iter_fold_if_null_step
|
||||
{
|
||||
typedef State state;
|
||||
typedef Iterator iterator;
|
||||
};
|
||||
|
||||
template< bool >
|
||||
struct iter_fold_if_step_impl
|
||||
{
|
||||
template<
|
||||
typename Iterator
|
||||
, typename State
|
||||
, typename StateOp
|
||||
, typename IteratorOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef typename apply2<StateOp,State,Iterator>::type state;
|
||||
typedef typename IteratorOp::type iterator;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct iter_fold_if_step_impl<false>
|
||||
{
|
||||
template<
|
||||
typename Iterator
|
||||
, typename State
|
||||
, typename StateOp
|
||||
, typename IteratorOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef State state;
|
||||
typedef Iterator iterator;
|
||||
};
|
||||
};
|
||||
|
||||
// agurt, 25/jun/02: MSVC 6.5 workaround, had to get rid of inheritance
|
||||
// here and in 'iter_fold_if_backward_step', because sometimes it interfered
|
||||
// with the "early template instantiation bug" in _really_ ugly ways
|
||||
template<
|
||||
typename Iterator
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
, typename Predicate
|
||||
>
|
||||
struct iter_fold_if_forward_step
|
||||
{
|
||||
typedef typename apply2<Predicate,State,Iterator>::type not_last;
|
||||
typedef typename iter_fold_if_step_impl<
|
||||
BOOST_MPL_AUX_MSVC_VALUE_WKND(not_last)::value
|
||||
>::template result_< Iterator,State,ForwardOp,mpl::next<Iterator> > impl_;
|
||||
|
||||
typedef typename impl_::state state;
|
||||
typedef typename impl_::iterator iterator;
|
||||
};
|
||||
|
||||
template<
|
||||
typename Iterator
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename Predicate
|
||||
>
|
||||
struct iter_fold_if_backward_step
|
||||
{
|
||||
typedef typename apply2<Predicate,State,Iterator>::type not_last;
|
||||
typedef typename iter_fold_if_step_impl<
|
||||
BOOST_MPL_AUX_MSVC_VALUE_WKND(not_last)::value
|
||||
>::template result_< Iterator,State,BackwardOp,identity<Iterator> > impl_;
|
||||
|
||||
typedef typename impl_::state state;
|
||||
typedef typename impl_::iterator iterator;
|
||||
};
|
||||
|
||||
|
||||
// local macros, #undef-ined at the end of the header
|
||||
|
||||
# define AUX_ITER_FOLD_FORWARD_STEP(unused, i, unused2) \
|
||||
typedef iter_fold_if_forward_step< \
|
||||
typename BOOST_PP_CAT(forward_step,i)::iterator \
|
||||
, typename BOOST_PP_CAT(forward_step,i)::state \
|
||||
, ForwardOp \
|
||||
, ForwardPredicate \
|
||||
> BOOST_PP_CAT(forward_step, BOOST_PP_INC(i)); \
|
||||
/**/
|
||||
|
||||
# define AUX_ITER_FOLD_BACKWARD_STEP_FUNC(i) \
|
||||
typedef iter_fold_if_backward_step< \
|
||||
typename BOOST_PP_CAT(forward_step,BOOST_PP_DEC(i))::iterator \
|
||||
, typename BOOST_PP_CAT(backward_step,i)::state \
|
||||
, BackwardOp \
|
||||
, BackwardPredicate \
|
||||
> BOOST_PP_CAT(backward_step,BOOST_PP_DEC(i)); \
|
||||
/**/
|
||||
|
||||
# define AUX_ITER_FOLD_BACKWARD_STEP(unused, i, unused2) \
|
||||
AUX_ITER_FOLD_BACKWARD_STEP_FUNC( \
|
||||
BOOST_PP_SUB_D(1,BOOST_MPL_LIMIT_UNROLLING,i) \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# define AUX_LAST_FORWARD_STEP \
|
||||
BOOST_PP_CAT(forward_step, BOOST_MPL_LIMIT_UNROLLING) \
|
||||
/**/
|
||||
|
||||
# define AUX_LAST_BACKWARD_STEP \
|
||||
BOOST_PP_CAT(backward_step, BOOST_MPL_LIMIT_UNROLLING) \
|
||||
/**/
|
||||
|
||||
template<
|
||||
typename Iterator
|
||||
, typename State
|
||||
, typename ForwardOp
|
||||
, typename ForwardPredicate
|
||||
, typename BackwardOp
|
||||
, typename BackwardPredicate
|
||||
>
|
||||
struct iter_fold_if_impl
|
||||
{
|
||||
private:
|
||||
typedef iter_fold_if_null_step<Iterator,State> forward_step0;
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_MPL_LIMIT_UNROLLING
|
||||
, AUX_ITER_FOLD_FORWARD_STEP
|
||||
, unused
|
||||
)
|
||||
|
||||
typedef typename if_<
|
||||
typename AUX_LAST_FORWARD_STEP::not_last
|
||||
, iter_fold_if_impl<
|
||||
typename AUX_LAST_FORWARD_STEP::iterator
|
||||
, typename AUX_LAST_FORWARD_STEP::state
|
||||
, ForwardOp
|
||||
, ForwardPredicate
|
||||
, BackwardOp
|
||||
, BackwardPredicate
|
||||
>
|
||||
, iter_fold_if_null_step<
|
||||
typename AUX_LAST_FORWARD_STEP::iterator
|
||||
, typename AUX_LAST_FORWARD_STEP::state
|
||||
>
|
||||
>::type AUX_LAST_BACKWARD_STEP;
|
||||
|
||||
BOOST_PP_REPEAT(
|
||||
BOOST_MPL_LIMIT_UNROLLING
|
||||
, AUX_ITER_FOLD_BACKWARD_STEP
|
||||
, unused
|
||||
)
|
||||
|
||||
public:
|
||||
typedef typename backward_step0::state state;
|
||||
typedef typename AUX_LAST_BACKWARD_STEP::iterator iterator;
|
||||
};
|
||||
|
||||
# undef AUX_LAST_BACKWARD_STEP
|
||||
# undef AUX_LAST_FORWARD_STEP
|
||||
# undef AUX_ITER_FOLD_BACKWARD_STEP
|
||||
# undef AUX_ITER_FOLD_BACKWARD_STEP_FUNC
|
||||
# undef AUX_ITER_FOLD_FORWARD_STEP
|
||||
|
||||
}}}
|
||||
|
||||
#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
|
||||
#endif // BOOST_MPL_AUX_ITER_FOLD_IF_IMPL_HPP_INCLUDED
|
42
boost/mpl/aux_/iter_fold_impl.hpp
Normal file
42
boost/mpl/aux_/iter_fold_impl.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_ITER_FOLD_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_ITER_FOLD_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#if !defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
# include <boost/mpl/next_prior.hpp>
|
||||
# include <boost/mpl/apply.hpp>
|
||||
# include <boost/mpl/aux_/config/ctps.hpp>
|
||||
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
# include <boost/mpl/if.hpp>
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/aux_/config/use_preprocessed.hpp>
|
||||
|
||||
#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
|
||||
&& !defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
|
||||
# define BOOST_MPL_PREPROCESSED_HEADER iter_fold_impl.hpp
|
||||
# include <boost/mpl/aux_/include_preprocessed.hpp>
|
||||
|
||||
#else
|
||||
|
||||
# define AUX778076_FOLD_IMPL_OP(iter) iter
|
||||
# define AUX778076_FOLD_IMPL_NAME_PREFIX iter_fold
|
||||
# include <boost/mpl/aux_/fold_impl_body.hpp>
|
||||
|
||||
#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
|
||||
#endif // BOOST_MPL_AUX_ITER_FOLD_IMPL_HPP_INCLUDED
|
36
boost/mpl/aux_/iter_push_front.hpp
Normal file
36
boost/mpl/aux_/iter_push_front.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
#ifndef BOOST_MPL_ITER_PUSH_FRONT_HPP_INCLUDED
|
||||
#define BOOST_MPL_ITER_PUSH_FRONT_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2002-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/push_front.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
|
||||
template<
|
||||
typename Sequence
|
||||
, typename Iterator
|
||||
>
|
||||
struct iter_push_front
|
||||
{
|
||||
typedef typename push_front<
|
||||
Sequence
|
||||
, typename deref<Iterator>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif // BOOST_MPL_ITER_PUSH_FRONT_HPP_INCLUDED
|
120
boost/mpl/aux_/joint_iter.hpp
Normal file
120
boost/mpl/aux_/joint_iter.hpp
Normal file
@ -0,0 +1,120 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_JOINT_ITER_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_JOINT_ITER_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/next_prior.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/iterator_tags.hpp>
|
||||
#include <boost/mpl/aux_/lambda_spec.hpp>
|
||||
#include <boost/mpl/aux_/config/ctps.hpp>
|
||||
|
||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
template<
|
||||
typename Iterator1
|
||||
, typename LastIterator1
|
||||
, typename Iterator2
|
||||
>
|
||||
struct joint_iter
|
||||
{
|
||||
typedef Iterator1 base;
|
||||
typedef forward_iterator_tag category;
|
||||
};
|
||||
|
||||
template<
|
||||
typename LastIterator1
|
||||
, typename Iterator2
|
||||
>
|
||||
struct joint_iter<LastIterator1,LastIterator1,Iterator2>
|
||||
{
|
||||
typedef Iterator2 base;
|
||||
typedef forward_iterator_tag category;
|
||||
};
|
||||
|
||||
|
||||
template< typename I1, typename L1, typename I2 >
|
||||
struct deref< joint_iter<I1,L1,I2> >
|
||||
{
|
||||
typedef typename joint_iter<I1,L1,I2>::base base_;
|
||||
typedef typename deref<base_>::type type;
|
||||
};
|
||||
|
||||
template< typename I1, typename L1, typename I2 >
|
||||
struct next< joint_iter<I1,L1,I2> >
|
||||
{
|
||||
typedef joint_iter< typename mpl::next<I1>::type,L1,I2 > type;
|
||||
};
|
||||
|
||||
template< typename L1, typename I2 >
|
||||
struct next< joint_iter<L1,L1,I2> >
|
||||
{
|
||||
typedef joint_iter< L1,L1,typename mpl::next<I2>::type > type;
|
||||
};
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
template<
|
||||
typename Iterator1
|
||||
, typename LastIterator1
|
||||
, typename Iterator2
|
||||
>
|
||||
struct joint_iter;
|
||||
|
||||
template< bool > struct joint_iter_impl
|
||||
{
|
||||
template< typename I1, typename L1, typename I2 > struct result_
|
||||
{
|
||||
typedef I1 base;
|
||||
typedef forward_iterator_tag category;
|
||||
typedef joint_iter< typename mpl::next<I1>::type,L1,I2 > next;
|
||||
typedef typename deref<I1>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<> struct joint_iter_impl<true>
|
||||
{
|
||||
template< typename I1, typename L1, typename I2 > struct result_
|
||||
{
|
||||
typedef I2 base;
|
||||
typedef forward_iterator_tag category;
|
||||
typedef joint_iter< L1,L1,typename mpl::next<I2>::type > next;
|
||||
typedef typename deref<I2>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<
|
||||
typename Iterator1
|
||||
, typename LastIterator1
|
||||
, typename Iterator2
|
||||
>
|
||||
struct joint_iter
|
||||
: joint_iter_impl< is_same<Iterator1,LastIterator1>::value >
|
||||
::template result_<Iterator1,LastIterator1,Iterator2>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
BOOST_MPL_AUX_PASS_THROUGH_LAMBDA_SPEC(3, joint_iter)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_JOINT_ITER_HPP_INCLUDED
|
49
boost/mpl/aux_/lambda_spec.hpp
Normal file
49
boost/mpl/aux_/lambda_spec.hpp
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_LAMBDA_SPEC_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_LAMBDA_SPEC_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2001-2007
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/void.hpp>
|
||||
#include <boost/mpl/lambda_fwd.hpp>
|
||||
#include <boost/mpl/int_fwd.hpp>
|
||||
#include <boost/mpl/aux_/preprocessor/params.hpp>
|
||||
#include <boost/mpl/aux_/lambda_arity_param.hpp>
|
||||
#include <boost/mpl/aux_/config/lambda.hpp>
|
||||
|
||||
#if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
|
||||
|
||||
# define BOOST_MPL_AUX_PASS_THROUGH_LAMBDA_SPEC(i, name) \
|
||||
template< \
|
||||
BOOST_MPL_PP_PARAMS(i, typename T) \
|
||||
, typename Tag \
|
||||
> \
|
||||
struct lambda< \
|
||||
name< BOOST_MPL_PP_PARAMS(i, T) > \
|
||||
, Tag \
|
||||
BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(int_<i>) \
|
||||
> \
|
||||
{ \
|
||||
typedef false_ is_le; \
|
||||
typedef name< BOOST_MPL_PP_PARAMS(i, T) > result_; \
|
||||
typedef result_ type; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_MPL_AUX_PASS_THROUGH_LAMBDA_SPEC(i, name) /**/
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BOOST_MPL_AUX_LAMBDA_SPEC_HPP_INCLUDED
|
62
boost/mpl/aux_/msvc_type.hpp
Normal file
62
boost/mpl/aux_/msvc_type.hpp
Normal file
@ -0,0 +1,62 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_MSVC_TYPE_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_MSVC_TYPE_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2001-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/aux_/config/eti.hpp>
|
||||
#include <boost/mpl/aux_/is_msvc_eti_arg.hpp>
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
|
||||
#if defined(BOOST_MPL_CFG_MSVC_70_ETI_BUG)
|
||||
|
||||
template< bool > struct msvc_type_impl
|
||||
{
|
||||
template< typename T > struct result_
|
||||
{
|
||||
typedef typename T::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<> struct msvc_type_impl<true>
|
||||
{
|
||||
template< typename T > struct result_
|
||||
{
|
||||
typedef result_ type;
|
||||
};
|
||||
};
|
||||
|
||||
template< typename T > struct msvc_type
|
||||
: msvc_type_impl< is_msvc_eti_arg<T>::value >
|
||||
::template result_<T>
|
||||
{
|
||||
};
|
||||
|
||||
#else // BOOST_MPL_CFG_MSVC_70_ETI_BUG
|
||||
|
||||
template< typename T > struct msvc_type
|
||||
{
|
||||
typedef typename T::type type;
|
||||
};
|
||||
|
||||
template<> struct msvc_type<int>
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
}}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_MSVC_TYPE_HPP_INCLUDED
|
70
boost/mpl/aux_/push_back_impl.hpp
Normal file
70
boost/mpl/aux_/push_back_impl.hpp
Normal file
@ -0,0 +1,70 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_PUSH_BACK_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_PUSH_BACK_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/push_back_fwd.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/aux_/has_type.hpp>
|
||||
#include <boost/mpl/aux_/traits_lambda_spec.hpp>
|
||||
#include <boost/mpl/aux_/config/forwarding.hpp>
|
||||
#include <boost/mpl/aux_/config/static_constant.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
struct has_push_back_arg {};
|
||||
|
||||
// agurt 05/feb/04: no default implementation; the stub definition is needed
|
||||
// to enable the default 'has_push_back' implementation below
|
||||
template< typename Tag >
|
||||
struct push_back_impl
|
||||
{
|
||||
template< typename Sequence, typename T > struct apply
|
||||
{
|
||||
// should be instantiated only in the context of 'has_push_back_impl';
|
||||
// if you've got an assert here, you are requesting a 'push_back'
|
||||
// specialization that doesn't exist.
|
||||
BOOST_MPL_ASSERT_MSG(
|
||||
( boost::is_same< T, has_push_back_arg >::value )
|
||||
, REQUESTED_PUSH_BACK_SPECIALIZATION_FOR_SEQUENCE_DOES_NOT_EXIST
|
||||
, ( Sequence )
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
template< typename Tag >
|
||||
struct has_push_back_impl
|
||||
{
|
||||
template< typename Seq > struct apply
|
||||
#if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
|
||||
: aux::has_type< push_back< Seq, has_push_back_arg > >
|
||||
{
|
||||
#else
|
||||
{
|
||||
typedef aux::has_type< push_back< Seq, has_push_back_arg > > type;
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
(aux::has_type< push_back< Seq, has_push_back_arg > >::value)
|
||||
);
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(2, push_back_impl)
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1, has_push_back_impl)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_PUSH_BACK_IMPL_HPP_INCLUDED
|
71
boost/mpl/aux_/push_front_impl.hpp
Normal file
71
boost/mpl/aux_/push_front_impl.hpp
Normal file
@ -0,0 +1,71 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_PUSH_FRONT_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_PUSH_FRONT_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/push_front_fwd.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/aux_/has_type.hpp>
|
||||
#include <boost/mpl/aux_/traits_lambda_spec.hpp>
|
||||
#include <boost/mpl/aux_/config/forwarding.hpp>
|
||||
#include <boost/mpl/aux_/config/static_constant.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
struct has_push_front_arg {};
|
||||
|
||||
// agurt 05/feb/04: no default implementation; the stub definition is needed
|
||||
// to enable the default 'has_push_front' implementation below
|
||||
|
||||
template< typename Tag >
|
||||
struct push_front_impl
|
||||
{
|
||||
template< typename Sequence, typename T > struct apply
|
||||
{
|
||||
// should be instantiated only in the context of 'has_push_front_impl';
|
||||
// if you've got an assert here, you are requesting a 'push_front'
|
||||
// specialization that doesn't exist.
|
||||
BOOST_MPL_ASSERT_MSG(
|
||||
( boost::is_same< T, has_push_front_arg >::value )
|
||||
, REQUESTED_PUSH_FRONT_SPECIALIZATION_FOR_SEQUENCE_DOES_NOT_EXIST
|
||||
, ( Sequence )
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
template< typename Tag >
|
||||
struct has_push_front_impl
|
||||
{
|
||||
template< typename Seq > struct apply
|
||||
#if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
|
||||
: aux::has_type< push_front< Seq, has_push_front_arg > >
|
||||
{
|
||||
#else
|
||||
{
|
||||
typedef aux::has_type< push_front< Seq, has_push_front_arg > > type;
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
(aux::has_type< push_front< Seq, has_push_front_arg > >::value)
|
||||
);
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(2, push_front_impl)
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1, has_push_front_impl)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_PUSH_FRONT_IMPL_HPP_INCLUDED
|
44
boost/mpl/aux_/reverse_fold_impl.hpp
Normal file
44
boost/mpl/aux_/reverse_fold_impl.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_REVERSE_FOLD_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_REVERSE_FOLD_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#if !defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
# include <boost/mpl/next_prior.hpp>
|
||||
# include <boost/mpl/deref.hpp>
|
||||
# include <boost/mpl/apply.hpp>
|
||||
# include <boost/mpl/aux_/config/ctps.hpp>
|
||||
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||
|| defined(BOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC)
|
||||
# include <boost/mpl/if.hpp>
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/aux_/config/use_preprocessed.hpp>
|
||||
|
||||
#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
|
||||
&& !defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
|
||||
# define BOOST_MPL_PREPROCESSED_HEADER reverse_fold_impl.hpp
|
||||
# include <boost/mpl/aux_/include_preprocessed.hpp>
|
||||
|
||||
#else
|
||||
|
||||
# define AUX778076_FOLD_IMPL_OP(iter) typename deref<iter>::type
|
||||
# define AUX778076_FOLD_IMPL_NAME_PREFIX reverse_fold
|
||||
# include <boost/mpl/aux_/reverse_fold_impl_body.hpp>
|
||||
|
||||
#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
|
||||
#endif // BOOST_MPL_AUX_REVERSE_FOLD_IMPL_HPP_INCLUDED
|
412
boost/mpl/aux_/reverse_fold_impl_body.hpp
Normal file
412
boost/mpl/aux_/reverse_fold_impl_body.hpp
Normal file
@ -0,0 +1,412 @@
|
||||
|
||||
// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION!
|
||||
|
||||
#if !defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
# include <boost/mpl/limits/unrolling.hpp>
|
||||
# include <boost/mpl/aux_/preprocessor/repeat.hpp>
|
||||
# include <boost/mpl/aux_/config/ctps.hpp>
|
||||
# include <boost/mpl/aux_/nttp_decl.hpp>
|
||||
|
||||
# include <boost/preprocessor/arithmetic/sub.hpp>
|
||||
# include <boost/preprocessor/iterate.hpp>
|
||||
# include <boost/preprocessor/dec.hpp>
|
||||
# include <boost/preprocessor/inc.hpp>
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
|
||||
// local macros, #undef-ined at the end of the header
|
||||
|
||||
# define AUX778076_ITER_FOLD_FORWARD_STEP(unused, n_, unused2) \
|
||||
typedef typename apply2< \
|
||||
ForwardOp \
|
||||
, BOOST_PP_CAT(fwd_state,n_) \
|
||||
, AUX778076_FOLD_IMPL_OP(BOOST_PP_CAT(iter,n_)) \
|
||||
>::type BOOST_PP_CAT(fwd_state,BOOST_PP_INC(n_)); \
|
||||
typedef typename mpl::next<BOOST_PP_CAT(iter,n_)>::type \
|
||||
BOOST_PP_CAT(iter,BOOST_PP_INC(n_)); \
|
||||
/**/
|
||||
|
||||
# define AUX778076_ITER_FOLD_BACKWARD_STEP_FUNC(n_) \
|
||||
typedef typename apply2< \
|
||||
BackwardOp \
|
||||
, BOOST_PP_CAT(bkwd_state,n_) \
|
||||
, AUX778076_FOLD_IMPL_OP(BOOST_PP_CAT(iter,BOOST_PP_DEC(n_))) \
|
||||
>::type BOOST_PP_CAT(bkwd_state,BOOST_PP_DEC(n_)); \
|
||||
/**/
|
||||
|
||||
# define AUX778076_ITER_FOLD_BACKWARD_STEP(unused, n_, j) \
|
||||
AUX778076_ITER_FOLD_BACKWARD_STEP_FUNC( \
|
||||
BOOST_PP_SUB_D(1,j,n_) \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# define AUX778076_FIRST_BACKWARD_STATE_TYPEDEF(n_) \
|
||||
typedef typename nested_chunk::state BOOST_PP_CAT(bkwd_state,n_);
|
||||
/**/
|
||||
|
||||
# define AUX778076_FOLD_IMPL_NAME \
|
||||
BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_impl) \
|
||||
/**/
|
||||
|
||||
# define AUX778076_FOLD_CHUNK_NAME \
|
||||
BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_chunk) \
|
||||
/**/
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
|
||||
/// forward declaration
|
||||
template<
|
||||
BOOST_MPL_AUX_NTTP_DECL(long, N)
|
||||
, typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME;
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||
&& !defined(BOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC)
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 \
|
||||
(3,(0, BOOST_MPL_LIMIT_UNROLLING, <boost/mpl/aux_/reverse_fold_impl_body.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
// implementation for N that exceeds BOOST_MPL_LIMIT_UNROLLING
|
||||
template<
|
||||
BOOST_MPL_AUX_NTTP_DECL(long, N)
|
||||
, typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME
|
||||
{
|
||||
typedef First iter0;
|
||||
typedef State fwd_state0;
|
||||
|
||||
BOOST_MPL_PP_REPEAT(
|
||||
BOOST_MPL_LIMIT_UNROLLING
|
||||
, AUX778076_ITER_FOLD_FORWARD_STEP
|
||||
, unused
|
||||
)
|
||||
|
||||
typedef AUX778076_FOLD_IMPL_NAME<
|
||||
( (N - BOOST_MPL_LIMIT_UNROLLING) < 0 ? 0 : N - BOOST_MPL_LIMIT_UNROLLING )
|
||||
, BOOST_PP_CAT(iter,BOOST_MPL_LIMIT_UNROLLING)
|
||||
, Last
|
||||
, BOOST_PP_CAT(fwd_state,BOOST_MPL_LIMIT_UNROLLING)
|
||||
, BackwardOp
|
||||
, ForwardOp
|
||||
> nested_chunk;
|
||||
|
||||
AUX778076_FIRST_BACKWARD_STATE_TYPEDEF(BOOST_MPL_LIMIT_UNROLLING)
|
||||
|
||||
BOOST_MPL_PP_REPEAT(
|
||||
BOOST_MPL_LIMIT_UNROLLING
|
||||
, AUX778076_ITER_FOLD_BACKWARD_STEP
|
||||
, BOOST_MPL_LIMIT_UNROLLING
|
||||
)
|
||||
|
||||
typedef bkwd_state0 state;
|
||||
typedef typename nested_chunk::iterator iterator;
|
||||
};
|
||||
|
||||
// fallback implementation for sequences of unknown size
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME<-1,First,Last,State,BackwardOp,ForwardOp>
|
||||
{
|
||||
typedef AUX778076_FOLD_IMPL_NAME<
|
||||
-1
|
||||
, typename mpl::next<First>::type
|
||||
, Last
|
||||
, typename apply2<ForwardOp,State,AUX778076_FOLD_IMPL_OP(First)>::type
|
||||
, BackwardOp
|
||||
, ForwardOp
|
||||
> nested_step;
|
||||
|
||||
typedef typename apply2<
|
||||
BackwardOp
|
||||
, typename nested_step::state
|
||||
, AUX778076_FOLD_IMPL_OP(First)
|
||||
>::type state;
|
||||
|
||||
typedef typename nested_step::iterator iterator;
|
||||
};
|
||||
|
||||
template<
|
||||
typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME<-1,Last,Last,State,BackwardOp,ForwardOp>
|
||||
{
|
||||
typedef State state;
|
||||
typedef Last iterator;
|
||||
};
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
template< BOOST_MPL_AUX_NTTP_DECL(long, N) >
|
||||
struct AUX778076_FOLD_CHUNK_NAME;
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 \
|
||||
(3,(0, BOOST_MPL_LIMIT_UNROLLING, <boost/mpl/aux_/reverse_fold_impl_body.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
// implementation for N that exceeds BOOST_MPL_LIMIT_UNROLLING
|
||||
template< BOOST_MPL_AUX_NTTP_DECL(long, N) >
|
||||
struct AUX778076_FOLD_CHUNK_NAME
|
||||
{
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef First iter0;
|
||||
typedef State fwd_state0;
|
||||
|
||||
BOOST_MPL_PP_REPEAT(
|
||||
BOOST_MPL_LIMIT_UNROLLING
|
||||
, AUX778076_ITER_FOLD_FORWARD_STEP
|
||||
, unused
|
||||
)
|
||||
|
||||
typedef AUX778076_FOLD_IMPL_NAME<
|
||||
( (N - BOOST_MPL_LIMIT_UNROLLING) < 0 ? 0 : N - BOOST_MPL_LIMIT_UNROLLING )
|
||||
, BOOST_PP_CAT(iter,BOOST_MPL_LIMIT_UNROLLING)
|
||||
, Last
|
||||
, BOOST_PP_CAT(fwd_state,BOOST_MPL_LIMIT_UNROLLING)
|
||||
, BackwardOp
|
||||
, ForwardOp
|
||||
> nested_chunk;
|
||||
|
||||
AUX778076_FIRST_BACKWARD_STATE_TYPEDEF(BOOST_MPL_LIMIT_UNROLLING)
|
||||
|
||||
BOOST_MPL_PP_REPEAT(
|
||||
BOOST_MPL_LIMIT_UNROLLING
|
||||
, AUX778076_ITER_FOLD_BACKWARD_STEP
|
||||
, BOOST_MPL_LIMIT_UNROLLING
|
||||
)
|
||||
|
||||
typedef bkwd_state0 state;
|
||||
typedef typename nested_chunk::iterator iterator;
|
||||
};
|
||||
};
|
||||
|
||||
// fallback implementation for sequences of unknown size
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_step);
|
||||
|
||||
template<
|
||||
typename Last
|
||||
, typename State
|
||||
>
|
||||
struct BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_null_step)
|
||||
{
|
||||
typedef Last iterator;
|
||||
typedef State state;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct AUX778076_FOLD_CHUNK_NAME<-1>
|
||||
{
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef typename if_<
|
||||
typename is_same<First,Last>::type
|
||||
, BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_null_step)<Last,State>
|
||||
, BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_step)<First,Last,State,BackwardOp,ForwardOp>
|
||||
>::type res_;
|
||||
|
||||
typedef typename res_::state state;
|
||||
typedef typename res_::iterator iterator;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)
|
||||
/// ETI workaround
|
||||
template<> struct result_<int,int,int,int,int>
|
||||
{
|
||||
typedef int state;
|
||||
typedef int iterator;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct BOOST_PP_CAT(AUX778076_FOLD_IMPL_NAME_PREFIX,_step)
|
||||
{
|
||||
typedef AUX778076_FOLD_CHUNK_NAME<-1>::template result_<
|
||||
typename mpl::next<First>::type
|
||||
, Last
|
||||
, typename apply2<ForwardOp,State,AUX778076_FOLD_IMPL_OP(First)>::type
|
||||
, BackwardOp
|
||||
, ForwardOp
|
||||
> nested_step;
|
||||
|
||||
typedef typename apply2<
|
||||
BackwardOp
|
||||
, typename nested_step::state
|
||||
, AUX778076_FOLD_IMPL_OP(First)
|
||||
>::type state;
|
||||
|
||||
typedef typename nested_step::iterator iterator;
|
||||
};
|
||||
|
||||
template<
|
||||
BOOST_MPL_AUX_NTTP_DECL(long, N)
|
||||
, typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME
|
||||
: AUX778076_FOLD_CHUNK_NAME<N>
|
||||
::template result_<First,Last,State,BackwardOp,ForwardOp>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
}}}
|
||||
|
||||
# undef AUX778076_FIRST_BACKWARD_STATE_TYPEDEF
|
||||
# undef AUX778076_ITER_FOLD_BACKWARD_STEP
|
||||
# undef AUX778076_ITER_FOLD_BACKWARD_STEP_FUNC
|
||||
# undef AUX778076_ITER_FOLD_FORWARD_STEP
|
||||
|
||||
#undef AUX778076_FOLD_IMPL_OP
|
||||
#undef AUX778076_FOLD_IMPL_NAME_PREFIX
|
||||
|
||||
///// iteration
|
||||
|
||||
#else
|
||||
|
||||
# define n_ BOOST_PP_FRAME_ITERATION(1)
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||
&& !defined(BOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC)
|
||||
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct AUX778076_FOLD_IMPL_NAME<n_,First,Last,State,BackwardOp,ForwardOp>
|
||||
{
|
||||
typedef First iter0;
|
||||
typedef State fwd_state0;
|
||||
|
||||
BOOST_MPL_PP_REPEAT(
|
||||
n_
|
||||
, AUX778076_ITER_FOLD_FORWARD_STEP
|
||||
, unused
|
||||
)
|
||||
|
||||
typedef BOOST_PP_CAT(fwd_state,n_) BOOST_PP_CAT(bkwd_state,n_);
|
||||
|
||||
BOOST_MPL_PP_REPEAT(
|
||||
n_
|
||||
, AUX778076_ITER_FOLD_BACKWARD_STEP
|
||||
, n_
|
||||
)
|
||||
|
||||
typedef bkwd_state0 state;
|
||||
typedef BOOST_PP_CAT(iter,n_) iterator;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template<> struct AUX778076_FOLD_CHUNK_NAME<n_>
|
||||
{
|
||||
template<
|
||||
typename First
|
||||
, typename Last
|
||||
, typename State
|
||||
, typename BackwardOp
|
||||
, typename ForwardOp
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
typedef First iter0;
|
||||
typedef State fwd_state0;
|
||||
|
||||
BOOST_MPL_PP_REPEAT(
|
||||
n_
|
||||
, AUX778076_ITER_FOLD_FORWARD_STEP
|
||||
, unused
|
||||
)
|
||||
|
||||
typedef BOOST_PP_CAT(fwd_state,n_) BOOST_PP_CAT(bkwd_state,n_);
|
||||
|
||||
BOOST_MPL_PP_REPEAT(
|
||||
n_
|
||||
, AUX778076_ITER_FOLD_BACKWARD_STEP
|
||||
, n_
|
||||
)
|
||||
|
||||
typedef bkwd_state0 state;
|
||||
typedef BOOST_PP_CAT(iter,n_) iterator;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)
|
||||
/// ETI workaround
|
||||
template<> struct result_<int,int,int,int,int>
|
||||
{
|
||||
typedef int state;
|
||||
typedef int iterator;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
# undef n_
|
||||
|
||||
#endif // BOOST_PP_IS_ITERATING
|
292
boost/mpl/aux_/sequence_wrapper.hpp
Normal file
292
boost/mpl/aux_/sequence_wrapper.hpp
Normal file
@ -0,0 +1,292 @@
|
||||
|
||||
// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
|
||||
|
||||
#if !defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
///// header body
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
# include <boost/mpl/aux_/config/ctps.hpp>
|
||||
# include <boost/mpl/aux_/config/static_constant.hpp>
|
||||
# include <boost/mpl/aux_/nttp_decl.hpp>
|
||||
|
||||
# include <boost/preprocessor/arithmetic/sub.hpp>
|
||||
# include <boost/preprocessor/tuple/elem.hpp>
|
||||
# include <boost/preprocessor/enum_params_with_a_default.hpp>
|
||||
# include <boost/preprocessor/enum_params.hpp>
|
||||
# include <boost/preprocessor/enum.hpp>
|
||||
# include <boost/preprocessor/repeat.hpp>
|
||||
# include <boost/preprocessor/comma_if.hpp>
|
||||
# include <boost/preprocessor/iterate.hpp>
|
||||
|
||||
#if defined(BOOST_MPL_PREPROCESSING_MODE)
|
||||
# undef LONG_MAX
|
||||
#endif
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
#if !defined(AUX778076_SEQUENCE_BASE_NAME)
|
||||
# define AUX778076_SEQUENCE_BASE_NAME AUX778076_SEQUENCE_NAME
|
||||
#endif
|
||||
|
||||
#if !defined(AUX778076_SEQUENCE_INTEGRAL_WRAPPER)
|
||||
|
||||
# define AUX778076_SEQUENCE_PARAM_NAME T
|
||||
# define AUX778076_SEQUENCE_TEMPLATE_PARAM typename T
|
||||
# define AUX778076_SEQUENCE_DEFAULT na
|
||||
|
||||
# define AUX778076_SEQUENCE_NAME_N(n) \
|
||||
BOOST_PP_CAT(AUX778076_SEQUENCE_BASE_NAME,n) \
|
||||
/**/
|
||||
|
||||
# define AUX778076_SEQUENCE_PARAMS() \
|
||||
BOOST_PP_ENUM_PARAMS( \
|
||||
AUX778076_SEQUENCE_LIMIT \
|
||||
, AUX778076_SEQUENCE_TEMPLATE_PARAM \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# define AUX778076_SEQUENCE_ARGS() \
|
||||
BOOST_PP_ENUM_PARAMS( \
|
||||
AUX778076_SEQUENCE_LIMIT \
|
||||
, T \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# define AUX778076_SEQUENCE_DEFAULT_PARAMS() \
|
||||
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( \
|
||||
AUX778076_SEQUENCE_LIMIT \
|
||||
, AUX778076_SEQUENCE_TEMPLATE_PARAM \
|
||||
, AUX778076_SEQUENCE_DEFAULT \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# define AUX778076_SEQUENCE_N_PARAMS(n) \
|
||||
BOOST_PP_ENUM_PARAMS(n, AUX778076_SEQUENCE_TEMPLATE_PARAM) \
|
||||
/**/
|
||||
|
||||
# define AUX778076_SEQUENCE_N_ARGS(n) \
|
||||
BOOST_PP_ENUM_PARAMS(n, T) \
|
||||
/**/
|
||||
|
||||
# define AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS(n) \
|
||||
BOOST_PP_ENUM_PARAMS(n, T) \
|
||||
BOOST_PP_COMMA_IF(n) \
|
||||
BOOST_PP_ENUM( \
|
||||
BOOST_PP_SUB_D(1,AUX778076_SEQUENCE_LIMIT,n) \
|
||||
, BOOST_PP_TUPLE_ELEM_3_2 \
|
||||
, AUX778076_SEQUENCE_DEFAULT \
|
||||
) \
|
||||
/**/
|
||||
|
||||
#else // AUX778076_SEQUENCE_INTEGRAL_WRAPPER
|
||||
|
||||
# define AUX778076_SEQUENCE_PARAM_NAME C
|
||||
# define AUX778076_SEQUENCE_TEMPLATE_PARAM BOOST_MPL_AUX_NTTP_DECL(long, C)
|
||||
# define AUX778076_SEQUENCE_DEFAULT LONG_MAX
|
||||
|
||||
# define AUX778076_SEQUENCE_PARAMS() \
|
||||
typename T, BOOST_PP_ENUM_PARAMS( \
|
||||
AUX778076_SEQUENCE_LIMIT \
|
||||
, AUX778076_SEQUENCE_TEMPLATE_PARAM \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# define AUX778076_SEQUENCE_ARGS() \
|
||||
T, BOOST_PP_ENUM_PARAMS( \
|
||||
AUX778076_SEQUENCE_LIMIT \
|
||||
, C \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# define AUX778076_SEQUENCE_DEFAULT_PARAMS() \
|
||||
typename T, \
|
||||
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( \
|
||||
AUX778076_SEQUENCE_LIMIT \
|
||||
, AUX778076_SEQUENCE_TEMPLATE_PARAM \
|
||||
, AUX778076_SEQUENCE_DEFAULT \
|
||||
) \
|
||||
/**/
|
||||
|
||||
# define AUX778076_SEQUENCE_N_PARAMS(n) \
|
||||
typename T BOOST_PP_COMMA_IF(n) \
|
||||
BOOST_PP_ENUM_PARAMS(n, AUX778076_SEQUENCE_TEMPLATE_PARAM) \
|
||||
/**/
|
||||
|
||||
# if !defined(AUX778076_SEQUENCE_CONVERT_CN_TO)
|
||||
# define AUX778076_SEQUENCE_CONVERT_CN_TO(z,n,TARGET) BOOST_PP_CAT(C,n)
|
||||
# endif
|
||||
|
||||
# define AUX778076_SEQUENCE_N_ARGS(n) \
|
||||
T BOOST_PP_COMMA_IF(n) \
|
||||
BOOST_PP_ENUM(n,AUX778076_SEQUENCE_CONVERT_CN_TO,T) \
|
||||
/**/
|
||||
|
||||
# define AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS(n) \
|
||||
T, BOOST_PP_ENUM_PARAMS(n, C) \
|
||||
BOOST_PP_COMMA_IF(n) \
|
||||
BOOST_PP_ENUM( \
|
||||
BOOST_PP_SUB_D(1,AUX778076_SEQUENCE_LIMIT,n) \
|
||||
, BOOST_PP_TUPLE_ELEM_3_2 \
|
||||
, AUX778076_SEQUENCE_DEFAULT \
|
||||
) \
|
||||
/**/
|
||||
|
||||
#endif // AUX778076_SEQUENCE_INTEGRAL_WRAPPER
|
||||
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
// forward declaration
|
||||
template<
|
||||
AUX778076_SEQUENCE_DEFAULT_PARAMS()
|
||||
>
|
||||
struct AUX778076_SEQUENCE_NAME;
|
||||
#else
|
||||
namespace aux {
|
||||
template< BOOST_MPL_AUX_NTTP_DECL(int, N) >
|
||||
struct BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define BOOST_PP_ITERATION_PARAMS_1 \
|
||||
(3,(0, AUX778076_SEQUENCE_LIMIT, <boost/mpl/aux_/sequence_wrapper.hpp>))
|
||||
#include BOOST_PP_ITERATE()
|
||||
|
||||
// real C++ version is already taken care of
|
||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
namespace aux {
|
||||
// ???_count_args
|
||||
#define AUX778076_COUNT_ARGS_PREFIX AUX778076_SEQUENCE_NAME
|
||||
#define AUX778076_COUNT_ARGS_DEFAULT AUX778076_SEQUENCE_DEFAULT
|
||||
#define AUX778076_COUNT_ARGS_PARAM_NAME AUX778076_SEQUENCE_PARAM_NAME
|
||||
#define AUX778076_COUNT_ARGS_TEMPLATE_PARAM AUX778076_SEQUENCE_TEMPLATE_PARAM
|
||||
#define AUX778076_COUNT_ARGS_ARITY AUX778076_SEQUENCE_LIMIT
|
||||
#define AUX778076_COUNT_ARGS_USE_STANDARD_PP_PRIMITIVES
|
||||
#include <boost/mpl/aux_/count_args.hpp>
|
||||
|
||||
template<
|
||||
AUX778076_SEQUENCE_PARAMS()
|
||||
>
|
||||
struct BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)
|
||||
{
|
||||
typedef aux::BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_count_args)<
|
||||
BOOST_PP_ENUM_PARAMS(AUX778076_SEQUENCE_LIMIT, AUX778076_SEQUENCE_PARAM_NAME)
|
||||
> arg_num_;
|
||||
|
||||
typedef typename aux::BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser)< arg_num_::value >
|
||||
::template result_< AUX778076_SEQUENCE_ARGS() >::type type;
|
||||
};
|
||||
|
||||
} // namespace aux
|
||||
|
||||
template<
|
||||
AUX778076_SEQUENCE_DEFAULT_PARAMS()
|
||||
>
|
||||
struct AUX778076_SEQUENCE_NAME
|
||||
: aux::BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)<
|
||||
AUX778076_SEQUENCE_ARGS()
|
||||
>::type
|
||||
{
|
||||
typedef typename aux::BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)<
|
||||
AUX778076_SEQUENCE_ARGS()
|
||||
>::type type;
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
# undef AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS
|
||||
# undef AUX778076_SEQUENCE_N_ARGS
|
||||
# undef AUX778076_SEQUENCE_CONVERT_CN_TO
|
||||
# undef AUX778076_SEQUENCE_N_PARAMS
|
||||
# undef AUX778076_SEQUENCE_DEFAULT_PARAMS
|
||||
# undef AUX778076_SEQUENCE_ARGS
|
||||
# undef AUX778076_SEQUENCE_PARAMS
|
||||
# undef AUX778076_SEQUENCE_NAME_N
|
||||
# undef AUX778076_SEQUENCE_DEFAULT
|
||||
# undef AUX778076_SEQUENCE_TEMPLATE_PARAM
|
||||
# undef AUX778076_SEQUENCE_PARAM_NAME
|
||||
# undef AUX778076_SEQUENCE_LIMIT
|
||||
# undef AUX778076_SEQUENCE_BASE_NAME
|
||||
# undef AUX778076_SEQUENCE_NAME
|
||||
# undef AUX778076_SEQUENCE_INTEGRAL_WRAPPER
|
||||
|
||||
}}
|
||||
|
||||
///// iteration
|
||||
|
||||
#else
|
||||
#define i_ BOOST_PP_FRAME_ITERATION(1)
|
||||
|
||||
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
#if i_ == AUX778076_SEQUENCE_LIMIT
|
||||
|
||||
/// primary template (not a specialization!)
|
||||
template<
|
||||
AUX778076_SEQUENCE_N_PARAMS(i_)
|
||||
>
|
||||
struct AUX778076_SEQUENCE_NAME
|
||||
: AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) >
|
||||
{
|
||||
typedef typename AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) >::type type;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template<
|
||||
AUX778076_SEQUENCE_N_PARAMS(i_)
|
||||
>
|
||||
struct AUX778076_SEQUENCE_NAME< AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS(i_) >
|
||||
: AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) >
|
||||
{
|
||||
#if i_ > 0 || defined(AUX778076_SEQUENCE_INTEGRAL_WRAPPER)
|
||||
typedef typename AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) >::type type;
|
||||
#else
|
||||
typedef AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) >::type type;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // i_ == AUX778076_SEQUENCE_LIMIT
|
||||
|
||||
# else
|
||||
|
||||
namespace aux {
|
||||
|
||||
template<>
|
||||
struct BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser)<i_>
|
||||
{
|
||||
template<
|
||||
AUX778076_SEQUENCE_PARAMS()
|
||||
>
|
||||
struct result_
|
||||
{
|
||||
#if i_ > 0 || defined(AUX778076_SEQUENCE_INTEGRAL_WRAPPER)
|
||||
typedef typename AUX778076_SEQUENCE_NAME_N(i_)<
|
||||
AUX778076_SEQUENCE_N_ARGS(i_)
|
||||
>::type type;
|
||||
#else
|
||||
typedef AUX778076_SEQUENCE_NAME_N(i_)<
|
||||
AUX778076_SEQUENCE_N_ARGS(i_)
|
||||
>::type type;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace aux
|
||||
|
||||
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#undef i_
|
||||
#endif // BOOST_PP_IS_ITERATING
|
52
boost/mpl/aux_/size_impl.hpp
Normal file
52
boost/mpl/aux_/size_impl.hpp
Normal file
@ -0,0 +1,52 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_SIZE_IMPL_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_SIZE_IMPL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/size_fwd.hpp>
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/distance.hpp>
|
||||
#include <boost/mpl/aux_/traits_lambda_spec.hpp>
|
||||
#include <boost/mpl/aux_/config/workaround.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
// default implementation; conrete sequences might override it by
|
||||
// specializing either the 'size_impl' or the primary 'size' template
|
||||
|
||||
template< typename Tag >
|
||||
struct size_impl
|
||||
{
|
||||
template< typename Sequence > struct apply
|
||||
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x561))
|
||||
: distance<
|
||||
typename begin<Sequence>::type
|
||||
, typename end<Sequence>::type
|
||||
>
|
||||
{
|
||||
#else
|
||||
{
|
||||
typedef typename distance<
|
||||
typename begin<Sequence>::type
|
||||
, typename end<Sequence>::type
|
||||
>::type type;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1, size_impl)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_SIZE_IMPL_HPP_INCLUDED
|
63
boost/mpl/aux_/traits_lambda_spec.hpp
Normal file
63
boost/mpl/aux_/traits_lambda_spec.hpp
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
#ifndef BOOST_MPL_AUX_TRAITS_LAMBDA_SPEC_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_TRAITS_LAMBDA_SPEC_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/sequence_tag_fwd.hpp>
|
||||
#include <boost/mpl/void.hpp>
|
||||
#include <boost/mpl/aux_/preprocessor/params.hpp>
|
||||
#include <boost/mpl/aux_/config/lambda.hpp>
|
||||
|
||||
#if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
|
||||
|
||||
# define BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(i, trait) /**/
|
||||
|
||||
#elif !defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
|
||||
|
||||
# define BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(i, trait) \
|
||||
template<> struct trait<void_> \
|
||||
{ \
|
||||
template< BOOST_MPL_PP_PARAMS(i, typename T) > struct apply \
|
||||
{ \
|
||||
}; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(i, trait) \
|
||||
template<> struct trait<void_> \
|
||||
{ \
|
||||
template< BOOST_MPL_PP_PARAMS(i, typename T) > struct apply \
|
||||
{ \
|
||||
}; \
|
||||
}; \
|
||||
template<> struct trait<int> \
|
||||
{ \
|
||||
template< BOOST_MPL_PP_PARAMS(i, typename T) > struct apply \
|
||||
{ \
|
||||
typedef int type; \
|
||||
}; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT
|
||||
|
||||
|
||||
#define BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(i, trait) \
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(i, trait) \
|
||||
template<> struct trait<non_sequence_tag> {}; \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_MPL_AUX_TRAITS_LAMBDA_SPEC_HPP_INCLUDED
|
34
boost/mpl/back_inserter.hpp
Normal file
34
boost/mpl/back_inserter.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
#ifndef BOOST_MPL_BACK_INSERTER_HPP_INCLUDED
|
||||
#define BOOST_MPL_BACK_INSERTER_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2003-2004
|
||||
// Copyright David Abrahams 2003-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/push_back.hpp>
|
||||
#include <boost/mpl/inserter.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace mpl {
|
||||
|
||||
template<
|
||||
typename Sequence
|
||||
>
|
||||
struct back_inserter
|
||||
: inserter< Sequence,push_back<> >
|
||||
{
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_BACK_INSERTER_HPP_INCLUDED
|
57
boost/mpl/begin_end.hpp
Normal file
57
boost/mpl/begin_end.hpp
Normal file
@ -0,0 +1,57 @@
|
||||
|
||||
#ifndef BOOST_MPL_BEGIN_END_HPP_INCLUDED
|
||||
#define BOOST_MPL_BEGIN_END_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/begin_end_fwd.hpp>
|
||||
#include <boost/mpl/aux_/begin_end_impl.hpp>
|
||||
#include <boost/mpl/sequence_tag.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
// agurt, 13/sep/02: switched from inheritance to typedef; MSVC is more
|
||||
// happy this way (less ETI-related errors), and it doesn't affect
|
||||
// anything else
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
|
||||
>
|
||||
struct begin
|
||||
{
|
||||
typedef typename sequence_tag<Sequence>::type tag_;
|
||||
typedef typename begin_impl< tag_ >
|
||||
::template apply< Sequence >::type type;
|
||||
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,begin,(Sequence))
|
||||
};
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
|
||||
>
|
||||
struct end
|
||||
{
|
||||
typedef typename sequence_tag<Sequence>::type tag_;
|
||||
typedef typename end_impl< tag_ >
|
||||
::template apply< Sequence >::type type;
|
||||
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,end,(Sequence))
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC(1, begin)
|
||||
BOOST_MPL_AUX_NA_SPEC(1, end)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_BEGIN_END_HPP_INCLUDED
|
27
boost/mpl/begin_end_fwd.hpp
Normal file
27
boost/mpl/begin_end_fwd.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
#ifndef BOOST_MPL_BEGIN_END_FWD_HPP_INCLUDED
|
||||
#define BOOST_MPL_BEGIN_END_FWD_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template< typename Tag > struct begin_impl;
|
||||
template< typename Tag > struct end_impl;
|
||||
|
||||
template< typename Sequence > struct begin;
|
||||
template< typename Sequence > struct end;
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_BEGIN_END_FWD_HPP_INCLUDED
|
39
boost/mpl/clear.hpp
Normal file
39
boost/mpl/clear.hpp
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
#ifndef BOOST_MPL_CLEAR_HPP_INCLUDED
|
||||
#define BOOST_MPL_CLEAR_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/clear_fwd.hpp>
|
||||
#include <boost/mpl/aux_/clear_impl.hpp>
|
||||
#include <boost/mpl/sequence_tag.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
|
||||
>
|
||||
struct clear
|
||||
: clear_impl< typename sequence_tag<Sequence>::type >
|
||||
::template apply< Sequence >
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,clear,(Sequence))
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC(1, clear)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_CLEAR_HPP_INCLUDED
|
24
boost/mpl/clear_fwd.hpp
Normal file
24
boost/mpl/clear_fwd.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
#ifndef BOOST_MPL_CLEAR_FWD_HPP_INCLUDED
|
||||
#define BOOST_MPL_CLEAR_FWD_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template< typename Tag > struct clear_impl;
|
||||
template< typename Sequence > struct clear;
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_CLEAR_FWD_HPP_INCLUDED
|
41
boost/mpl/deref.hpp
Normal file
41
boost/mpl/deref.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
#ifndef BOOST_MPL_DEREF_HPP_INCLUDED
|
||||
#define BOOST_MPL_DEREF_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2002-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/aux_/msvc_type.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||
#include <boost/mpl/aux_/config/eti.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(Iterator)
|
||||
>
|
||||
struct deref
|
||||
{
|
||||
#if !defined(BOOST_MPL_CFG_MSVC_70_ETI_BUG)
|
||||
typedef typename Iterator::type type;
|
||||
#else
|
||||
typedef typename aux::msvc_type<Iterator>::type type;
|
||||
#endif
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,deref,(Iterator))
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC(1, deref)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_DEREF_HPP_INCLUDED
|
78
boost/mpl/distance.hpp
Normal file
78
boost/mpl/distance.hpp
Normal file
@ -0,0 +1,78 @@
|
||||
|
||||
#ifndef BOOST_MPL_DISTANCE_HPP_INCLUDED
|
||||
#define BOOST_MPL_DISTANCE_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/distance_fwd.hpp>
|
||||
#include <boost/mpl/iter_fold.hpp>
|
||||
#include <boost/mpl/iterator_range.hpp>
|
||||
#include <boost/mpl/long.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/tag.hpp>
|
||||
#include <boost/mpl/apply_wrap.hpp>
|
||||
#include <boost/mpl/aux_/msvc_eti_base.hpp>
|
||||
#include <boost/mpl/aux_/value_wknd.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/config/forwarding.hpp>
|
||||
#include <boost/mpl/aux_/config/static_constant.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
// default implementation for forward/bidirectional iterators
|
||||
template< typename Tag > struct distance_impl
|
||||
{
|
||||
template< typename First, typename Last > struct apply
|
||||
#if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING)
|
||||
: aux::msvc_eti_base< typename iter_fold<
|
||||
iterator_range<First,Last>
|
||||
, mpl::long_<0>
|
||||
, next<>
|
||||
>::type >
|
||||
{
|
||||
#else
|
||||
{
|
||||
typedef typename iter_fold<
|
||||
iterator_range<First,Last>
|
||||
, mpl::long_<0>
|
||||
, next<>
|
||||
>::type type;
|
||||
|
||||
BOOST_STATIC_CONSTANT(long, value =
|
||||
(iter_fold<
|
||||
iterator_range<First,Last>
|
||||
, mpl::long_<0>
|
||||
, next<>
|
||||
>::type::value)
|
||||
);
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(First)
|
||||
, typename BOOST_MPL_AUX_NA_PARAM(Last)
|
||||
>
|
||||
struct distance
|
||||
: distance_impl< typename tag<First>::type >
|
||||
::template apply<First, Last>
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(2, distance, (First, Last))
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC(2, distance)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_DISTANCE_HPP_INCLUDED
|
28
boost/mpl/distance_fwd.hpp
Normal file
28
boost/mpl/distance_fwd.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
#ifndef BOOST_MPL_DISTANCE_FWD_HPP_INCLUDED
|
||||
#define BOOST_MPL_DISTANCE_FWD_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/aux_/common_name_wknd.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
BOOST_MPL_AUX_COMMON_NAME_WKND(distance)
|
||||
|
||||
template< typename Tag > struct distance_impl;
|
||||
template< typename First, typename Last > struct distance;
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_DISTANCE_FWD_HPP_INCLUDED
|
39
boost/mpl/empty.hpp
Normal file
39
boost/mpl/empty.hpp
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
#ifndef BOOST_MPL_EMPTY_HPP_INCLUDED
|
||||
#define BOOST_MPL_EMPTY_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/empty_fwd.hpp>
|
||||
#include <boost/mpl/sequence_tag.hpp>
|
||||
#include <boost/mpl/aux_/empty_impl.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
|
||||
>
|
||||
struct empty
|
||||
: empty_impl< typename sequence_tag<Sequence>::type >
|
||||
::template apply< Sequence >
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,empty,(Sequence))
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC(1, empty)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_EMPTY_HPP_INCLUDED
|
24
boost/mpl/empty_fwd.hpp
Normal file
24
boost/mpl/empty_fwd.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
#ifndef BOOST_MPL_EMPTY_FWD_HPP_INCLUDED
|
||||
#define BOOST_MPL_EMPTY_FWD_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template< typename Tag > struct empty_impl;
|
||||
template< typename Sequence > struct empty;
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_EMPTY_FWD_HPP_INCLUDED
|
112
boost/mpl/equal.hpp
Normal file
112
boost/mpl/equal.hpp
Normal file
@ -0,0 +1,112 @@
|
||||
|
||||
#ifndef BOOST_MPL_EQUAL_HPP_INCLUDED
|
||||
#define BOOST_MPL_EQUAL_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/aux_/iter_fold_if_impl.hpp>
|
||||
#include <boost/mpl/aux_/iter_apply.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/always.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/lambda.hpp>
|
||||
#include <boost/mpl/bind.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/void.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||
#include <boost/mpl/aux_/msvc_eti_base.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
namespace aux {
|
||||
|
||||
template<
|
||||
typename Predicate
|
||||
, typename LastIterator1
|
||||
, typename LastIterator2
|
||||
>
|
||||
struct equal_pred
|
||||
{
|
||||
template<
|
||||
typename Iterator2
|
||||
, typename Iterator1
|
||||
>
|
||||
struct apply
|
||||
{
|
||||
typedef typename and_<
|
||||
not_< is_same<Iterator1,LastIterator1> >
|
||||
, not_< is_same<Iterator2,LastIterator2> >
|
||||
, aux::iter_apply2<Predicate,Iterator1,Iterator2>
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<
|
||||
typename Sequence1
|
||||
, typename Sequence2
|
||||
, typename Predicate
|
||||
>
|
||||
struct equal_impl
|
||||
{
|
||||
typedef typename begin<Sequence1>::type first1_;
|
||||
typedef typename begin<Sequence2>::type first2_;
|
||||
typedef typename end<Sequence1>::type last1_;
|
||||
typedef typename end<Sequence2>::type last2_;
|
||||
|
||||
typedef aux::iter_fold_if_impl<
|
||||
first1_
|
||||
, first2_
|
||||
, next<>
|
||||
, protect< aux::equal_pred<Predicate,last1_,last2_> >
|
||||
, void_
|
||||
, always<false_>
|
||||
> fold_;
|
||||
|
||||
typedef typename fold_::iterator iter1_;
|
||||
typedef typename fold_::state iter2_;
|
||||
typedef and_<
|
||||
is_same<iter1_,last1_>
|
||||
, is_same<iter2_,last2_>
|
||||
> result_;
|
||||
|
||||
typedef typename result_::type type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace aux
|
||||
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(Sequence1)
|
||||
, typename BOOST_MPL_AUX_NA_PARAM(Sequence2)
|
||||
, typename Predicate = is_same<_,_>
|
||||
>
|
||||
struct equal
|
||||
: aux::msvc_eti_base<
|
||||
typename aux::equal_impl<Sequence1,Sequence2,Predicate>::type
|
||||
>::type
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(2,equal,(Sequence1,Sequence2))
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC(2, equal)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_EQUAL_HPP_INCLUDED
|
50
boost/mpl/find_if.hpp
Normal file
50
boost/mpl/find_if.hpp
Normal file
@ -0,0 +1,50 @@
|
||||
|
||||
#ifndef BOOST_MPL_FIND_IF_HPP_INCLUDED
|
||||
#define BOOST_MPL_FIND_IF_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/aux_/find_if_pred.hpp>
|
||||
#include <boost/mpl/arg.hpp>
|
||||
#include <boost/mpl/iter_fold_if.hpp>
|
||||
#include <boost/mpl/aux_/common_name_wknd.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
BOOST_MPL_AUX_COMMON_NAME_WKND(find_if)
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
|
||||
, typename BOOST_MPL_AUX_NA_PARAM(Predicate)
|
||||
>
|
||||
struct find_if
|
||||
{
|
||||
typedef typename iter_fold_if<
|
||||
Sequence
|
||||
, void
|
||||
, mpl::arg<1> // ignore
|
||||
, protect< aux::find_if_pred<Predicate> >
|
||||
>::type result_;
|
||||
|
||||
typedef typename second<result_>::type type;
|
||||
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(2,find_if,(Sequence,Predicate))
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC(2,find_if)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_FIND_IF_HPP_INCLUDED
|
48
boost/mpl/fold.hpp
Normal file
48
boost/mpl/fold.hpp
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
#ifndef BOOST_MPL_FOLD_HPP_INCLUDED
|
||||
#define BOOST_MPL_FOLD_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2001-2004
|
||||
// Copyright David Abrahams 2001-2002
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/O1_size.hpp>
|
||||
#include <boost/mpl/aux_/fold_impl.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
|
||||
, typename BOOST_MPL_AUX_NA_PARAM(State)
|
||||
, typename BOOST_MPL_AUX_NA_PARAM(ForwardOp)
|
||||
>
|
||||
struct fold
|
||||
{
|
||||
typedef typename aux::fold_impl<
|
||||
::boost::mpl::O1_size<Sequence>::value
|
||||
, typename begin<Sequence>::type
|
||||
, typename end<Sequence>::type
|
||||
, State
|
||||
, ForwardOp
|
||||
>::state type;
|
||||
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(3,fold,(Sequence,State,ForwardOp))
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC(3, fold)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_FOLD_HPP_INCLUDED
|
39
boost/mpl/front.hpp
Normal file
39
boost/mpl/front.hpp
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
#ifndef BOOST_MPL_FRONT_HPP_INCLUDED
|
||||
#define BOOST_MPL_FRONT_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/front_fwd.hpp>
|
||||
#include <boost/mpl/aux_/front_impl.hpp>
|
||||
#include <boost/mpl/sequence_tag.hpp>
|
||||
#include <boost/mpl/aux_/na_spec.hpp>
|
||||
#include <boost/mpl/aux_/lambda_support.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
|
||||
>
|
||||
struct front
|
||||
: front_impl< typename sequence_tag<Sequence>::type >
|
||||
::template apply< Sequence >
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,front,(Sequence))
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC(1, front)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_FRONT_HPP_INCLUDED
|
24
boost/mpl/front_fwd.hpp
Normal file
24
boost/mpl/front_fwd.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
#ifndef BOOST_MPL_FRONT_FWD_HPP_INCLUDED
|
||||
#define BOOST_MPL_FRONT_FWD_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template< typename Tag > struct front_impl;
|
||||
template< typename Sequence > struct front;
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_FRONT_FWD_HPP_INCLUDED
|
33
boost/mpl/front_inserter.hpp
Normal file
33
boost/mpl/front_inserter.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
#ifndef BOOST_MPL_FRONT_INSERTER_HPP_INCLUDED
|
||||
#define BOOST_MPL_FRONT_INSERTER_HPP_INCLUDED
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2003-2004
|
||||
// Copyright David Abrahams 2003-2004
|
||||
//
|
||||
// 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/mpl for documentation.
|
||||
|
||||
// $Id$
|
||||
// $Date$
|
||||
// $Revision$
|
||||
|
||||
#include <boost/mpl/push_front.hpp>
|
||||
#include <boost/mpl/inserter.hpp>
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename Sequence
|
||||
>
|
||||
struct front_inserter
|
||||
: inserter< Sequence,push_front<> >
|
||||
{
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_MPL_FRONT_INSERTER_HPP_INCLUDED
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user