• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

util

pushvalue.h

00001 /*
00002    Copyright 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #ifndef PUSHVALUE_H
00020 #define PUSHVALUE_H
00021 
00028 template<class Value>
00029 class PushValue {
00030   public:
00031     PushValue( Value& ptr, const Value& push = Value()  ) : m_ptr(ptr)  {
00032       m_oldPtr = m_ptr;
00033       m_ptr = push;
00034     }
00035     ~PushValue() {
00036       m_ptr = m_oldPtr;
00037     }
00038   private:
00039     Value& m_ptr;
00040     Value m_oldPtr;
00041 };
00042 
00044 template<class Value>
00045 class PushPositiveValue {
00046   public:
00047     PushPositiveValue( Value& ptr, const Value& push = Value()  ) : m_ptr(ptr)  {
00048       m_oldPtr = m_ptr;
00049       if( push ) {
00050         m_ptr = push;
00051       }
00052     }
00053     ~PushPositiveValue() {
00054       m_ptr = m_oldPtr;
00055     }
00056   private:
00057     Value& m_ptr;
00058     Value m_oldPtr;
00059 };
00060 
00061 #endif

util

Skip menu "util"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   codegen
  •   duchain
  •   editor
  • outputview
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal