]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/wave/util/iteration_context.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / wave / util / iteration_context.hpp
1 /*=============================================================================
2 Boost.Wave: A Standard compliant C++ preprocessor library
3
4 http://www.boost.org/
5
6 Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
7 Software License, Version 1.0. (See accompanying file
8 LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 =============================================================================*/
10
11 #if !defined(BOOST_ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED)
12 #define BOOST_ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED
13
14 #include <cstdlib>
15 #include <stack>
16 #include <string>
17
18 #include <boost/wave/wave_config.hpp>
19 #include <boost/wave/cpp_exceptions.hpp>
20
21 // this must occur after all of the includes and before any code appears
22 #ifdef BOOST_HAS_ABI_HEADERS
23 #include BOOST_ABI_PREFIX
24 #endif
25
26 ///////////////////////////////////////////////////////////////////////////////
27 namespace boost {
28 namespace wave {
29 namespace util {
30
31 ///////////////////////////////////////////////////////////////////////////////
32 template <typename IterationContextT>
33 class iteration_context_stack
34 {
35 typedef std::stack<IterationContextT> base_type;
36
37 public:
38 typedef typename base_type::size_type size_type;
39
40 iteration_context_stack()
41 : max_include_nesting_depth(BOOST_WAVE_MAX_INCLUDE_LEVEL_DEPTH)
42 {}
43
44 void set_max_include_nesting_depth(size_type new_depth)
45 { max_include_nesting_depth = new_depth; }
46 size_type get_max_include_nesting_depth() const
47 { return max_include_nesting_depth; }
48
49 typename base_type::size_type size() const { return iter_ctx.size(); }
50 typename base_type::value_type &top() { return iter_ctx.top(); }
51 void pop() { iter_ctx.pop(); }
52
53 template <typename Context, typename PositionT>
54 void push(Context& ctx, PositionT const &pos,
55 typename base_type::value_type const &val)
56 {
57 if (iter_ctx.size() == max_include_nesting_depth) {
58 std::string buffer = std::to_string(max_include_nesting_depth);
59 BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
60 include_nesting_too_deep, buffer.c_str(), pos);
61 }
62 iter_ctx.push(val);
63 }
64
65 private:
66 size_type max_include_nesting_depth;
67 base_type iter_ctx;
68 };
69
70 ///////////////////////////////////////////////////////////////////////////////
71 } // namespace util
72 } // namespace wave
73 } // namespace boost
74
75 // the suffix header occurs after all of the code
76 #ifdef BOOST_HAS_ABI_HEADERS
77 #include BOOST_ABI_SUFFIX
78 #endif
79
80 #endif // !defined(BOOST_ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED)