The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download | Blog | Stats
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

BoolSet Class Reference

BoolSet is a utility class designed to hold eight bools in a bitmask. More...

#include <base.h>

Inheritance diagram for BoolSet:

Inheritance graph
[legend]
Collaboration diagram for BoolSet:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 BoolSet ()
 The default constructor initializes the BoolSet to all values unset.
 BoolSet (char bitmask)
 This constructor copies the default bitmask from a char.
void Set (int number)
 The Set method sets one bool in the set.
bool Get (int number)
 The Get method returns the value of one bool in the set.
void Unset (int number)
 The Unset method unsets one value in the set.
void Invert (int number)
 The Unset method inverts (flips) one value in the set.
bool operator== (BoolSet other)
 Compare two BoolSets.
BoolSet operator| (BoolSet other)
 OR two BoolSets together.
BoolSet operator & (BoolSet other)
 AND two BoolSets together.
bool operator= (BoolSet other)
 Assign one BoolSet to another.

Private Attributes

char bits
 Actual bit values.

Detailed Description

BoolSet is a utility class designed to hold eight bools in a bitmask.

Use BoolSet::Set and BoolSet::Get to set and get bools in the bitmask, and Unset and Invert for special operations upon them.

Definition at line 168 of file base.h.


Constructor & Destructor Documentation

BoolSet::BoolSet  ) 
 

The default constructor initializes the BoolSet to all values unset.

Definition at line 81 of file base.cpp.

References bits.

00082 {
00083         this->bits = 0;
00084 }

BoolSet::BoolSet char  bitmask  ) 
 

This constructor copies the default bitmask from a char.

Definition at line 86 of file base.cpp.

References bits.

00087 {
00088         this->bits = bitmask;
00089 }


Member Function Documentation

bool BoolSet::Get int  number  ) 
 

The Get method returns the value of one bool in the set.

Parameters:
number The number of the item to retrieve. This must be between 0 and 7.
Returns:
True if the item is set, false if it is unset.

Definition at line 59 of file base.cpp.

References bitfields.

00060 {
00061         return ((this->bits | bitfields[number]) > 0);
00062 }

void BoolSet::Invert int  number  ) 
 

The Unset method inverts (flips) one value in the set.

Parameters:
number The number of the item to invert. This must be between 0 and 7.

Definition at line 54 of file base.cpp.

References bitfields, and bits.

00055 {
00056         this->bits ^= bitfields[number];
00057 }

BoolSet BoolSet::operator & BoolSet  other  ) 
 

AND two BoolSets together.

Definition at line 75 of file base.cpp.

References bits.

00076 {
00077         BoolSet x(this->bits & other.bits);
00078         return x;
00079 }

bool BoolSet::operator= BoolSet  other  ) 
 

Assign one BoolSet to another.

Definition at line 91 of file base.cpp.

References bits.

00092 {
00093         this->bits = other.bits;
00094         return true;
00095 }

bool BoolSet::operator== BoolSet  other  ) 
 

Compare two BoolSets.

Definition at line 64 of file base.cpp.

References bits.

00065 {
00066         return (this->bits == other.bits);
00067 }

BoolSet BoolSet::operator| BoolSet  other  ) 
 

OR two BoolSets together.

Definition at line 69 of file base.cpp.

References bits.

00070 {
00071         BoolSet x(this->bits | other.bits);
00072         return x;
00073 }

void BoolSet::Set int  number  ) 
 

The Set method sets one bool in the set.

Parameters:
number The number of the item to set. This must be between 0 and 7.

Definition at line 44 of file base.cpp.

References bitfields, and bits.

00045 {
00046         this->bits |= bitfields[number];
00047 }

void BoolSet::Unset int  number  ) 
 

The Unset method unsets one value in the set.

Parameters:
number The number of the item to set. This must be between 0 and 7.

Definition at line 49 of file base.cpp.

References bits, and inverted_bitfields.

00050 {
00051         this->bits &= inverted_bitfields[number];
00052 }


Member Data Documentation

char BoolSet::bits [private]
 

Actual bit values.

Definition at line 171 of file base.h.

Referenced by BoolSet(), Invert(), operator &(), operator=(), operator==(), operator|(), Set(), and Unset().


The documentation for this class was generated from the following files: