nuclear@0: nuclear@0: #ifndef BOOST_FOREACH nuclear@0: nuclear@0: /////////////////////////////////////////////////////////////////////////////// nuclear@0: // A stripped down version of FOREACH for nuclear@0: // illustration purposes. NOT FOR GENERAL USE. nuclear@0: // For a complete implementation, see BOOST_FOREACH at nuclear@0: // http://boost-sandbox.sourceforge.net/vault/index.php?directory=eric_niebler nuclear@0: // nuclear@0: // Copyright 2004 Eric Niebler. nuclear@0: // Distributed under the Boost Software License, Version 1.0. (See nuclear@0: // accompanying file LICENSE_1_0.txt or copy at nuclear@0: // http://www.boost.org/LICENSE_1_0.txt) nuclear@0: // nuclear@0: // Adapted to Assimp November 29th, 2008 (Alexander Gessler). nuclear@0: // Added code to handle both const and non-const iterators, simplified some nuclear@0: // parts. nuclear@0: /////////////////////////////////////////////////////////////////////////////// nuclear@0: nuclear@0: namespace boost { nuclear@0: namespace foreach_detail { nuclear@0: nuclear@0: /////////////////////////////////////////////////////////////////////////////// nuclear@0: // auto_any nuclear@0: nuclear@0: struct auto_any_base nuclear@0: { nuclear@0: operator bool() const { return false; } nuclear@0: }; nuclear@0: nuclear@0: template nuclear@0: struct auto_any : auto_any_base nuclear@0: { nuclear@0: auto_any(T const& t) : item(t) {} nuclear@0: mutable T item; nuclear@0: }; nuclear@0: nuclear@0: template nuclear@0: T& auto_any_cast(auto_any_base const& any) nuclear@0: { nuclear@0: return static_cast const&>(any).item; nuclear@0: } nuclear@0: nuclear@0: /////////////////////////////////////////////////////////////////////////////// nuclear@0: // FOREACH helper function nuclear@0: nuclear@0: template nuclear@0: auto_any begin(T const& t) nuclear@0: { nuclear@0: return t.begin(); nuclear@0: } nuclear@0: nuclear@0: template nuclear@0: auto_any end(T const& t) nuclear@0: { nuclear@0: return t.end(); nuclear@0: } nuclear@0: nuclear@0: // iterator nuclear@0: template nuclear@0: bool done(auto_any_base const& cur, auto_any_base const& end, T&) nuclear@0: { nuclear@0: typedef typename T::iterator iter_type; nuclear@0: return auto_any_cast(cur) == auto_any_cast(end); nuclear@0: } nuclear@0: nuclear@0: template nuclear@0: void next(auto_any_base const& cur, T&) nuclear@0: { nuclear@0: ++auto_any_cast(cur); nuclear@0: } nuclear@0: nuclear@0: template nuclear@0: typename T::reference deref(auto_any_base const& cur, T&) nuclear@0: { nuclear@0: return *auto_any_cast(cur); nuclear@0: } nuclear@0: nuclear@0: template nuclear@0: typename T::const_reference deref(auto_any_base const& cur, const T&) nuclear@0: { nuclear@0: return *auto_any_cast(cur); nuclear@0: } nuclear@0: nuclear@0: } // end foreach_detail nuclear@0: nuclear@0: /////////////////////////////////////////////////////////////////////////////// nuclear@0: // FOREACH nuclear@0: nuclear@0: #define BOOST_FOREACH(item, container) \ nuclear@0: if(boost::foreach_detail::auto_any_base const& foreach_magic_b = boost::foreach_detail::begin(container)) {} else \ nuclear@0: if(boost::foreach_detail::auto_any_base const& foreach_magic_e = boost::foreach_detail::end(container)) {} else \ nuclear@0: for(;!boost::foreach_detail::done(foreach_magic_b,foreach_magic_e,container); boost::foreach_detail::next(foreach_magic_b,container)) \ nuclear@0: if (bool ugly_and_unique_break = false) {} else \ nuclear@0: for(item = boost::foreach_detail::deref(foreach_magic_b,container); !ugly_and_unique_break; ugly_and_unique_break = true) nuclear@0: nuclear@0: } // end boost nuclear@0: nuclear@0: #endif