Parma_Polyhedra_Library::Row::Flags Class Reference
[C++ Language Interface]

Wrapper class to represent a set of flags with bits in a native unsigned integral type. More...

#include <Row.defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::Row::Flags:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 Flags ()
 Constructs an object with all the flags unset.
bool operator== (const Flags &y) const
 Returns true if and only if *this and y are equal.
bool operator!= (const Flags &y) const
 Returns true if and only if *this and y are different.
void ascii_dump () const
 Writes to std::cerr an ASCII representation of *this.
void ascii_dump (std::ostream &s) const
 Writes to s an ASCII representation of *this.
void print () const
 Prints *this to std::cerr using operator<<.
bool ascii_load (std::istream &s)
 Uses the ASCII Flags representation from s to recreate *this.

Protected Types

typedef unsigned int base_type
 A native integral type holding the bits that encode the flags.

Protected Member Functions

 Flags (base_type n)
 Constructs an object with flags set as in n.
base_type get_bits () const
 Returns the integer encoding *this.
void set_bits (base_type mask)
 Sets the bits in mask.
void reset_bits (base_type mask)
 Resets the bits in mask.
bool test_bits (base_type mask) const
 Returns true if and only if all the bits in mask are set.

Static Protected Attributes

static const unsigned first_free_bit = 0
 Index of the first bit derived classes can use.
static const unsigned num_bits = std::numeric_limits<base_type>::digits
 Total number of bits that can be stored.

Private Attributes

base_type bits
 The integer encoding *this.

Friends

class Row


Detailed Description

Wrapper class to represent a set of flags with bits in a native unsigned integral type.

Definition at line 93 of file Row.defs.hh.


Member Typedef Documentation

typedef unsigned int Parma_Polyhedra_Library::Row::Flags::base_type [protected]

A native integral type holding the bits that encode the flags.

Definition at line 119 of file Row.defs.hh.


Constructor & Destructor Documentation

Parma_Polyhedra_Library::Row::Flags::Flags (  )  [inline]

Constructs an object with all the flags unset.

Reimplemented in Parma_Polyhedra_Library::Linear_Row::Flags.

Definition at line 33 of file Row.inlines.hh.

00034   : bits(0) {
00035 }

Parma_Polyhedra_Library::Row::Flags::Flags ( base_type  n  )  [inline, explicit, protected]

Constructs an object with flags set as in n.

Definition at line 38 of file Row.inlines.hh.

00039   : bits(n) {
00040 }


Member Function Documentation

bool Parma_Polyhedra_Library::Row::Flags::operator== ( const Flags y  )  const [inline]

Returns true if and only if *this and y are equal.

Reimplemented in Parma_Polyhedra_Library::Linear_Row::Flags.

Definition at line 63 of file Row.inlines.hh.

References first_free_bit, and get_bits().

Referenced by operator!=().

00063                                          {
00064   base_type mask = low_bits_mask<base_type>(first_free_bit);
00065   return (get_bits() & mask) == (y.get_bits() & mask);
00066 }

bool Parma_Polyhedra_Library::Row::Flags::operator!= ( const Flags y  )  const [inline]

Returns true if and only if *this and y are different.

Reimplemented in Parma_Polyhedra_Library::Linear_Row::Flags.

Definition at line 69 of file Row.inlines.hh.

References operator==().

00069                                          {
00070   return !operator==(y);
00071 }

void Parma_Polyhedra_Library::Row::Flags::ascii_dump (  )  const

Writes to std::cerr an ASCII representation of *this.

Reimplemented in Parma_Polyhedra_Library::Linear_Row::Flags.

Referenced by Parma_Polyhedra_Library::Row::ascii_dump().

void Parma_Polyhedra_Library::Row::Flags::ascii_dump ( std::ostream &  s  )  const

Writes to s an ASCII representation of *this.

Reimplemented in Parma_Polyhedra_Library::Linear_Row::Flags.

Definition at line 135 of file Row.cc.

References bits.

00135                                            {
00136   s << "0x";
00137   std::istream::fmtflags f = s.setf(std::istream::hex);
00138   std::streamsize sz = s.width(2*sizeof(Flags::base_type));
00139   std::ostream::char_type ch = s.fill('0');
00140   s << bits;
00141   s.fill(ch);
00142   s.width(sz);
00143   s.flags(f);
00144 }

void Parma_Polyhedra_Library::Row::Flags::print (  )  const

Prints *this to std::cerr using operator<<.

Reimplemented in Parma_Polyhedra_Library::Linear_Row::Flags.

bool Parma_Polyhedra_Library::Row::Flags::ascii_load ( std::istream &  s  ) 

Uses the ASCII Flags representation from s to recreate *this.

Returns true if successful, false otherwise. The ASCII representation is as output by Parma_Polyhedra_Library::Row::Flags::ascii_dump.

Reimplemented in Parma_Polyhedra_Library::Linear_Row::Flags.

Definition at line 149 of file Row.cc.

References bits.

Referenced by Parma_Polyhedra_Library::Row::ascii_load().

00149                                      {
00150   std::string str;
00151   std::streamsize sz = s.width(2);
00152   if (!(s >> str) || (str.compare("0x") != 0))
00153     return false;
00154   s.width(sz);
00155   std::istream::fmtflags f = s.setf(std::istream::hex);
00156   bool r = s >> bits;
00157   s.flags(f);
00158   return r;
00159 }

Row::Flags::base_type Parma_Polyhedra_Library::Row::Flags::get_bits (  )  const [inline, protected]

Returns the integer encoding *this.

Definition at line 43 of file Row.inlines.hh.

References bits.

Referenced by operator==(), and Parma_Polyhedra_Library::Linear_Row::Flags::operator==().

00043                          {
00044   return bits;
00045 }

void Parma_Polyhedra_Library::Row::Flags::set_bits ( base_type  mask  )  [inline, protected]

void Parma_Polyhedra_Library::Row::Flags::reset_bits ( base_type  mask  )  [inline, protected]

bool Parma_Polyhedra_Library::Row::Flags::test_bits ( base_type  mask  )  const [inline, protected]


Friends And Related Function Documentation

friend class Row [friend]

Definition at line 149 of file Row.defs.hh.


Member Data Documentation

const unsigned Parma_Polyhedra_Library::Row::Flags::first_free_bit = 0 [static, protected]

Index of the first bit derived classes can use.

Reimplemented in Parma_Polyhedra_Library::Linear_Row::Flags.

Definition at line 122 of file Row.defs.hh.

Referenced by Parma_Polyhedra_Library::Linear_Row::Flags::ascii_load(), and operator==().

const unsigned Parma_Polyhedra_Library::Row::Flags::num_bits = std::numeric_limits<base_type>::digits [static, protected]

Total number of bits that can be stored.

Definition at line 125 of file Row.defs.hh.

The integer encoding *this.

Definition at line 147 of file Row.defs.hh.

Referenced by ascii_dump(), ascii_load(), get_bits(), reset_bits(), set_bits(), and test_bits().


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

Generated on Wed Jul 16 22:55:45 2008 for PPL by  doxygen 1.5.6