KMIME Library
boolflags.cpp
Go to the documentation of this file.
00001 /* 00002 Copyright (c) 1999-2001 the KMime authors. 00003 See file AUTHORS for details 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 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 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00031 #include "boolflags.h" 00032 00033 using namespace KMime; 00034 00035 void BoolFlags::set( unsigned int i, bool b ) 00036 { 00037 if ( i > 15 ) { 00038 return; 00039 } 00040 00041 unsigned char p; //bitmask 00042 int n; 00043 00044 if ( i < 8 ) { //first byte 00045 p = (1 << i); 00046 n = 0; 00047 } else { //second byte 00048 p = (1 << (i-8)); 00049 n = 1; 00050 } 00051 00052 if ( b ) { 00053 mBits[n] = mBits[n] | p; 00054 } else { 00055 mBits[n] = mBits[n] & (255 - p); 00056 } 00057 } 00058 00059 bool BoolFlags::get( unsigned int i ) 00060 { 00061 if ( i > 15 ) { 00062 return false; 00063 } 00064 00065 unsigned char p; //bitmask 00066 int n; 00067 00068 if ( i < 8 ) { //first byte 00069 p = (1 << i); 00070 n = 0; 00071 } else { //second byte 00072 p = (1 << (i-8)); 00073 n = 1; 00074 } 00075 00076 return ( ( mBits[n] & p ) > 0 ); 00077 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:24:34 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:24:34 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.