]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/io/server/src/stack.hh
update
[l4.git] / l4 / pkg / io / server / src / stack.hh
1 /* A Bison parser, made by GNU Bison 2.7.12-4996.  */
2
3 /* Stack handling for Bison parsers in C++
4    
5       Copyright (C) 2002-2013 Free Software Foundation, Inc.
6    
7    This program is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20 /* As a special exception, you may create a larger work that contains
21    part or all of the Bison parser skeleton and distribute that work
22    under terms of your choice, so long as that work isn't itself a
23    parser generator using the skeleton or a modified version thereof
24    as a parser skeleton.  Alternatively, if you modify or redistribute
25    the parser skeleton itself, you may (at your option) remove this
26    special exception, which will cause the skeleton and the resulting
27    Bison output files to be licensed under the GNU General Public
28    License without this special exception.
29    
30    This special exception was added by the Free Software Foundation in
31    version 2.2 of Bison.  */
32
33 /**
34  ** \file stack.hh
35  ** Define the cfg::stack class.
36  */
37
38 #ifndef YY_CFG_STACK_HH_INCLUDED
39 # define YY_CFG_STACK_HH_INCLUDED
40
41 # include <deque>
42
43
44 namespace cfg {
45 /* Line 34 of stack.hh  */
46 #line 47 "stack.hh"
47   template <class T, class S = std::deque<T> >
48   class stack
49   {
50   public:
51     // Hide our reversed order.
52     typedef typename S::reverse_iterator iterator;
53     typedef typename S::const_reverse_iterator const_iterator;
54
55     stack () : seq_ ()
56     {
57     }
58
59     stack (unsigned int n) : seq_ (n)
60     {
61     }
62
63     inline
64     T&
65     operator [] (unsigned int i)
66     {
67       return seq_[i];
68     }
69
70     inline
71     const T&
72     operator [] (unsigned int i) const
73     {
74       return seq_[i];
75     }
76
77     inline
78     void
79     push (const T& t)
80     {
81       seq_.push_front (t);
82     }
83
84     inline
85     void
86     pop (unsigned int n = 1)
87     {
88       for (; n; --n)
89         seq_.pop_front ();
90     }
91
92     void
93     clear ()
94     {
95       seq_.clear ();
96     }
97
98     inline
99     unsigned int
100     height () const
101     {
102       return seq_.size ();
103     }
104
105     inline const_iterator begin () const { return seq_.rbegin (); }
106     inline const_iterator end () const { return seq_.rend (); }
107
108   private:
109     stack (const stack&);
110     stack& operator= (const stack&);
111     S seq_;
112   };
113
114   /// Present a slice of the top of a stack.
115   template <class T, class S = stack<T> >
116   class slice
117   {
118   public:
119     slice (const S& stack, unsigned int range)
120       : stack_ (stack)
121       , range_ (range)
122     {
123     }
124
125     inline
126     const T&
127     operator [] (unsigned int i) const
128     {
129       return stack_[range_ - i];
130     }
131
132   private:
133     const S& stack_;
134     unsigned int range_;
135   };
136
137 } // cfg
138 /* Line 124 of stack.hh  */
139 #line 140 "stack.hh"
140
141 #endif /* !YY_CFG_STACK_HH_INCLUDED  */