KMIME Library
boolflags.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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;
00042 int n;
00043
00044 if ( i < 8 ) {
00045 p = (1 << i);
00046 n = 0;
00047 } else {
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;
00066 int n;
00067
00068 if ( i < 8 ) {
00069 p = (1 << i);
00070 n = 0;
00071 } else {
00072 p = (1 << (i-8));
00073 n = 1;
00074 }
00075
00076 return ( ( mBits[n] & p ) > 0 );
00077 }