Chris@16: /*============================================================================= Chris@16: Boost.Wave: A Standard compliant C++ preprocessor library Chris@16: Chris@16: http://www.boost.org/ Chris@16: Chris@16: Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost Chris@16: Software License, Version 1.0. (See accompanying file Chris@16: LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: =============================================================================*/ Chris@16: Chris@16: #if !defined(ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED) Chris@16: #define ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: // this must occur after all of the includes and before any code appears Chris@16: #ifdef BOOST_HAS_ABI_HEADERS Chris@16: #include BOOST_ABI_PREFIX Chris@16: #endif Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: namespace boost { Chris@16: namespace wave { Chris@16: namespace util { Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: template Chris@16: class iteration_context_stack Chris@16: { Chris@16: typedef std::stack base_type; Chris@16: Chris@16: public: Chris@16: typedef typename base_type::size_type size_type; Chris@16: Chris@16: iteration_context_stack() Chris@16: : max_include_nesting_depth(BOOST_WAVE_MAX_INCLUDE_LEVEL_DEPTH) Chris@16: {} Chris@16: Chris@16: void set_max_include_nesting_depth(size_type new_depth) Chris@16: { max_include_nesting_depth = new_depth; } Chris@16: size_type get_max_include_nesting_depth() const Chris@16: { return max_include_nesting_depth; } Chris@16: Chris@16: typename base_type::size_type size() const { return iter_ctx.size(); } Chris@16: typename base_type::value_type &top() { return iter_ctx.top(); } Chris@16: void pop() { iter_ctx.pop(); } Chris@16: Chris@16: template Chris@16: void push(Context& ctx, PositionT const &pos, Chris@16: typename base_type::value_type const &val) Chris@16: { Chris@16: if (iter_ctx.size() == max_include_nesting_depth) { Chris@16: char buffer[22]; // 21 bytes holds all NUL-terminated unsigned 64-bit numbers Chris@16: Chris@16: using namespace std; // for some systems sprintf is in namespace std Chris@16: sprintf(buffer, "%d", (int)max_include_nesting_depth); Chris@16: BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, Chris@16: include_nesting_too_deep, buffer, pos); Chris@16: } Chris@16: iter_ctx.push(val); Chris@16: } Chris@16: Chris@16: private: Chris@16: size_type max_include_nesting_depth; Chris@16: base_type iter_ctx; Chris@16: }; Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: } // namespace util Chris@16: } // namespace wave Chris@16: } // namespace boost Chris@16: Chris@16: // the suffix header occurs after all of the code Chris@16: #ifdef BOOST_HAS_ABI_HEADERS Chris@16: #include BOOST_ABI_SUFFIX Chris@16: #endif Chris@16: Chris@16: #endif // !defined(ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED)