Follow this link to skip to the main content

claraty::Bits Class Reference

#include <bits.h>

List of all members.

Public Member Functions

Bits operator<< (size_t n) const
Bits operator>> (size_t n) const
Bits operator~ () const
size_t size () const
unsigned long to_ulong () const
std::string to_str () const
void print (const char *msg="") const
Assignment/index operations
Bitsoperator= (const Bits &rhs)
reference operator[] (size_t pos)
bool operator[] (size_t pos) const
Bit manipulation operators
Bitsoperator &= (const Bits &rhs)
Bitsoperator|= (const Bits &rhs)
Bitsoperator^= (const Bits &rhs)
Bitsoperator<<= (size_t n)
Bitsoperator>>= (size_t n)
Bitsset ()
Bitsset_bit (size_t pos, bool val=true)
Bitsset_bits (size_t pos, size_t n)
Bitsclr ()
Bitsclr_bit (size_t pos)
Bitsclr_bits (size_t pos, size_t n)
Bitstoggle ()
Bitstoggle_bit (size_t pos)
Bitsunchecked_set (unsigned long data)
Bit testing operations
bool operator== (const Bits &rhs) const
bool operator!= (const Bits &rhs) const
bool test (size_t pos) const
bool is_set (size_t pos) const
bool get_bit (size_t pos) const
bool any () const
bool none () const

Private Member Functions

void _sanitize ()

Private Attributes

unsigned long _data
size_t _Nbits

Friends

class reference

Classes

class  reference


Detailed Description

Definition at line 53 of file bits.h.


Constructor & Destructor Documentation

claraty::Bits::Bits ( unsigned long  val = 0,
size_t  n_bits = MAX_BITS 
) [inline]

Definition at line 300 of file bits.h.

References _Nbits, _sanitize(), and claraty::MAX_BITS.

Referenced by operator<<(), operator>>(), and operator~().

00301    : _data(val), _Nbits(n_bits)
00302 {
00303   // Constructor
00304   //
00305   // default args:
00306   //   unsigned long val = 0
00307   //   size_t n_bits = MAX_BITS = sizeof(unsigned long)
00308   //
00309   // input args:
00310   //    unsigned long val --- bit pattern in hexadecimal/octal/decimal number
00311   //    size_t n_bits --- number of bits ( >= MAX_BITS )
00312   //
00313   // Bits b1;                   // b1 = 0000 0000 0000 0000 (_Nbits = MAX_BITS)
00314   // Bits b1(0x14);             // b1 = 0000 0000 0001 0100 (_Nbits = MAX_BITS)
00315   // Bits b1 = 0x14;            // same as above (not using assignment operator)
00316   // Bits b1(0x14, 5);          // b1 = ---- ---- ---1 0100 (_Nbits = 5)
00317   //
00318   // Bits(unsigned long) allows automatic type conversion from "unsigned long"
00319   //   to "Bits" with _Nbits = MAX_BITS
00320   //
00321   if ((int) _Nbits > (int) MAX_BITS) {
00322     // throw out_of_range("Bits::Bits");
00323     // For now, clamp to MAX_BITS and let user check size to see if it worked.
00324     _Nbits = MAX_BITS;
00325     std::cerr << "THROW ERROR: out_of_range - Bits::Bits" << std::endl;
00326   } else {
00327       _sanitize();
00328   }
00329 }

Here is the call graph for this function:

claraty::Bits::Bits ( const std::string &  str,
size_t  n_bits = MAX_BITS 
) [inline, explicit]

Definition at line 337 of file bits.h.

References _data, claraty::_maskbit(), _Nbits, and claraty::MAX_BITS.

00338   : _Nbits(n_bits)
00339 {
00340   // Constructor
00341   //
00342   // default args:
00343   //   size_t n_bits = MAX_BITS = sizeof(unsigned long)
00344   //
00345   // input args:
00346   //    unsigned char* str ---binary-format number, e.g, "0100 0111 0000 1010"
00347   //    size_t n_bits --- number of bits ( >= MAX_BITS )
00348   //
00349   // explicit: no implicit automatic conversion allowed from char* str to Bits;
00350   //   Bits(const char* str) must be explicitly used for the conversion
00351   //
00352   // Bits b1("");               // b1 = 0000 0000 0000 0000 (_Nbits = MAX_BITS)
00353   // Bits b2("01 0100");        // b1 = 0000 0000 0001 0100 (_Nbits = MAX_BITS)
00354   // Bits b2("01 0100", 5);     // b1 = ---- ---- ---1 0100 (_Nbits = 5)
00355   //
00356   if ((int) _Nbits > (int) MAX_BITS)
00357     // throw out_of_range("Bits::Bits");
00358     std::cerr << "THROW ERROR: out_of_range - Bits::Bits" << std::endl;
00359 
00360   _data = 0;    // clear all bits initially
00361 
00362   int i = 0;    // bit index
00363 
00364   // for (int j = strlen(str) - 1; j >= 0; j--) {
00365   for (int j = str.length() - 1; j >= 0; j--) {
00366 
00367     switch (str[j]) {
00368     case '0':
00369       i++;
00370       break;
00371     case '1':           // set bit[i] of _data = 1
00372       _data |= _maskbit(i);
00373       i++;
00374       break;
00375     case ' ':           // skip space
00376       break;
00377     default:
00378       // throw invalid_argument("Bits::Bits");
00379       std::cerr << "THROW ERROR: invalid_argument - Bits::Bits" << std::endl;
00380     }
00381 
00382     if (i >= (int) _Nbits) {                    // warning ??????
00383       std::cerr << "Warning: input data too large" << std::endl;
00384       break;
00385     }
00386   }
00387 }

Here is the call graph for this function:

claraty::Bits::Bits ( unsigned long  val = 0,
size_t  n_bits = MAX_BITS 
) [inline]

Definition at line 300 of file bits.h.

References _Nbits, _sanitize(), and claraty::MAX_BITS.

Referenced by operator<<(), operator>>(), and operator~().

00301    : _data(val), _Nbits(n_bits)
00302 {
00303   // Constructor
00304   //
00305   // default args:
00306   //   unsigned long val = 0
00307   //   size_t n_bits = MAX_BITS = sizeof(unsigned long)
00308   //
00309   // input args:
00310   //    unsigned long val --- bit pattern in hexadecimal/octal/decimal number
00311   //    size_t n_bits --- number of bits ( >= MAX_BITS )
00312   //
00313   // Bits b1;                   // b1 = 0000 0000 0000 0000 (_Nbits = MAX_BITS)
00314   // Bits b1(0x14);             // b1 = 0000 0000 0001 0100 (_Nbits = MAX_BITS)
00315   // Bits b1 = 0x14;            // same as above (not using assignment operator)
00316   // Bits b1(0x14, 5);          // b1 = ---- ---- ---1 0100 (_Nbits = 5)
00317   //
00318   // Bits(unsigned long) allows automatic type conversion from "unsigned long"
00319   //   to "Bits" with _Nbits = MAX_BITS
00320   //
00321   if ((int) _Nbits > (int) MAX_BITS) {
00322     // throw out_of_range("Bits::Bits");
00323     // For now, clamp to MAX_BITS and let user check size to see if it worked.
00324     _Nbits = MAX_BITS;
00325     std::cerr << "THROW ERROR: out_of_range - Bits::Bits" << std::endl;
00326   } else {
00327       _sanitize();
00328   }
00329 }

Here is the call graph for this function:

claraty::Bits::Bits ( const std::string &  str,
size_t  n_bits = MAX_BITS 
) [inline, explicit]

Definition at line 337 of file bits.h.

References _data, claraty::_maskbit(), _Nbits, and claraty::MAX_BITS.

00338   : _Nbits(n_bits)
00339 {
00340   // Constructor
00341   //
00342   // default args:
00343   //   size_t n_bits = MAX_BITS = sizeof(unsigned long)
00344   //
00345   // input args:
00346   //    unsigned char* str ---binary-format number, e.g, "0100 0111 0000 1010"
00347   //    size_t n_bits --- number of bits ( >= MAX_BITS )
00348   //
00349   // explicit: no implicit automatic conversion allowed from char* str to Bits;
00350   //   Bits(const char* str) must be explicitly used for the conversion
00351   //
00352   // Bits b1("");               // b1 = 0000 0000 0000 0000 (_Nbits = MAX_BITS)
00353   // Bits b2("01 0100");        // b1 = 0000 0000 0001 0100 (_Nbits = MAX_BITS)
00354   // Bits b2("01 0100", 5);     // b1 = ---- ---- ---1 0100 (_Nbits = 5)
00355   //
00356   if ((int) _Nbits > (int) MAX_BITS)
00357     // throw out_of_range("Bits::Bits");
00358     std::cerr << "THROW ERROR: out_of_range - Bits::Bits" << std::endl;
00359 
00360   _data = 0;    // clear all bits initially
00361 
00362   int i = 0;    // bit index
00363 
00364   // for (int j = strlen(str) - 1; j >= 0; j--) {
00365   for (int j = str.length() - 1; j >= 0; j--) {
00366 
00367     switch (str[j]) {
00368     case '0':
00369       i++;
00370       break;
00371     case '1':           // set bit[i] of _data = 1
00372       _data |= _maskbit(i);
00373       i++;
00374       break;
00375     case ' ':           // skip space
00376       break;
00377     default:
00378       // throw invalid_argument("Bits::Bits");
00379       std::cerr << "THROW ERROR: invalid_argument - Bits::Bits" << std::endl;
00380     }
00381 
00382     if (i >= (int) _Nbits) {                    // warning ??????
00383       std::cerr << "Warning: input data too large" << std::endl;
00384       break;
00385     }
00386   }
00387 }

Here is the call graph for this function:


Member Function Documentation

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

Definition at line 416 of file bits.h.

References _data, and _sanitize().

00417 {
00418   // Assignment operator
00419   //
00420   // b2 = b1;           // copies _data, but not _Nbits; zeroes out unused bits
00421   // b2 = 0x14;         // first does automatic conversion using Bits(0x14)
00422   //
00423   // cannot not use the compiler-synthesized default assignment operator that
00424   //   copies both the _data and _Nbits member data; it is desirable to keep
00425   //   _Nbits unchanged and zero out the unused high-order bits accordingly;
00426   //   the idea is similar to the assignment statement that involves
00427   //   automatic type conversion (e.g., between char and int)
00428   //
00429   _data = rhs._data;
00430   _sanitize();          // zero out the unused high-order bits
00431   return *this;
00432 }

Here is the call graph for this function:

Bits::reference claraty::Bits::operator[] ( size_t  pos  )  [inline]

Definition at line 457 of file bits.h.

References reference.

00458 {
00459   // single bit element access using b[i] used as lvalue
00460   // - it sets the member data  _bit_pos = pos first, and then
00461   //   returns an lvalue temporay object of type "reference" not "reference&"
00462   // - the returned temporary object together with the assigment operators
00463   //     Bits::reference& Bits::reference::operator=(const reference&) and
00464   //     Bits::reference& Bits::reference::operator=(bool)
00465   //   enables such statement as
00466   //     b[i] = b[j] = 1;
00467   //   After the execution, the i-th and j-th bits of b (a Bits object) are
00468   //   set to 1, and the temporary "reference" object created by b[i]
00469   //   dissappears.
00470   //
00471   return reference(*this, pos);
00472 }

bool claraty::Bits::operator[] ( size_t  pos  )  const [inline]

Definition at line 475 of file bits.h.

References _data, and claraty::_maskbit().

00476 {
00477   // single bit element access using b[i]
00478   // - when returning a built-in type by value, it automatically implies
00479   //   a "const" return; it returns a value not a variable; namely,
00480   //   bool f() is the same as const bool f()
00481   // - the "const" return type cannot be a lvalue
00482   //
00483   return (_data & _maskbit(pos)) != 0;
00484 }

Here is the call graph for this function:

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

Definition at line 501 of file bits.h.

References _data.

00502 {
00503   // bitwise AND
00504   //
00505   _data &= rhs._data;           // _sanitize unnecessary
00506   return *this;
00507 }

Bits & claraty::Bits::operator|= ( const Bits rhs  )  [inline]

Definition at line 510 of file bits.h.

References _data, and _sanitize().

00511 {
00512   // bitwise OR
00513   //
00514   _data |= rhs._data;
00515   _sanitize();
00516   return *this;
00517 }

Here is the call graph for this function:

Bits & claraty::Bits::operator^= ( const Bits rhs  )  [inline]

Definition at line 520 of file bits.h.

References _data, and _sanitize().

00521 {
00522   // bitwise EXCLUSIVE-OR
00523   //
00524   _data ^= rhs._data;
00525   _sanitize();
00526   return *this;
00527 }

Here is the call graph for this function:

Bits & claraty::Bits::operator<<= ( size_t  n  )  [inline]

Definition at line 530 of file bits.h.

References _data, and _sanitize().

00531 {
00532   // shift left: fill with zeros
00533   //
00534   _data <<= n;
00535   _sanitize();
00536   return *this;
00537 }

Here is the call graph for this function:

Bits & claraty::Bits::operator>>= ( size_t  n  )  [inline]

Definition at line 540 of file bits.h.

References _data, and _sanitize().

00541 {
00542   // shift right: fill with zeros
00543   //
00544   _data >>= n;
00545   _sanitize();
00546   return *this;
00547 }

Here is the call graph for this function:

Bits & claraty::Bits::set (  )  [inline]

Definition at line 569 of file bits.h.

References _data, and _sanitize().

Referenced by claraty::DIO::_verify_io_mode(), and claraty::DIO_impl::set_IO_direction().

00570 {
00571   // set every bit to 1
00572   //
00573   _data = ~static_cast<unsigned long>(0);
00574   _sanitize();
00575   return *this;
00576 }

Here is the call graph for this function:

Bits & claraty::Bits::set_bit ( size_t  pos,
bool  val = true 
) [inline]

Definition at line 580 of file bits.h.

References _data, claraty::_maskbit(), and _Nbits.

Referenced by claraty::DIO::clr(), claraty::DIO::clr_bit(), claraty::DIO::set(), claraty::DIO::set_bit(), and claraty::DIO_impl::set_IO_direction().

00581 {
00582   // b[pos] = val; don't change other bits
00583   // default bool val = true; b[pos] = 1 (set to 1)
00584   //
00585   if (pos >= _Nbits)
00586     // throw out_of_range("Bits::set_bit");
00587     std::cerr << "Bits WARNING: out_of_range - Bits::set_bit" << std::endl;
00588 
00589   if (val)
00590     _data |= _maskbit(pos);
00591   else
00592     _data &= ~_maskbit(pos);
00593 
00594   return *this;
00595 }

Here is the call graph for this function:

Bits & claraty::Bits::set_bits ( size_t  pos,
size_t  n 
) [inline]

Definition at line 598 of file bits.h.

References _data, claraty::_maskbits(), and _Nbits.

Referenced by claraty::DIO::clr(), claraty::DIO::DIO(), and claraty::DIO::set().

00599 {
00600   // extension from STL bitset
00601   // b[pos] =  ... = b[pos+n-1] = 1; don't change other bits
00602   //
00603   if (pos + n > _Nbits)                 // + has precedence over >=
00604     // throw out_of_range("Bits::set_bits");
00605     std::cerr << "Bits WARNING: out_of_range - Bits::set_bits" << std::endl;
00606 
00607   _data |= _maskbits(pos, n);
00608 
00609   return *this;
00610 }

Here is the call graph for this function:

Bits & claraty::Bits::clr (  )  [inline]

Definition at line 613 of file bits.h.

References _data.

Referenced by claraty::DIO_impl::set_IO_direction().

00614 {
00615   // set every bit to 0 (clear all bits)
00616   //
00617   _data = 0;
00618   return *this;
00619 }

Bits & claraty::Bits::clr_bit ( size_t  pos  )  [inline]

Definition at line 622 of file bits.h.

References _data, claraty::_maskbit(), and _Nbits.

00623 {
00624   // b[pos] = 0 (clear one bit)
00625   //
00626   if (pos >= _Nbits)
00627     // throw out_of_range("Bits::clr_bit");
00628     std::cerr << "Bits WARNING: out_of_range - Bits::clr_bit" << std::endl;
00629 
00630   _data &= ~_maskbit(pos);
00631 
00632   return *this;
00633 }

Here is the call graph for this function:

Bits & claraty::Bits::clr_bits ( size_t  pos,
size_t  n 
) [inline]

Definition at line 636 of file bits.h.

References _data, claraty::_maskbits(), and _Nbits.

Referenced by claraty::DIO::clr(), and claraty::DIO::set().

00637 {
00638   // extension from STL bitset
00639   // b[pos] =  ... = b[pos+n-1] = 0; don't change other bits
00640   //
00641   if (pos + n > _Nbits)         // + has precedence over >=
00642     // throw out_of_range("Bits::clr_bits");
00643     std::cerr << "Bits WARNING: out_of_range - Bits::clr_bits" << std::endl;
00644 
00645   _data &= ~_maskbits(pos, n);
00646 
00647   return *this;
00648 }

Here is the call graph for this function:

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

Definition at line 651 of file bits.h.

References _data, and _sanitize().

00652 {
00653   // change the value of every bit
00654   //
00655   _data = ~_data;
00656   _sanitize();
00657 
00658   return *this;
00659 }

Here is the call graph for this function:

Bits & claraty::Bits::toggle_bit ( size_t  pos  )  [inline]

Definition at line 662 of file bits.h.

References _data, claraty::_maskbit(), and _Nbits.

Referenced by claraty::DIO::toggle(), and claraty::DIO::toggle_bit().

00663 {
00664   // change the value of b[pos]
00665   //
00666   if (pos >= _Nbits)
00667     // throw out_of_range("Bits::toggle_bit");
00668     std::cerr << "Bits WARNING: out_of_range - Bits::toggle_bit" << std::endl;
00669 
00670   _data ^= _maskbit(pos);
00671   return *this;
00672 }

Here is the call graph for this function:

Bits & claraty::Bits::unchecked_set ( unsigned long  data  )  [inline]

Definition at line 675 of file bits.h.

References _data.

Referenced by claraty::DIO::set(), and claraty::DIO_impl::set_mask().

00676 {
00677   _data = data;                 // user must ensure data is sanitized
00678   // _sanitize();               // does not do data sanity check
00679 
00680   return *this;
00681 }

Bits claraty::Bits::operator<< ( size_t  n  )  const [inline]

Definition at line 784 of file bits.h.

References Bits().

00785 {
00786   // for return (b1<<3) and also for b2 = b1<<3; b1 unchanged
00787   // make a left-shifted copy without changing the original object (*this)
00788   // e.g., the statement b2 = b1 << 3 should not change b1.
00789   // returns the updated object by value (Bits), not by reference (Bits&)
00790   //
00791   return Bits(*this) <<= n;
00792 }

Here is the call graph for this function:

Bits claraty::Bits::operator>> ( size_t  n  )  const [inline]

Definition at line 795 of file bits.h.

References Bits().

00796 {
00797   // for return (b1>>3) and also for b2 = b1>>3; b1 unchanged
00798   // make right-shifted set
00799   //
00800   return Bits(*this) >>= n;
00801 }

Here is the call graph for this function:

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

Definition at line 804 of file bits.h.

References Bits().

00805 {
00806   // for return (~b1) and also for b2 = ~b1; b1 unchanged
00807   // make complement set
00808   //
00809   return Bits(*this).toggle();
00810 }

Here is the call graph for this function:

bool claraty::Bits::operator== ( const Bits rhs  )  const [inline]

Definition at line 723 of file bits.h.

References _data.

00724 {
00725   // for b1==b2 and also for b1==0x14
00726   // compare _data only not _Nbits
00727   //
00728   return _data == rhs._data;
00729 }

bool claraty::Bits::operator!= ( const Bits rhs  )  const [inline]

Definition at line 732 of file bits.h.

References _data.

00733 {
00734   // for b1!=b2 and also for b1!=0x14
00735   // compare _data only not _Nbits
00736   //
00737   return _data != rhs._data;
00738 }

bool claraty::Bits::test ( size_t  pos  )  const [inline]

Definition at line 742 of file bits.h.

References _data, claraty::_maskbit(), and _Nbits.

Referenced by get_bit(), is_set(), claraty::DIO::test(), and to_str().

00743 {
00744   // true if b[pos] is 1
00745   //
00746   if (pos >= _Nbits)
00747     // throw out_of_range("Bits::test");
00748     std::cerr << "THROW ERROR: out_of_range - Bits::test" << std::endl;
00749 
00750   return (_data & _maskbit(pos)) != 0;
00751 }

Here is the call graph for this function:

bool claraty::Bits::is_set ( size_t  pos  )  const [inline]

Definition at line 755 of file bits.h.

References test().

00756 {
00757     return test(pos);
00758 }

Here is the call graph for this function:

bool claraty::Bits::get_bit ( size_t  pos  )  const [inline]

Definition at line 762 of file bits.h.

References test().

00763 {
00764     return test(pos);
00765 }

Here is the call graph for this function:

bool claraty::Bits::any (  )  const [inline]

Definition at line 768 of file bits.h.

References _data.

00769 {
00770   // true if any bit is 1
00771   //
00772   return _data != 0;
00773 }

bool claraty::Bits::none (  )  const [inline]

Definition at line 776 of file bits.h.

References _data.

00777 {
00778   // true if no bit is 1
00779   //
00780   return _data == 0;
00781 }

size_t claraty::Bits::size (  )  const [inline]

Definition at line 689 of file bits.h.

References _Nbits.

00690 {
00691   // get bit size
00692   //
00693   return _Nbits;                                // number of bits
00694 }

unsigned long claraty::Bits::to_ulong (  )  const [inline]

Definition at line 703 of file bits.h.

References _data.

Referenced by claraty::DIO::get_mask(), claraty::DIO::operator unsigned long(), claraty::DIO::output(), claraty::CDIO::output(), claraty::DIO::set(), and claraty::CDIO::set().

00704 {
00705   // conversion to unsigned long
00706   //
00707   // unsigned long x = b1.to_ulong();
00708   // unsigned short y = b1.to_ulong();
00709   // unsigned char z = b1.to_ulong();
00710   // BYTE z = b1.to_ulong();                    // BYTE = unsigned char
00711   //
00712   return _data;
00713 }

string claraty::Bits::to_str (  )  const

Definition at line 34 of file bits.cc.

References _data, _Nbits, and test().

Referenced by claraty::operator<<(), print(), claraty::DIO_impl::to_str(), and claraty::CDIO::to_str().

00035 {
00036   // Print out the bit pattern of the Bits object
00037   //
00038   char buffer[128], *output;
00039   output = new char[256];               // for contiguous printing on VxWorks
00040 
00041   sprintf(buffer, "[%2d] {", static_cast<unsigned int>(_Nbits));
00042   strcpy(output, buffer);
00043 
00044 
00045   // Convert the Bits to hex ascii
00046   //
00047   int n_bytes = (_Nbits + 7)/8;         // number of bytes
00048   for (int i = n_bytes - 1; i >= 0; --i) {
00049     sprintf(buffer, "%2x ", static_cast<unsigned int>((_data >> i*8) & 0xff));
00050     strcat(output, buffer);
00051   }
00052   strcat(output, "}  ");
00053 
00054   // Print the bit pattern --00 0110 0010 ...
00055   //
00056   int n = (_Nbits + 3) / 4 * 4; // total number of bits in 4-bit period
00057   int j=0;                      // buffer index for buffer[j];
00058 
00059   for (size_t i = n - 1; i >= 0; i--) {    // i = bit index for b[i]
00060     if (i >= _Nbits) {
00061       buffer[j++] = '-';
00062       continue;
00063     }
00064 
00065     // if (_unchecked_test(i))
00066     if (test(i))
00067       buffer[j++] = '1';
00068     else
00069       buffer[j++] = '0';
00070 
00071     if ( (i % 4) == 0  &&  i != 0)      // == and != have precedence over &&
00072       buffer[j++] = ' ';
00073   }
00074   buffer[j] = 0;                // null character ('\0' = 0)
00075 
00076   strcat(output, buffer);
00077 
00078   string s(output);
00079   delete [] output;
00080 
00081   return s;
00082 }

Here is the call graph for this function:

void claraty::Bits::print ( const char *  msg = ""  )  const

Print function.

Parameters:
[in] msg 

Definition at line 90 of file bits.cc.

References to_str().

Referenced by claraty::DIO_impl::print(), claraty::CDIO::print(), and claraty::DIO_sim::set_hw_bits().

00091 {
00092   cout << msg << "\n  " << to_str().c_str() << endl;    // c_str() will not be
00093                                                         // needed in the future
00094 }

Here is the call graph for this function:

void claraty::Bits::_sanitize (  )  [inline, private]

Definition at line 814 of file bits.h.

References _data, _Nbits, and claraty::MAX_BITS.

Referenced by Bits(), operator<<=(), operator=(), operator>>=(), operator^=(), operator|=(), set(), and toggle().

00815 {
00816   // zero out the unused high-order bits
00817   //
00818   if (_Nbits != MAX_BITS)
00819     _data &= ~( ~static_cast<unsigned long>(0) << _Nbits );
00820 }


Friends And Related Function Documentation

friend class reference [friend]

Definition at line 60 of file bits.h.

Referenced by operator[]().


Member Data Documentation

size_t claraty::Bits::_Nbits [private]

Definition at line 154 of file bits.h.

Referenced by _sanitize(), Bits(), clr_bit(), clr_bits(), set_bit(), set_bits(), size(), test(), to_str(), and toggle_bit().


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