Wrapper class to represent a set of flags with bits in a native unsigned integral type. More...
#include <Row.defs.hh>

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 |
Wrapper class to represent a set of flags with bits in a native unsigned integral type.
Definition at line 98 of file Row.defs.hh.
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 124 of file Row.defs.hh.
| 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 35 of file Row.inlines.hh.
00036 : bits(0) { 00037 }
| Parma_Polyhedra_Library::Row::Flags::Flags | ( | base_type | n | ) | [inline, explicit, protected] |
Constructs an object with flags set as in n.
Reimplemented in Parma_Polyhedra_Library::Linear_Row::Flags.
Definition at line 40 of file Row.inlines.hh.
00041 : bits(n) { 00042 }
| 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::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().
| 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.
00149 { 00150 std::string str; 00151 std::streamsize sz = s.width(2); 00152 if (!(s >> str) || str != "0x") 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 45 of file Row.inlines.hh.
References bits.
Referenced by operator==(), and Parma_Polyhedra_Library::Linear_Row::Flags::operator==().
00045 { 00046 return bits; 00047 }
| 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 71 of file Row.inlines.hh.
References operator==().
00071 { 00072 return !operator==(y); 00073 }
| 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 65 of file Row.inlines.hh.
References first_free_bit, and get_bits().
Referenced by operator!=().
00065 { 00066 base_type mask = low_bits_mask<base_type>(first_free_bit); 00067 return (get_bits() & mask) == (y.get_bits() & mask); 00068 }
| void Parma_Polyhedra_Library::Row::Flags::print | ( | ) | const |
Prints *this to std::cerr using operator<<.
Reimplemented in Parma_Polyhedra_Library::Linear_Row::Flags.
| void Parma_Polyhedra_Library::Row::Flags::reset_bits | ( | base_type | mask | ) | [inline, protected] |
Resets the bits in mask.
Definition at line 55 of file Row.inlines.hh.
References bits.
Referenced by Parma_Polyhedra_Library::Linear_Row::Flags::set_is_line_or_equality(), and Parma_Polyhedra_Library::Linear_Row::Flags::set_necessarily_closed().
00055 { 00056 bits &= ~mask; 00057 }
| void Parma_Polyhedra_Library::Row::Flags::set_bits | ( | base_type | mask | ) | [inline, protected] |
Sets the bits in mask.
Definition at line 50 of file Row.inlines.hh.
References bits.
Referenced by Parma_Polyhedra_Library::Linear_Row::Flags::Flags(), Parma_Polyhedra_Library::Linear_Row::Flags::set_is_line_or_equality(), Parma_Polyhedra_Library::Linear_Row::Flags::set_is_ray_or_point_or_inequality(), Parma_Polyhedra_Library::Linear_Row::Flags::set_necessarily_closed(), and Parma_Polyhedra_Library::Linear_Row::Flags::set_not_necessarily_closed().
00050 { 00051 bits |= mask; 00052 }
| bool Parma_Polyhedra_Library::Row::Flags::test_bits | ( | base_type | mask | ) | const [inline, protected] |
Returns true if and only if all the bits in mask are set.
Definition at line 60 of file Row.inlines.hh.
References bits.
Referenced by Parma_Polyhedra_Library::Linear_Row::Flags::ascii_dump(), Parma_Polyhedra_Library::Linear_Row::Flags::is_line_or_equality(), Parma_Polyhedra_Library::Linear_Row::Flags::is_necessarily_closed(), Parma_Polyhedra_Library::Linear_Row::Flags::is_not_necessarily_closed(), and Parma_Polyhedra_Library::Linear_Row::Flags::is_ray_or_point_or_inequality().
00060 { 00061 return (bits & mask) == mask; 00062 }
friend class Row [friend] |
Definition at line 154 of file Row.defs.hh.
The integer encoding *this.
Definition at line 152 of file Row.defs.hh.
Referenced by ascii_dump(), get_bits(), reset_bits(), set_bits(), and test_bits().
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 127 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 130 of file Row.defs.hh.
1.6.3