• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

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 }

KMIME Library

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.2-20100208
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