xref: /AOO41X/main/autodoc/source/inc/estack.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef ARY_ESTACK_HXX
29 #define ARY_ESTACK_HXX
30 
31 
32 
33 // USED SERVICES
34 	// BASE CLASSES
35 #include <slist>
36 	// COMPONENTS
37 	// PARAMETERS
38 
39 
40 
41 template <class ELEM>
42 class EStack : private std::slist<ELEM>
43 {
44   private:
45     typedef std::slist<ELEM>    base;
46     const base &        Base() const            { return *this; }
47     base &              Base()                  { return *this; }
48 
49   public:
50     typedef ELEM                                    value_type;
51     typedef typename std::slist<ELEM>::size_type    size_type;
52 
53     // LIFECYCLE
54 						EStack() 				{}
55 						EStack(
56 							const EStack &      i_rStack )
57 												: 	base( (const base &)(i_rStack) ) {}
58 						~EStack() 				{}
59     // OPERATORS
60     EStack &            operator=(
61                             const EStack &      i_rStack )
62                                                 { base::operator=( i_rStack.Base() );
63                                                   return *this; }
64     bool                operator==(
65                             const EStack<ELEM> &
66                                                 i_r2 ) const
67                                                 { return std::operator==( Base(), this->i_rStack.Base() ); }
68     bool                operator<(
69                             const EStack<ELEM> &
70                                                 i_r2 ) const
71                                                 { return std::operator<( Base(), this->i_rStack.Base() ); }
72     // OPERATIONS
73     void                push(
74                             const value_type &  i_rElem )
75                                                 { base::push_front(i_rElem); }
76     void                pop()                   { base::pop_front(); }
77     void                erase_all()             { while (NOT empty()) pop(); }
78 
79     // INQUIRY
80     const value_type &  top() const             { return base::front(); }
81     size_type           size() const            { return base::size(); }
82     bool                empty() const           { return base::empty(); }
83 
84     // ACCESS
85     value_type &        top()                   { return base::front(); }
86 };
87 
88 
89 
90 // IMPLEMENTATION
91 
92 
93 #endif
94 
95