LCOV - code coverage report
Current view: top level - builds/barbot/Cosmos/build/src/ModelGenerator/LhaParser - stack.hh (source / functions) Hit Total Coverage
Test: coverage.info Lines: 27 31 87.1 %
Date: 2021-06-16 15:43:28 Functions: 10 12 83.3 %

          Line data    Source code
       1             : // A Bison parser, made by GNU Bison 3.0.4.
       2             : 
       3             : // Stack handling for Bison parsers in C++
       4             : 
       5             : // Copyright (C) 2002-2015 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 lha::stack class.
      36             :  */
      37             : 
      38             : #ifndef YY_LHA_STACK_HH_INCLUDED
      39             : # define YY_LHA_STACK_HH_INCLUDED
      40             : 
      41             : # include <vector>
      42             : 
      43             : 
      44             : namespace lha {
      45             : #line 46 "stack.hh" // stack.hh:132
      46             :   template <class T, class S = std::vector<T> >
      47          29 :   class stack
      48             :   {
      49             :   public:
      50             :     // Hide our reversed order.
      51             :     typedef typename S::reverse_iterator iterator;
      52             :     typedef typename S::const_reverse_iterator const_iterator;
      53             : 
      54          29 :     stack ()
      55          29 :       : seq_ ()
      56             :     {
      57          29 :       seq_.reserve (200);
      58          29 :     }
      59             : 
      60             :     stack (unsigned int n)
      61             :       : seq_ (n)
      62             :     {}
      63             : 
      64             :     inline
      65             :     T&
      66       75758 :     operator[] (unsigned int i)
      67             :     {
      68       75758 :       return seq_[seq_.size () - 1 - i];
      69             :     }
      70             : 
      71             :     inline
      72             :     const T&
      73       12434 :     operator[] (unsigned int i) const
      74             :     {
      75       12434 :       return seq_[seq_.size () - 1 - i];
      76             :     }
      77             : 
      78             :     /// Steal the contents of \a t.
      79             :     ///
      80             :     /// Close to move-semantics.
      81             :     inline
      82             :     void
      83       16104 :     push (T& t)
      84             :     {
      85       16104 :       seq_.push_back (T());
      86       16104 :       operator[](0).move (t);
      87       16104 :     }
      88             : 
      89             :     inline
      90             :     void
      91       22387 :     pop (unsigned int n = 1)
      92             :     {
      93       38462 :       for (; n; --n)
      94       16075 :         seq_.pop_back ();
      95        6312 :     }
      96             : 
      97             :     void
      98          29 :     clear ()
      99             :     {
     100          29 :       seq_.clear ();
     101          29 :     }
     102             : 
     103             :     inline
     104             :     typename S::size_type
     105          87 :     size () const
     106             :     {
     107          87 :       return seq_.size ();
     108             :     }
     109             : 
     110             :     inline
     111             :     const_iterator
     112           0 :     begin () const
     113             :     {
     114           0 :       return seq_.rbegin ();
     115             :     }
     116             : 
     117             :     inline
     118             :     const_iterator
     119           0 :     end () const
     120             :     {
     121           0 :       return seq_.rend ();
     122             :     }
     123             : 
     124             :   private:
     125             :     stack (const stack&);
     126             :     stack& operator= (const stack&);
     127             :     /// The wrapped container.
     128             :     S seq_;
     129             :   };
     130             : 
     131             :   /// Present a slice of the top of a stack.
     132             :   template <class T, class S = stack<T> >
     133             :   class slice
     134             :   {
     135             :   public:
     136        6225 :     slice (const S& stack, unsigned int range)
     137             :       : stack_ (stack)
     138        6225 :       , range_ (range)
     139        6225 :     {}
     140             : 
     141             :     inline
     142             :     const T&
     143       12434 :     operator [] (unsigned int i) const
     144             :     {
     145       12434 :       return stack_[range_ - i];
     146             :     }
     147             : 
     148             :   private:
     149             :     const S& stack_;
     150             :     unsigned int range_;
     151             :   };
     152             : 
     153             : 
     154             : } // lha
     155             : #line 156 "stack.hh" // stack.hh:132
     156             : 
     157             : #endif // !YY_LHA_STACK_HH_INCLUDED

Generated by: LCOV version 1.13