annotate DEPENDENCIES/generic/include/boost/wave/util/iteration_context.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*=============================================================================
Chris@16 2 Boost.Wave: A Standard compliant C++ preprocessor library
Chris@16 3
Chris@16 4 http://www.boost.org/
Chris@16 5
Chris@16 6 Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
Chris@16 7 Software License, Version 1.0. (See accompanying file
Chris@16 8 LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 =============================================================================*/
Chris@16 10
Chris@16 11 #if !defined(ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED)
Chris@16 12 #define ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED
Chris@16 13
Chris@16 14 #include <cstdlib>
Chris@16 15 #include <cstdio>
Chris@16 16 #include <stack>
Chris@16 17
Chris@16 18 #include <boost/wave/wave_config.hpp>
Chris@16 19 #include <boost/wave/cpp_exceptions.hpp>
Chris@16 20
Chris@16 21 // this must occur after all of the includes and before any code appears
Chris@16 22 #ifdef BOOST_HAS_ABI_HEADERS
Chris@16 23 #include BOOST_ABI_PREFIX
Chris@16 24 #endif
Chris@16 25
Chris@16 26 ///////////////////////////////////////////////////////////////////////////////
Chris@16 27 namespace boost {
Chris@16 28 namespace wave {
Chris@16 29 namespace util {
Chris@16 30
Chris@16 31 ///////////////////////////////////////////////////////////////////////////////
Chris@16 32 template <typename IterationContextT>
Chris@16 33 class iteration_context_stack
Chris@16 34 {
Chris@16 35 typedef std::stack<IterationContextT> base_type;
Chris@16 36
Chris@16 37 public:
Chris@16 38 typedef typename base_type::size_type size_type;
Chris@16 39
Chris@16 40 iteration_context_stack()
Chris@16 41 : max_include_nesting_depth(BOOST_WAVE_MAX_INCLUDE_LEVEL_DEPTH)
Chris@16 42 {}
Chris@16 43
Chris@16 44 void set_max_include_nesting_depth(size_type new_depth)
Chris@16 45 { max_include_nesting_depth = new_depth; }
Chris@16 46 size_type get_max_include_nesting_depth() const
Chris@16 47 { return max_include_nesting_depth; }
Chris@16 48
Chris@16 49 typename base_type::size_type size() const { return iter_ctx.size(); }
Chris@16 50 typename base_type::value_type &top() { return iter_ctx.top(); }
Chris@16 51 void pop() { iter_ctx.pop(); }
Chris@16 52
Chris@16 53 template <typename Context, typename PositionT>
Chris@16 54 void push(Context& ctx, PositionT const &pos,
Chris@16 55 typename base_type::value_type const &val)
Chris@16 56 {
Chris@16 57 if (iter_ctx.size() == max_include_nesting_depth) {
Chris@16 58 char buffer[22]; // 21 bytes holds all NUL-terminated unsigned 64-bit numbers
Chris@16 59
Chris@16 60 using namespace std; // for some systems sprintf is in namespace std
Chris@16 61 sprintf(buffer, "%d", (int)max_include_nesting_depth);
Chris@16 62 BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
Chris@16 63 include_nesting_too_deep, buffer, pos);
Chris@16 64 }
Chris@16 65 iter_ctx.push(val);
Chris@16 66 }
Chris@16 67
Chris@16 68 private:
Chris@16 69 size_type max_include_nesting_depth;
Chris@16 70 base_type iter_ctx;
Chris@16 71 };
Chris@16 72
Chris@16 73 ///////////////////////////////////////////////////////////////////////////////
Chris@16 74 } // namespace util
Chris@16 75 } // namespace wave
Chris@16 76 } // namespace boost
Chris@16 77
Chris@16 78 // the suffix header occurs after all of the code
Chris@16 79 #ifdef BOOST_HAS_ABI_HEADERS
Chris@16 80 #include BOOST_ABI_SUFFIX
Chris@16 81 #endif
Chris@16 82
Chris@16 83 #endif // !defined(ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED)