libkmime
boolflags.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "boolflags.h"
00018
00019 void BoolFlags::set(unsigned int i, bool b)
00020 {
00021 if(i>15) return;
00022
00023 unsigned char p;
00024 int n;
00025
00026 if(i<8) {
00027 p=(1 << i);
00028 n=0;
00029 }
00030 else {
00031 p=(1 << i-8);
00032 n=1;
00033 }
00034
00035 if(b)
00036 bits[n] = bits[n] | p;
00037 else
00038 bits[n] = bits[n] & (255-p);
00039 }
00040
00041
00042 bool BoolFlags::get(unsigned int i)
00043 {
00044 if(i>15) return false;
00045
00046 unsigned char p;
00047 int n;
00048
00049 if(i<8) {
00050 p=(1 << i);
00051 n=0;
00052 }
00053 else {
00054 p=(1 << i-8);
00055 n=1;
00056 }
00057
00058 return ( (bits[n] & p)>0 );
00059 }
00060
00061
|