blocxx
BLOCXX_NAMESPACE::Bool Class Reference

The Bool class is an abstraction for the boolean data type. More...

#include <Bool.hpp>

Public Member Functions

 Bool ()
 Create an Bool object initialized to false.
 
 Bool (bool val)
 Create an Bool object initialized to a given boolean value.
 
 Bool (const Bool &arg)
 Copy constructor.
 
Booloperator= (const Bool &arg)
 Assignment operator.
 
bool operator== (const bool arg) const
 Equality operator.
 
bool operator== (const Bool &arg) const
 Equality operator.
 
bool operator!= (const bool arg) const
 Inequality operator.
 
bool operator!= (const Bool &arg) const
 Inequality operator.
 
 operator bool () const
 
bool operator! () const
 Negation operator.
 
String toString () const
 
void writeObject (std::streambuf &ostrm) const
 Write this object to an output stream.
 
void readObject (std::streambuf &istrm)
 Read this object from an input stream.
 

Private Member Functions

 Bool (const void *)
 
 Bool (void *)
 
 Bool (volatile const void *)
 
 Bool (volatile void *)
 

Private Attributes

bool m_val
 

Friends

bool operator< (const Bool &b1, const Bool &b2)
 Less than operator (friend function)
 
bool operator!= (bool b1, Bool b2)
 Not equal operator (friend function)
 

Detailed Description

The Bool class is an abstraction for the boolean data type.

It's not meant to be a replacement for bool. Use it if you need a type that supports toString(), readObject(), or writeObject(). It's also useful for preventing implicit conversion of char*->bool. Using it can make overloading functions safer (ie it'll be less likely the compiler will pick the wrong overload.)

Definition at line 56 of file Bool.hpp.

Constructor & Destructor Documentation

◆ Bool() [1/7]

BLOCXX_NAMESPACE::Bool::Bool ( )
inline

Create an Bool object initialized to false.

Definition at line 63 of file Bool.hpp.

References m_val.

Referenced by Bool(), operator!=, operator!=(), operator<, operator=(), and operator==().

◆ Bool() [2/7]

BLOCXX_NAMESPACE::Bool::Bool ( bool val)
inline

Create an Bool object initialized to a given boolean value.

Parameters
valThe boolean value to initialize this Bool to

Definition at line 68 of file Bool.hpp.

References m_val.

◆ Bool() [3/7]

BLOCXX_NAMESPACE::Bool::Bool ( const Bool & arg)
inline

Copy constructor.

Parameters
argThe Bool to make this object a copy of.

Definition at line 73 of file Bool.hpp.

References Bool(), and m_val.

◆ Bool() [4/7]

BLOCXX_NAMESPACE::Bool::Bool ( const void * )
private

◆ Bool() [5/7]

BLOCXX_NAMESPACE::Bool::Bool ( void * )
private

◆ Bool() [6/7]

BLOCXX_NAMESPACE::Bool::Bool ( volatile const void * )
private

◆ Bool() [7/7]

BLOCXX_NAMESPACE::Bool::Bool ( volatile void * )
private

Member Function Documentation

◆ operator bool()

BLOCXX_NAMESPACE::Bool::operator bool ( ) const
inline
Returns
The bool value of this Bool object.

Definition at line 111 of file Bool.hpp.

References m_val.

◆ operator!()

bool BLOCXX_NAMESPACE::Bool::operator! ( ) const
inline

Negation operator.

Returns
true if this Bool operator has a value of false.

Definition at line 116 of file Bool.hpp.

References m_val.

◆ operator!=() [1/2]

bool BLOCXX_NAMESPACE::Bool::operator!= ( const Bool & arg) const
inline

Inequality operator.

Parameters
argThe Bool object to compare this one with.
Returns
true If the given Bool object is not equal to this one. Otherwise false

Definition at line 107 of file Bool.hpp.

References Bool(), and m_val.

◆ operator!=() [2/2]

bool BLOCXX_NAMESPACE::Bool::operator!= ( const bool arg) const
inline

Inequality operator.

Parameters
argbool value to compare this Bool object against.
Returns
true If the given bool value is not equal to this one. Otherwise false

Definition at line 100 of file Bool.hpp.

References m_val.

◆ operator=()

Bool & BLOCXX_NAMESPACE::Bool::operator= ( const Bool & arg)
inline

Assignment operator.

Parameters
argThe Bool to assign to this one.
Returns
A reference to this object after the assignment has been made.

Definition at line 79 of file Bool.hpp.

References Bool(), and m_val.

◆ operator==() [1/2]

bool BLOCXX_NAMESPACE::Bool::operator== ( const Bool & arg) const
inline

Equality operator.

Parameters
argThe Bool object to compare this one with.
Returns
true If the given Bool object is equal to this one. Otherwise false

Definition at line 93 of file Bool.hpp.

References Bool(), and m_val.

◆ operator==() [2/2]

bool BLOCXX_NAMESPACE::Bool::operator== ( const bool arg) const
inline

Equality operator.

Parameters
argbool value to compare this Bool object against.
Returns
true If the given bool value is equal to this one. Otherwise false

Definition at line 86 of file Bool.hpp.

References m_val.

◆ readObject()

void BLOCXX_NAMESPACE::Bool::readObject ( std::streambuf & istrm)

Read this object from an input stream.

Parameters
istrmThe input stream to read this object from.

Definition at line 63 of file Bool.cpp.

References m_val, and BLOCXX_NAMESPACE::BinarySerialization::read().

Referenced by BLOCXX_NAMESPACE::BinarySerialization::readBool().

◆ toString()

String BLOCXX_NAMESPACE::Bool::toString ( ) const
Returns
The string representation of this object. If this object contains a true value, the "true" is returned. Otherwise "false" is returned.

Definition at line 71 of file Bool.cpp.

References m_val.

Referenced by BLOCXX_NAMESPACE::StringBuffer::operator+=().

◆ writeObject()

void BLOCXX_NAMESPACE::Bool::writeObject ( std::streambuf & ostrm) const

Write this object to an output stream.

Parameters
ostrmThe output stream to write this object to.

Definition at line 56 of file Bool.cpp.

References m_val, and BLOCXX_NAMESPACE::BinarySerialization::write().

Referenced by BLOCXX_NAMESPACE::BinarySerialization::writeBool().

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( bool b1,
Bool b2 )
friend

Not equal operator (friend function)

Parameters
b1The first Bool object to use in the comparison.
b2The second Bool object to use in the comparison.
Returns
true if b1 is not equal to b2. Otherwise false.

Definition at line 148 of file Bool.hpp.

References Bool(), and m_val.

◆ operator<

bool operator< ( const Bool & b1,
const Bool & b2 )
friend

Less than operator (friend function)

Parameters
b1The first Bool object to use in the comparison.
b2The second Bool object to use in the comparison.
Returns
true if b1 is less than b2. Otherwise false.

Definition at line 138 of file Bool.hpp.

References Bool(), and m_val.

Member Data Documentation

◆ m_val

bool BLOCXX_NAMESPACE::Bool::m_val
private

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