ui/secstring.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //
00003 // $Id: secstring.h,v 1.5 2008-02-13 20:47:48 rafi Exp $
00004 //
00005 // YAPET -- Yet Another Password Encryption Tool
00006 // Copyright (C) 2008  Rafael Ostertag
00007 //
00008 // This program is free software: you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation, either version 3 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020 //
00021 
00022 #ifndef _SECSTRING_H
00023 #define _SECSTRING_H
00024 
00025 #ifdef HAVE_CONFIG_H
00026 # include <config.h>
00027 #endif
00028 
00029 #ifdef HAVE_STRING_H
00030 # include <string.h>
00031 #endif
00032 
00033 #ifdef HAVE_MEMORY
00034 # include <memory>
00035 #endif
00036 
00037 #ifdef HAVE_STRING
00038 # include <string>
00039 #endif
00040 
00049 namespace YAPETUI {
00050 
00057     template <class T>
00058     class secallocator: public std::allocator<T> {
00059     public:
00060         void deallocate(typename std::allocator<T>::pointer p,
00061                 typename std::allocator<T>::size_type n) {
00062         memset(p, '0', n*sizeof(std::allocator<T>::value_type));
00063         std::allocator<T>::deallocate(p, n);
00064         }
00065 
00066     };
00067 
00074     typedef std::basic_string<char, std::char_traits<char>, secallocator<char> > secstring;
00075 
00076 }
00077 
00078 #endif // _SECSTRING_H

Generated on Wed Feb 27 16:15:41 2008 for YAPET by  doxygen 1.5.4