Main Page | Namespace List | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

offset_stack_guard.h

Go to the documentation of this file.
00001 
00002 // Common Text Transformation Library
00003 // Copyright (C) 1997-2006 by Igor Kholodov. 
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the
00017 // Free Software Foundation, Inc.,
00018 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 //
00020 // mailto:cttl@users.sourceforge.net
00021 // http://sourceforge.net/projects/cttl/
00023 
00030 // offset_stack_guard.h
00031 
00032 #ifndef _OFFSET_STACK_GUARD_H_INCLUDED_
00033 #define _OFFSET_STACK_GUARD_H_INCLUDED_
00034 
00035 namespace cttl {
00036 
00092 template< typename UniverseT >
00093 class offset_stack_guard {
00094 
00095 protected:
00097     typedef typename UniverseT::offset_manager_T offset_guard_T;
00098 
00100     typedef typename UniverseT::node_T node_T;
00101 
00102 protected:
00104     offset_guard_T m_offset_manager;
00105 
00107     std::stack< size_t >& m_offset_stack;
00108 
00109 public:
00114     offset_stack_guard( std::stack< size_t >& offset_stack_, node_T& node_ )
00115         :
00116         m_offset_manager( node_.parent().container(), node_.offset() ),
00117         m_offset_stack( offset_stack_ )
00118     {
00119         m_offset_stack.push( m_offset_manager.stack_identity() );
00120     }
00121 
00123     ~offset_stack_guard()
00124     {
00125         m_offset_stack.pop();
00126     }
00127 
00129     static size_t offset( UniverseT const& universe_, size_t stack_identity_ )
00130     {
00131         return universe_.first.parent().container().stack_offset( stack_identity_ );
00132     }
00133 
00135     void operator=( offset_stack_guard< UniverseT > const& ) const
00136     {
00137     }
00138 
00139 }; //offset_stack_guard
00140 
00141 
00142 }   // namespace cttl
00143 
00144 
00145 #endif //_OFFSET_STACK_GUARD_H_INCLUDED_

Generated on Thu Nov 2 17:43:39 2006 for CTTL Utility Classes and Functions by  doxygen 1.3.9.1