Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/wave/util/iteration_context.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
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(ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED) | |
12 #define ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED | |
13 | |
14 #include <cstdlib> | |
15 #include <cstdio> | |
16 #include <stack> | |
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 char buffer[22]; // 21 bytes holds all NUL-terminated unsigned 64-bit numbers | |
59 | |
60 using namespace std; // for some systems sprintf is in namespace std | |
61 sprintf(buffer, "%d", (int)max_include_nesting_depth); | |
62 BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, | |
63 include_nesting_too_deep, buffer, pos); | |
64 } | |
65 iter_ctx.push(val); | |
66 } | |
67 | |
68 private: | |
69 size_type max_include_nesting_depth; | |
70 base_type iter_ctx; | |
71 }; | |
72 | |
73 /////////////////////////////////////////////////////////////////////////////// | |
74 } // namespace util | |
75 } // namespace wave | |
76 } // namespace boost | |
77 | |
78 // the suffix header occurs after all of the code | |
79 #ifdef BOOST_HAS_ABI_HEADERS | |
80 #include BOOST_ABI_SUFFIX | |
81 #endif | |
82 | |
83 #endif // !defined(ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED) |