Follow this link to skip to the main content

claraty::Bits::reference Class Reference

#include <bits.h>

List of all members.

Public Member Functions

 reference (Bits &b, size_t pos)
 ~reference ()
referenceoperator= (bool x)
referenceoperator= (const reference &j)
bool operator~ () const
 operator bool () const
referencetoggle ()

Private Member Functions

 reference ()

Private Attributes

unsigned long * _data_p
size_t _bit_pos

Friends

class Bits


Detailed Description

Definition at line 192 of file bits.h.


Constructor & Destructor Documentation

claraty::Bits::reference::reference (  )  [private]

claraty::Bits::reference::reference ( Bits b,
size_t  pos 
) [inline]

Definition at line 219 of file bits.h.

00220   : _data_p(&b._data), _bit_pos(pos)
00221 {
00222   // constructor
00223   //
00224   // initialization is all we need
00225 }

claraty::Bits::reference::~reference (  )  [inline]

Definition at line 209 of file bits.h.

00209 {}                              // empty default destructor


Member Function Documentation

Bits::reference & claraty::Bits::reference::operator= ( bool  x  )  [inline]

Definition at line 246 of file bits.h.

References _bit_pos, _data_p, and claraty::_maskbit().

00247 {
00248   // for b[i] = x
00249   //
00250   if ( x )
00251     *_data_p |= _maskbit(_bit_pos);
00252   else
00253     *_data_p &= ~_maskbit(_bit_pos);
00254 
00255   return *this;
00256 }

Here is the call graph for this function:

Bits::reference & claraty::Bits::reference::operator= ( const reference j  )  [inline]

Definition at line 258 of file bits.h.

References _bit_pos, _data_p, and claraty::_maskbit().

00259 {
00260   // for b[i] = b[j];
00261   //
00262   if ( *j._data_p & _maskbit(j._bit_pos) )
00263     *_data_p |= _maskbit(_bit_pos);
00264   else
00265     *_data_p &= ~_maskbit(_bit_pos);
00266 
00267   return *this;
00268 }

Here is the call graph for this function:

bool claraty::Bits::reference::operator~ (  )  const [inline]

Definition at line 270 of file bits.h.

References _bit_pos, _data_p, and claraty::_maskbit().

00271 {
00272   // return ~b[i]
00273   //
00274   return (*_data_p & _maskbit(_bit_pos)) == 0;
00275 }

Here is the call graph for this function:

claraty::Bits::reference::operator bool (  )  const [inline]

Definition at line 277 of file bits.h.

References _bit_pos, _data_p, and claraty::_maskbit().

00278 {
00279   // for x = b[i]; conversion operator to a built-in type bool
00280   //
00281   return (*_data_p & _maskbit(_bit_pos)) != 0;  // != has precedence over &
00282 }

Here is the call graph for this function:

Bits::reference & claraty::Bits::reference::toggle (  )  [inline]

Definition at line 284 of file bits.h.

References _bit_pos, _data_p, and claraty::_maskbit().

00285 {
00286   // for b[i].toggle();
00287   //
00288   *_data_p ^= _maskbit(_bit_pos);
00289   return *this;
00290 }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class Bits [friend]

Definition at line 200 of file bits.h.


Member Data Documentation

unsigned long* claraty::Bits::reference::_data_p [private]

Definition at line 202 of file bits.h.

Referenced by operator bool(), operator=(), operator~(), and toggle().

Definition at line 203 of file bits.h.

Referenced by operator bool(), operator=(), operator~(), and toggle().


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