diff options
Diffstat (limited to '3rdParty/Boost/src/boost/spirit/home/support/iterators/detail')
7 files changed, 1261 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp new file mode 100644 index 0000000..9df2d9c --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp @@ -0,0 +1,90 @@ +// Copyright (c) 2001, Daniel C. Nuffer +// Copyright (c) 2001-2011 Hartmut Kaiser +// +// 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) + +#if !defined(BOOST_SPIRIT_ITERATOR_BUF_ID_CHECK_POLICY_MAR_16_2007_1108AM) +#define BOOST_SPIRIT_ITERATOR_BUF_ID_CHECK_POLICY_MAR_16_2007_1108AM + +#include <boost/spirit/home/support/iterators/multi_pass_fwd.hpp> +#include <boost/spirit/home/support/iterators/detail/multi_pass.hpp> +#include <boost/config.hpp> +#include <boost/throw_exception.hpp> +#include <exception> // for std::exception + +namespace boost { namespace spirit { namespace iterator_policies +{ + /////////////////////////////////////////////////////////////////////////// + // class illegal_backtracking + // thrown by buf_id_check CheckingPolicy if an instance of an iterator is + // used after another one has invalidated the queue + /////////////////////////////////////////////////////////////////////////// + class illegal_backtracking : public std::exception + { + public: + illegal_backtracking() throw() {} + ~illegal_backtracking() throw() {} + + char const* what() const throw() + { + return "boost::spirit::multi_pass::illegal_backtracking"; + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // class buf_id_check + // Implementation of the CheckingPolicy used by multi_pass + // This policy is most effective when used together with the std_deque + // StoragePolicy. + // + // If used with the fixed_size_queue StoragePolicy, it will not detect + // iterator dereferences that are out of the range of the queue. + /////////////////////////////////////////////////////////////////////////////// + struct buf_id_check + { + /////////////////////////////////////////////////////////////////////// + struct unique //: detail::default_checking_policy + { + unique() : buf_id(0) {} + unique(unique const& x) : buf_id(x.buf_id) {} + + void swap(unique& x) + { + boost::swap(buf_id, x.buf_id); + } + + // called to verify that everything is ok. + template <typename MultiPass> + static void docheck(MultiPass const& mp) + { + if (mp.buf_id != mp.shared()->shared_buf_id) + boost::throw_exception(illegal_backtracking()); + } + + // called from multi_pass::clear_queue, so we can increment the count + template <typename MultiPass> + static void clear_queue(MultiPass& mp) + { + ++mp.shared()->shared_buf_id; + ++mp.buf_id; + } + + template <typename MultiPass> + static void destroy(MultiPass&) {} + + protected: + unsigned long buf_id; + }; + + /////////////////////////////////////////////////////////////////////// + struct shared + { + shared() : shared_buf_id(0) {} + unsigned long shared_buf_id; + }; + }; + +}}} + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/combine_policies.hpp b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/combine_policies.hpp new file mode 100644 index 0000000..cfac882 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/combine_policies.hpp @@ -0,0 +1,558 @@ +// Copyright (c) 2001-2012 Hartmut Kaiser +// +// 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) + +#if !defined(BOOST_SPIRIT_ITERATOR_COMBINE_POLICIES_APR_06_2008_0136PM) +#define BOOST_SPIRIT_ITERATOR_COMBINE_POLICIES_APR_06_2008_0136PM + +#include <boost/config.hpp> +#include <boost/type_traits/is_empty.hpp> + +namespace boost { namespace spirit { namespace iterator_policies +{ + /////////////////////////////////////////////////////////////////////////// + // The purpose of the multi_pass_unique template is to eliminate + // empty policy classes (policies not containing any data items) from the + // multiple inheritance chain. This is necessary since some compilers + // fail to apply the empty base optimization if multiple inheritance is + // involved. + // Additionally this can be used to combine separate policies into one + // single multi_pass_policy as required by the multi_pass template + /////////////////////////////////////////////////////////////////////////// + +#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + // without partial template specialization there is nothing much to do in + // terms of empty base optimization anyways... + template <typename T, typename Ownership, typename Checking, + typename Input, typename Storage> + struct multi_pass_unique + : Ownership, Checking, Input, Storage + { + multi_pass_unique() {} + multi_pass_unique(T& x) : Input(x) {} + multi_pass_unique(T const& x) : Input(x) {} + + template <typename MultiPass> + static void destroy(MultiPass& mp) + { + Ownership::destroy(mp); + Checking::destroy(mp); + Input::destroy(mp); + Storage::destroy(mp); + } + + void swap(multi_pass_unique& x) + { + this->Ownership::swap(x); + this->Checking::swap(x); + this->Input::swap(x); + this->Storage::swap(x); + } + + template <typename MultiPass> + inline static void clear_queue(MultiPass& mp) + { + Checking::clear_queue(mp); + Storage::clear_queue(mp); + } + }; +#else + /////////////////////////////////////////////////////////////////////////// + // select the correct derived classes based on if a policy is empty + template <typename T + , typename Ownership, typename Checking, typename Input, typename Storage + , bool OwnershipIsEmpty = boost::is_empty<Ownership>::value + , bool CheckingIsEmpty = boost::is_empty<Checking>::value + , bool InputIsEmpty = boost::is_empty<Input>::value> + struct multi_pass_unique; + + /////////////////////////////////////////////////////////////////////////// + template <typename T, typename Ownership, typename Checking + , typename Input, typename Storage> + struct multi_pass_unique<T, Ownership, Checking, Input, Storage + , false, false, false> + : Ownership, Checking, Input, Storage + { + multi_pass_unique() {} + multi_pass_unique(T& x) : Input(x) {} + multi_pass_unique(T const& x) : Input(x) {} + + template <typename MultiPass> + static void destroy(MultiPass& mp) + { + Ownership::destroy(mp); + Checking::destroy(mp); + Input::destroy(mp); + Storage::destroy(mp); + } + + void swap(multi_pass_unique& x) + { + this->Ownership::swap(x); + this->Checking::swap(x); + this->Input::swap(x); + this->Storage::swap(x); + } + + template <typename MultiPass> + inline static void clear_queue(MultiPass& mp) + { + Checking::clear_queue(mp); + Storage::clear_queue(mp); + } + }; + + /////////////////////////////////////////////////////////////////////////// + template <typename T, typename Ownership, typename Checking + , typename Input, typename Storage> + struct multi_pass_unique<T, Ownership, Checking, Input, Storage + , false, false, true> + : Ownership, Checking, Storage + { + multi_pass_unique() {} + multi_pass_unique(T const&) {} + + template <typename MultiPass> + static void destroy(MultiPass& mp) + { + Ownership::destroy(mp); + Checking::destroy(mp); + Input::destroy(mp); + Storage::destroy(mp); + } + + void swap(multi_pass_unique& x) + { + this->Ownership::swap(x); + this->Checking::swap(x); + this->Storage::swap(x); + } + + template <typename MultiPass> + inline static void clear_queue(MultiPass& mp) + { + Checking::clear_queue(mp); + Storage::clear_queue(mp); + } + + // implement input policy functions by forwarding to the Input type + template <typename MultiPass> + inline static void advance_input(MultiPass& mp) + { Input::advance_input(mp); } + + template <typename MultiPass> + inline static typename MultiPass::reference get_input(MultiPass& mp) + { return Input::get_input(mp); } + + template <typename MultiPass> + inline static bool input_at_eof(MultiPass const& mp) + { return Input::input_at_eof(mp); } + + template <typename MultiPass, typename TokenType> + inline static bool input_is_valid(MultiPass& mp, TokenType& curtok) + { return Input::input_is_valid(mp, curtok); } + }; + + /////////////////////////////////////////////////////////////////////////// + template <typename T, typename Ownership, typename Checking + , typename Input, typename Storage> + struct multi_pass_unique<T, Ownership, Checking, Input, Storage + , false, true, false> + : Ownership, Input, Storage + { + multi_pass_unique() {} + multi_pass_unique(T& x) : Input(x) {} + multi_pass_unique(T const& x) : Input(x) {} + + template <typename MultiPass> + static void destroy(MultiPass& mp) + { + Ownership::destroy(mp); + Input::destroy(mp); + Storage::destroy(mp); + } + + void swap(multi_pass_unique& x) + { + this->Ownership::swap(x); + this->Input::swap(x); + this->Storage::swap(x); + } + + template <typename MultiPass> + inline static void clear_queue(MultiPass& mp) + { + Checking::clear_queue(mp); + Storage::clear_queue(mp); + } + + // checking policy functions are forwarded to the Checking type + template <typename MultiPass> + inline static void docheck(MultiPass const& mp) + { Checking::docheck(mp); } + }; + + /////////////////////////////////////////////////////////////////////////// + template <typename T, typename Ownership, typename Checking + , typename Input, typename Storage> + struct multi_pass_unique<T, Ownership, Checking, Input, Storage + , false, true, true> + : Ownership, Storage + { + multi_pass_unique() {} + multi_pass_unique(T const&) {} + + template <typename MultiPass> + static void destroy(MultiPass& mp) + { + Ownership::destroy(mp); + Input::destroy(mp); + Storage::destroy(mp); + } + + void swap(multi_pass_unique& x) + { + this->Ownership::swap(x); + this->Storage::swap(x); + } + + template <typename MultiPass> + inline static void clear_queue(MultiPass& mp) + { + Checking::clear_queue(mp); + Storage::clear_queue(mp); + } + + // implement input policy functions by forwarding to the Input type + template <typename MultiPass> + inline static void advance_input(MultiPass& mp) + { Input::advance_input(mp); } + + template <typename MultiPass> + inline static typename MultiPass::reference get_input(MultiPass& mp) + { return Input::get_input(mp); } + + template <typename MultiPass> + inline static bool input_at_eof(MultiPass const& mp) + { return Input::input_at_eof(mp); } + + template <typename MultiPass, typename TokenType> + inline static bool input_is_valid(MultiPass& mp, TokenType& curtok) + { return Input::input_is_valid(mp, curtok); } + + // checking policy functions are forwarded to the Checking type + template <typename MultiPass> + inline static void docheck(MultiPass const& mp) + { Checking::docheck(mp); } + }; + + /////////////////////////////////////////////////////////////////////////// + template <typename T, typename Ownership, typename Checking + , typename Input, typename Storage> + struct multi_pass_unique<T, Ownership, Checking, Input, Storage + , true, false, false> + : Checking, Input, Storage + { + multi_pass_unique() {} + multi_pass_unique(T& x) : Input(x) {} + multi_pass_unique(T const& x) : Input(x) {} + + template <typename MultiPass> + static void destroy(MultiPass& mp) + { + Checking::destroy(mp); + Input::destroy(mp); + Storage::destroy(mp); + } + + void swap(multi_pass_unique& x) + { + this->Checking::swap(x); + this->Input::swap(x); + this->Storage::swap(x); + } + + template <typename MultiPass> + inline static void clear_queue(MultiPass& mp) + { + Checking::clear_queue(mp); + Storage::clear_queue(mp); + } + + // ownership policy functions are forwarded to the Ownership type + template <typename MultiPass> + inline static void clone(MultiPass& mp) + { Ownership::clone(mp); } + + template <typename MultiPass> + inline static bool release(MultiPass& mp) + { return Ownership::release(mp); } + + template <typename MultiPass> + inline static bool is_unique(MultiPass const& mp) + { return Ownership::is_unique(mp); } + }; + + /////////////////////////////////////////////////////////////////////////// + template <typename T, typename Ownership, typename Checking + , typename Input, typename Storage> + struct multi_pass_unique<T, Ownership, Checking, Input, Storage + , true, false, true> + : Checking, Storage + { + multi_pass_unique() {} + multi_pass_unique(T const&) {} + + template <typename MultiPass> + static void destroy(MultiPass& mp) + { + Checking::destroy(mp); + Input::destroy(mp); + Storage::destroy(mp); + } + + void swap(multi_pass_unique& x) + { + this->Checking::swap(x); + this->Storage::swap(x); + } + + template <typename MultiPass> + inline static void clear_queue(MultiPass& mp) + { + Checking::clear_queue(mp); + Storage::clear_queue(mp); + } + + // implement input policy functions by forwarding to the Input type + template <typename MultiPass> + inline static void advance_input(MultiPass& mp) + { Input::advance_input(mp); } + + template <typename MultiPass> + inline static typename MultiPass::reference get_input(MultiPass& mp) + { return Input::get_input(mp); } + + template <typename MultiPass> + inline static bool input_at_eof(MultiPass const& mp) + { return Input::input_at_eof(mp); } + + template <typename MultiPass, typename TokenType> + inline static bool input_is_valid(MultiPass& mp, TokenType& curtok) + { return Input::input_is_valid(mp, curtok); } + + // ownership policy functions are forwarded to the Ownership type + template <typename MultiPass> + inline static void clone(MultiPass& mp) + { Ownership::clone(mp); } + + template <typename MultiPass> + inline static bool release(MultiPass& mp) + { return Ownership::release(mp); } + + template <typename MultiPass> + inline static bool is_unique(MultiPass const& mp) + { return Ownership::is_unique(mp); } + }; + + /////////////////////////////////////////////////////////////////////////// + template <typename T, typename Ownership, typename Checking + , typename Input, typename Storage> + struct multi_pass_unique<T, Ownership, Checking, Input, Storage + , true, true, false> + : Input, Storage + { + multi_pass_unique() {} + multi_pass_unique(T& x) : Input(x) {} + multi_pass_unique(T const& x) : Input(x) {} + + template <typename MultiPass> + static void destroy(MultiPass& mp) + { + Input::destroy(mp); + Storage::destroy(mp); + } + + void swap(multi_pass_unique& x) + { + this->Input::swap(x); + this->Storage::swap(x); + } + + template <typename MultiPass> + inline static void clear_queue(MultiPass& mp) + { + Checking::clear_queue(mp); + Storage::clear_queue(mp); + } + + // checking policy functions are forwarded to the Checking type + template <typename MultiPass> + inline static void docheck(MultiPass const& mp) + { Checking::docheck(mp); } + + // ownership policy functions are forwarded to the Ownership type + template <typename MultiPass> + inline static void clone(MultiPass& mp) + { Ownership::clone(mp); } + + template <typename MultiPass> + inline static bool release(MultiPass& mp) + { return Ownership::release(mp); } + + template <typename MultiPass> + inline static bool is_unique(MultiPass const& mp) + { return Ownership::is_unique(mp); } + }; + + /////////////////////////////////////////////////////////////////////////// + template <typename T, typename Ownership, typename Checking + , typename Input, typename Storage> + struct multi_pass_unique<T, Ownership, Checking, Input, Storage + , true, true, true> + : Storage + { + multi_pass_unique() {} + multi_pass_unique(T const&) {} + + template <typename MultiPass> + static void destroy(MultiPass& mp) + { + Input::destroy(mp); + Storage::destroy(mp); + } + + void swap(multi_pass_unique& x) + { + this->Storage::swap(x); + } + + template <typename MultiPass> + inline static void clear_queue(MultiPass& mp) + { + Checking::clear_queue(mp); + Storage::clear_queue(mp); + } + + // implement input policy functions by forwarding to the Input type + template <typename MultiPass> + inline static void advance_input(MultiPass& mp) + { Input::advance_input(mp); } + + template <typename MultiPass> + inline static typename MultiPass::reference get_input(MultiPass& mp) + { return Input::get_input(mp); } + + template <typename MultiPass> + inline static bool input_at_eof(MultiPass const& mp) + { return Input::input_at_eof(mp); } + + template <typename MultiPass, typename TokenType> + inline static bool input_is_valid(MultiPass& mp, TokenType& curtok) + { return Input::input_is_valid(mp, curtok); } + + // checking policy functions are forwarded to the Checking type + template <typename MultiPass> + inline static void docheck(MultiPass const& mp) + { Checking::docheck(mp); } + + // ownership policy functions are forwarded to the Ownership type + template <typename MultiPass> + inline static void clone(MultiPass& mp) + { Ownership::clone(mp); } + + template <typename MultiPass> + inline static bool release(MultiPass& mp) + { return Ownership::release(mp); } + + template <typename MultiPass> + inline static bool is_unique(MultiPass const& mp) + { return Ownership::is_unique(mp); } + }; +#endif + + /////////////////////////////////////////////////////////////////////////// + // the multi_pass_shared structure is used to combine the shared data items + // of all policies into one single structure + /////////////////////////////////////////////////////////////////////////// + template<typename T, typename Ownership, typename Checking, typename Input + , typename Storage> + struct multi_pass_shared : Ownership, Checking, Input, Storage + { + explicit multi_pass_shared(T& input) : Input(input) {} + explicit multi_pass_shared(T const& input) : Input(input) {} + }; + + /////////////////////////////////////////////////////////////////////////// + // This is a default implementation of a policy class as required by the + // multi_pass template, combining 4 separate policies into one. Any other + // multi_pass policy class needs to follow the scheme as shown below. + template<typename Ownership, typename Checking, typename Input + , typename Storage> + struct default_policy + { + typedef Ownership ownership_policy; + typedef Checking checking_policy; + typedef Input input_policy; + typedef Storage storage_policy; + + /////////////////////////////////////////////////////////////////////// + template <typename T> + struct unique : multi_pass_unique<T + , typename Ownership::unique, typename Checking::unique + , typename Input::BOOST_NESTED_TEMPLATE unique<T> + , typename Storage::BOOST_NESTED_TEMPLATE unique< + typename Input::BOOST_NESTED_TEMPLATE unique<T>::value_type> > + { + typedef typename Ownership::unique ownership_policy; + typedef typename Checking::unique checking_policy; + typedef typename Input::BOOST_NESTED_TEMPLATE unique<T> + input_policy; + typedef typename Storage::BOOST_NESTED_TEMPLATE unique< + typename input_policy::value_type> storage_policy; + + typedef multi_pass_unique<T, ownership_policy, checking_policy + , input_policy, storage_policy> unique_base_type; + + unique() {} + explicit unique(T& input) : unique_base_type(input) {} + explicit unique(T const& input) : unique_base_type(input) {} + }; + + /////////////////////////////////////////////////////////////////////// + template <typename T> + struct shared : multi_pass_shared<T + , typename Ownership::shared, typename Checking::shared + , typename Input::BOOST_NESTED_TEMPLATE shared<T> + , typename Storage::BOOST_NESTED_TEMPLATE shared< + typename Input::BOOST_NESTED_TEMPLATE unique<T>::value_type> > + { + typedef typename Ownership::shared ownership_policy; + typedef typename Checking::shared checking_policy; + typedef typename Input::BOOST_NESTED_TEMPLATE shared<T> + input_policy; + typedef typename Storage::BOOST_NESTED_TEMPLATE shared< + typename Input::BOOST_NESTED_TEMPLATE unique<T>::value_type> + storage_policy; + + typedef multi_pass_shared<T, ownership_policy, checking_policy + , input_policy, storage_policy> shared_base_type; + + explicit shared(T& input) + : shared_base_type(input), inhibit_clear_queue_(false) {} + explicit shared(T const& input) + : shared_base_type(input), inhibit_clear_queue_(false) {} + + // This is needed for the correct implementation of expectation + // points. Normally expectation points flush any multi_pass + // iterator they may act on, but if the corresponding error handler + // is of type 'retry' no flushing of the internal buffers should be + // executed (even if explicitly requested). + bool inhibit_clear_queue_; + }; + }; + +}}} + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/multi_pass.hpp b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/multi_pass.hpp new file mode 100644 index 0000000..088b39a --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/multi_pass.hpp @@ -0,0 +1,132 @@ +// Copyright (c) 2001 Daniel C. Nuffer +// Copyright (c) 2001-2011 Hartmut Kaiser +// +// 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) + +#if !defined(BOOST_SPIRIT_ITERATOR_MULTI_PASS_MAR_16_2007_1122AM) +#define BOOST_SPIRIT_ITERATOR_MULTI_PASS_MAR_16_2007_1122AM + +#include <boost/config.hpp> +#include <boost/spirit/home/support/iterators/multi_pass_fwd.hpp> +#include <boost/iterator.hpp> +#include <boost/mpl/bool.hpp> +#include <iterator> +#include <algorithm> + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { namespace detail +{ +#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + /////////////////////////////////////////////////////////////////////////// + // Meta-function to generate a std::iterator<> base class for multi_pass. + // This is used mainly to improve conformance of compilers not supporting + // PTS and thus relying on inheritance to recognize an iterator. + // + // We are using boost::iterator<> because it offers an automatic + // workaround for broken std::iterator<> implementations. + /////////////////////////////////////////////////////////////////////////// + template <typename T, typename InputPolicy> + struct iterator_base_creator + { + typedef typename InputPolicy::BOOST_NESTED_TEMPLATE unique<T> input_type; + + typedef boost::iterator < + std::forward_iterator_tag + , typename input_type::value_type + , typename input_type::difference_type + , typename input_type::pointer + , typename input_type::reference + > type; + }; +#endif + + /////////////////////////////////////////////////////////////////////////// + // Default implementations of the different policies to be used with a + // multi_pass iterator + /////////////////////////////////////////////////////////////////////////// + struct default_input_policy + { + default_input_policy() {} + + template <typename Functor> + default_input_policy(Functor const&) {} + + template <typename MultiPass> + static void destroy(MultiPass&) {} + + void swap(default_input_policy&) {} + + template <typename MultiPass, typename TokenType> + static void advance_input(MultiPass& mp); + + template <typename MultiPass> + static typename MultiPass::reference get_input(MultiPass& mp); + + template <typename MultiPass> + static bool input_at_eof(MultiPass const& mp); + + template <typename MultiPass, typename TokenType> + static bool input_is_valid(MultiPass& mp, TokenType& curtok); + }; + + struct default_ownership_policy + { + template <typename MultiPass> + static void destroy(MultiPass&) {} + + void swap(default_ownership_policy&) {} + + template <typename MultiPass> + static void clone(MultiPass&) {} + + template <typename MultiPass> + static bool release(MultiPass& mp); + + template <typename MultiPass> + static bool is_unique(MultiPass const& mp); + }; + + struct default_storage_policy + { + template <typename MultiPass> + static void destroy(MultiPass&) {} + + void swap(default_storage_policy&) {} + + template <typename MultiPass> + static typename MultiPass::reference dereference(MultiPass const& mp); + + template <typename MultiPass> + static void increment(MultiPass&) {} + + template <typename MultiPass> + static void clear_queue(MultiPass&) {} + + template <typename MultiPass> + static bool is_eof(MultiPass const& mp); + + template <typename MultiPass> + static bool equal_to(MultiPass const& mp, MultiPass const& x); + + template <typename MultiPass> + static bool less_than(MultiPass const& mp, MultiPass const& x); + }; + + struct default_checking_policy + { + template <typename MultiPass> + static void destroy(MultiPass&) {} + + void swap(default_checking_policy&) {} + + template <typename MultiPass> + static void docheck(MultiPass const&) {} + + template <typename MultiPass> + static void clear_queue(MultiPass&) {} + }; + +}}} + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/no_check_policy.hpp b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/no_check_policy.hpp new file mode 100644 index 0000000..8f4a26d --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/no_check_policy.hpp @@ -0,0 +1,31 @@ +// Copyright (c) 2001 Daniel C. Nuffer +// Copyright (c) 2001-2011 Hartmut Kaiser +// +// 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) + +#if !defined(BOOST_SPIRIT_ITERATOR_NO_CHECK_POLICY_MAR_16_2007_1121AM) +#define BOOST_SPIRIT_ITERATOR_NO_CHECK_POLICY_MAR_16_2007_1121AM + +#include <boost/spirit/home/support/iterators/multi_pass_fwd.hpp> +#include <boost/spirit/home/support/iterators/detail/multi_pass.hpp> + +namespace boost { namespace spirit { namespace iterator_policies +{ + /////////////////////////////////////////////////////////////////////////// + // class no_check + // Implementation of the CheckingPolicy used by multi_pass + // It does not do anything :-) + /////////////////////////////////////////////////////////////////////////// + struct no_check + { + /////////////////////////////////////////////////////////////////////// + struct unique : public detail::default_checking_policy {}; + + /////////////////////////////////////////////////////////////////////// + struct shared {}; + }; + +}}} + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/ref_counted_policy.hpp b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/ref_counted_policy.hpp new file mode 100644 index 0000000..723bbee --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/ref_counted_policy.hpp @@ -0,0 +1,79 @@ +// Copyright (c) 2001 Daniel C. Nuffer +// Copyright (c) 2001-2011 Hartmut Kaiser +// +// 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) + +#if !defined(BOOST_SPIRIT_ITERATOR_REF_COUNTED_POLICY_MAR_16_2007_1108AM) +#define BOOST_SPIRIT_ITERATOR_REF_COUNTED_POLICY_MAR_16_2007_1108AM + +#include <boost/spirit/home/support/iterators/multi_pass_fwd.hpp> +#include <boost/spirit/home/support/iterators/detail/multi_pass.hpp> +#if defined(BOOST_HAS_THREADS) +#include <boost/detail/atomic_count.hpp> +#endif +#include <cstdlib> + +namespace boost { namespace spirit { namespace iterator_policies +{ + /////////////////////////////////////////////////////////////////////////// + // class ref_counted + // Implementation of an OwnershipPolicy used by multi_pass. + // + // Implementation modified from RefCounted class from the Loki library by + // Andrei Alexandrescu. + /////////////////////////////////////////////////////////////////////////// + struct ref_counted + { + /////////////////////////////////////////////////////////////////////// + struct unique // : detail::default_ownership_policy + { + void swap(unique&) {} + + // clone is called when a copy of the iterator is made, so + // increment the ref-count. + template <typename MultiPass> + static void clone(MultiPass& mp) + { + if (0 != mp.shared()) + ++mp.shared()->count; + } + + // called when a copy is deleted. Decrement the ref-count. Return + // value of true indicates that the last copy has been released. + template <typename MultiPass> + static bool release(MultiPass& mp) + { + return 0 != mp.shared() && 0 == --mp.shared()->count; + } + + // returns true if there is only one iterator in existence. + // std_deque StoragePolicy will free it's buffered data if this + // returns true. + template <typename MultiPass> + static bool is_unique(MultiPass const& mp) + { + return 0 == mp.shared() || 1 == mp.shared()->count; + } + + template <typename MultiPass> + static void destroy(MultiPass&) {} + }; + + //////////////////////////////////////////////////////////////////////// + struct shared + { + shared() : count(1) {} + +#if defined(BOOST_HAS_THREADS) + boost::detail::atomic_count count; +#else + std::size_t count; +#endif + }; + + }; + +}}} + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/split_functor_input_policy.hpp b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/split_functor_input_policy.hpp new file mode 100644 index 0000000..711ae90 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/split_functor_input_policy.hpp @@ -0,0 +1,201 @@ +// Copyright (c) 2001-2011 Hartmut Kaiser +// +// 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) + +#if !defined(BOOST_SPIRIT_ITERATOR_SPLIT_FUNCTOR_INPUT_POLICY_JAN_17_2008_0103PM) +#define BOOST_SPIRIT_ITERATOR_SPLIT_FUNCTOR_INPUT_POLICY_JAN_17_2008_0103PM + +#include <boost/spirit/home/support/iterators/multi_pass_fwd.hpp> +#include <boost/spirit/home/support/iterators/detail/multi_pass.hpp> +#include <boost/assert.hpp> +#include <boost/type_traits/is_empty.hpp> + +namespace boost { namespace spirit { namespace iterator_policies +{ + namespace split_functor_input_is_valid_test_ + { + template <typename Token> + inline bool token_is_valid(Token const&) + { + return true; + } + } + + /////////////////////////////////////////////////////////////////////////// + // class split_functor_input + // Implementation of the InputPolicy used by multi_pass + // split_functor_input gets tokens from a functor + // + // This policy should be used when the functor holds two parts of data: a + // unique part (unique for each instance of the iterator) and a shared + // part (to be shared between the different copies of the same iterator). + // Using this policy allows to merge the shared part of the functor with + // the shared part of the iterator data, saving one pointer and one + // allocation per iterator instance. + // + // The Functor template parameter of this policy is expected to be a + // std::pair<unique, shared>, where 'unique' and 'shared' represent the + // respective parts of the functor itself. + // + // Note: the unique part of the functor must have a typedef for result_type + // It also must have a static variable of type result_type defined + // to represent EOF that is called eof. + // + /////////////////////////////////////////////////////////////////////////// + struct split_functor_input + { + /////////////////////////////////////////////////////////////////////// + template <typename Functor + , bool FunctorIsEmpty = is_empty<typename Functor::first_type>::value> + class unique; + + // the unique part of the functor is empty, do not include the functor + // as a member at all to avoid unnecessary padding bytes to be included + // into the generated structure + template <typename Functor> + class unique<Functor, true> // : public detail::default_input_policy + { + protected: + typedef typename Functor::first_type functor_type; + typedef typename functor_type::result_type result_type; + + public: + typedef result_type value_type; + typedef std::ptrdiff_t difference_type; + typedef std::ptrdiff_t distance_type; + typedef result_type const* pointer; + typedef result_type const& reference; + + protected: + unique() {} + explicit unique(Functor const&) {} + + public: + void swap(unique&) {} + + // get the next token + template <typename MultiPass> + static typename MultiPass::reference get_input(MultiPass& mp) + { + value_type& curtok = mp.shared()->curtok; + using namespace split_functor_input_is_valid_test_; + if (!token_is_valid(curtok)) + functor_type::get_next(mp, curtok); + return curtok; + } + + template <typename MultiPass> + static void advance_input(MultiPass& mp) + { + functor_type::get_next(mp, mp.shared()->curtok); + } + + // test, whether we reached the end of the underlying stream + template <typename MultiPass> + static bool input_at_eof(MultiPass const& mp) + { + return mp.shared()->curtok == functor_type::eof; + } + + template <typename MultiPass> + static bool input_is_valid(MultiPass const&, value_type const& t) + { + using namespace split_functor_input_is_valid_test_; + return token_is_valid(t); + } + + template <typename MultiPass> + static void destroy(MultiPass& mp) + { + functor_type::destroy(mp); + } + }; + + // the unique part of the functor is non-empty + template <typename Functor> + class unique<Functor, false> : public unique<Functor, true> + { + protected: + typedef typename Functor::first_type functor_type; + typedef typename functor_type::result_type result_type; + + protected: + unique() {} + explicit unique(Functor const& x) : ftor(x.first) {} + + void swap(unique& x) + { + boost::swap(ftor, x.ftor); + } + + public: + typedef result_type value_type; + typedef std::ptrdiff_t difference_type; + typedef std::ptrdiff_t distance_type; + typedef result_type const* pointer; + typedef result_type const& reference; + + public: + // get the next token + template <typename MultiPass> + static typename MultiPass::reference get_input(MultiPass& mp) + { + value_type& curtok = mp.shared()->curtok; + using namespace split_functor_input_is_valid_test_; + if (!token_is_valid(curtok)) + functor_type::get_next(mp, curtok); + return curtok; + } + + template <typename MultiPass> + static void advance_input(MultiPass& mp) + { + mp.ftor.get_next(mp, mp.shared()->curtok); + } + + template <typename MultiPass> + static bool input_is_valid(MultiPass const&, value_type const& t) + { + using namespace split_functor_input_is_valid_test_; + return token_is_valid(t); + } + + // test, whether we reached the end of the underlying stream + template <typename MultiPass> + static bool input_at_eof(MultiPass const& mp) + { + return mp.shared()->curtok == mp.ftor.eof; + } + + typename Functor::first_type& get_functor() const + { + return ftor; + } + + mutable functor_type ftor; + }; + + /////////////////////////////////////////////////////////////////////// + template <typename Functor> + struct shared + { + protected: + typedef typename Functor::first_type functor_type; + typedef typename functor_type::result_type result_type; + + public: + explicit shared(Functor const& x) : ftor(x.second), curtok(0) {} + + mutable typename Functor::second_type ftor; + result_type curtok; + + private: + // silence MSVC warning C4512: assignment operator could not be generated + shared& operator= (shared const&); + }; + }; + +}}} + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/split_std_deque_policy.hpp b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/split_std_deque_policy.hpp new file mode 100644 index 0000000..402956b --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/support/iterators/detail/split_std_deque_policy.hpp @@ -0,0 +1,170 @@ +// Copyright (c) 2001 Daniel C. Nuffer +// Copyright (c) 2001-2011 Hartmut Kaiser +// +// 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) + +#if !defined(BOOST_SPIRIT_ITERATOR_SPLIT_DEQUE_POLICY_APR_06_2008_0138PM) +#define BOOST_SPIRIT_ITERATOR_SPLIT_DEQUE_POLICY_APR_06_2008_0138PM + +#include <boost/spirit/home/support/iterators/multi_pass_fwd.hpp> +#include <boost/spirit/home/support/iterators/detail/multi_pass.hpp> +#include <boost/assert.hpp> +#include <vector> + +namespace boost { namespace spirit { namespace iterator_policies +{ + /////////////////////////////////////////////////////////////////////////// + // class split_std_deque + // + // Implementation of the StoragePolicy used by multi_pass + // This stores all data in a std::vector (despite its name), and keeps an + // offset to the current position. It stores all the data unless there is + // only one iterator using the queue. + // + /////////////////////////////////////////////////////////////////////////// + struct split_std_deque + { + enum { threshold = 16 }; + + /////////////////////////////////////////////////////////////////////// + template <typename Value> + class unique //: public detail::default_storage_policy + { + private: + typedef std::vector<Value> queue_type; + + protected: + unique() : queued_position(0) {} + + unique(unique const& x) + : queued_position(x.queued_position) {} + + void swap(unique& x) + { + boost::swap(queued_position, x.queued_position); + } + + // This is called when the iterator is dereferenced. It's a + // template method so we can recover the type of the multi_pass + // iterator and call advance_input and input_is_valid. + template <typename MultiPass> + static typename MultiPass::reference + dereference(MultiPass const& mp) + { + queue_type& queue = mp.shared()->queued_elements; + typename queue_type::size_type size = queue.size(); + + BOOST_ASSERT(mp.queued_position <= size); + + if (mp.queued_position == size) + { + // check if this is the only iterator + if (size >= threshold && MultiPass::is_unique(mp)) + { + // free up the memory used by the queue. + queue.clear(); + mp.queued_position = 0; + } + return MultiPass::get_input(mp); + } + + return queue[mp.queued_position]; + } + + // This is called when the iterator is incremented. It's a template + // method so we can recover the type of the multi_pass iterator + // and call is_unique and advance_input. + template <typename MultiPass> + static void increment(MultiPass& mp) + { + queue_type& queue = mp.shared()->queued_elements; + typename queue_type::size_type size = queue.size(); + + BOOST_ASSERT(mp.queued_position <= size); + +// // do not increment iterator as long as the current token is +// // invalid +// if (size > 0 && !MultiPass::input_is_valid(mp, queue[mp.queued_position-1])) +// return; + + if (mp.queued_position == size) + { + // check if this is the only iterator + if (size >= threshold && MultiPass::is_unique(mp)) + { + // free up the memory used by the queue. we avoid + // clearing the queue on every increment, though, + // because this would be too time consuming + queue.clear(); + mp.queued_position = 0; + } + else + { + queue.push_back(MultiPass::get_input(mp)); + ++mp.queued_position; + } + MultiPass::advance_input(mp); + } + else + { + ++mp.queued_position; + } + } + + // called to forcibly clear the queue + template <typename MultiPass> + static void clear_queue(MultiPass& mp) + { + mp.shared()->queued_elements.clear(); + mp.queued_position = 0; + } + + // called to determine whether the iterator is an eof iterator + template <typename MultiPass> + static bool is_eof(MultiPass const& mp) + { + return mp.queued_position == mp.shared()->queued_elements.size() + && MultiPass::input_at_eof(mp); + } + + // called by operator== + template <typename MultiPass> + static bool equal_to(MultiPass const& mp, MultiPass const& x) + { + return mp.queued_position == x.queued_position; + } + + // called by operator< + template <typename MultiPass> + static bool less_than(MultiPass const& mp, MultiPass const& x) + { + return mp.queued_position < x.queued_position; + } + + template <typename MultiPass> + static void destroy(MultiPass&) {} + + protected: + mutable typename queue_type::size_type queued_position; + }; + + /////////////////////////////////////////////////////////////////////// + template <typename Value> + struct shared + { + shared() + { + queued_elements.reserve(threshold); + } + + typedef std::vector<Value> queue_type; + queue_type queued_elements; + }; + + }; // split_std_deque + +}}} + +#endif + |