• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

KMIME Library

  • sources
  • kde-4.12
  • kdepimlibs
  • kmime
boolflags.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 1999-2001 the KMime authors.
3  See file AUTHORS for details
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
31 #include "boolflags.h"
32 
33 using namespace KMime;
34 
35 void BoolFlags::set( unsigned int i, bool b )
36 {
37  if ( i > 15 ) {
38  return;
39  }
40 
41  unsigned char p; //bitmask
42  int n;
43 
44  if ( i < 8 ) { //first byte
45  p = ( 1 << i );
46  n = 0;
47  } else { //second byte
48  p = ( 1 << ( i - 8 ) );
49  n = 1;
50  }
51 
52  if ( b ) {
53  mBits[n] = mBits[n] | p;
54  } else {
55  mBits[n] = mBits[n] & ( 255 - p );
56  }
57 }
58 
59 bool BoolFlags::get( unsigned int i )
60 {
61  if ( i > 15 ) {
62  return false;
63  }
64 
65  unsigned char p; //bitmask
66  int n;
67 
68  if ( i < 8 ) { //first byte
69  p = ( 1 << i );
70  n = 0;
71  } else { //second byte
72  p = ( 1 << ( i - 8 ) );
73  n = 1;
74  }
75 
76  return ( ( mBits[n] & p ) > 0 );
77 }
KMime::BoolFlags::set
void set(unsigned int i, bool b=true)
Sets bit number i to the value b.
Definition: boolflags.cpp:35
KMime::BoolFlags::get
bool get(unsigned int i)
Get bit number i.
Definition: boolflags.cpp:59
boolflags.h
This file is part of the API for handling MIME data and defines the BoolFlags class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KMIME Library

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

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal