PSCF v1.1
List of all members
Util::Bool Class Reference

Wrapper for an bool value, for formatted ostream output. More...

#include <Bool.h>

Public Member Functions

Constructors
 Bool ()
 Default constructor. More...
 
 Bool (bool value)
 Constructor, set value. More...
 
 Bool (bool value, int width)
 Constructor, value and width. More...
 
Setters
void setValue (bool value)
 Set the value. More...
 
void setWidth (int width)
 Set the output width. More...
 

Accessors

bool value ()
 Return value. More...
 
int width ()
 Return default width (number of characters). More...
 
std::istream & operator>> (std::istream &in, Bool &object)
 Input stream extractor for an Bool object. More...
 
std::ostream & operator<< (std::ostream &out, const Bool &object)
 Output stream inserter for an Bool object. More...
 

Detailed Description

Wrapper for an bool value, for formatted ostream output.

An Bool object has a bool value, and a minimum output field width. The << operator for a Bool uses the specified width. The value and width may both be specified as parameters to a constructor. If the width is not specified as a constructor parameter, it is set within the constructor to the default Format::defaultWidth().

An Bool object may be passed to an ostream as a temporary object. For example, the expression:

std::cout << Bool(true) << Bool(false, 10) << std::endl;
Bool()
Default constructor.
Definition: Bool.cpp:15

outputs the value true using the default width, followed by the false value in a field of minimum width 10.

Definition at line 35 of file Bool.h.

Constructor & Destructor Documentation

◆ Bool() [1/3]

Util::Bool::Bool ( )

Default constructor.

Definition at line 15 of file Bool.cpp.

◆ Bool() [2/3]

Util::Bool::Bool ( bool  value)
explicit

Constructor, set value.

Parameters
valuevalue of the variable

Definition at line 21 of file Bool.cpp.

◆ Bool() [3/3]

Util::Bool::Bool ( bool  value,
int  width 
)

Constructor, value and width.

Parameters
valuevalue of the variable
widthoutput width (number of characters)

Definition at line 27 of file Bool.cpp.

Member Function Documentation

◆ setValue()

void Util::Bool::setValue ( bool  value)

Set the value.

Parameters
valuevalue of the variable

Definition at line 32 of file Bool.cpp.

References value().

◆ setWidth()

void Util::Bool::setWidth ( int  width)

Set the output width.

Parameters
widthoutput width (number of characters)

Definition at line 35 of file Bool.cpp.

References width().

◆ value()

bool Util::Bool::value ( )

Return value.

Definition at line 38 of file Bool.cpp.

Referenced by setValue().

◆ width()

int Util::Bool::width ( )

Return default width (number of characters).

Definition at line 41 of file Bool.cpp.

Referenced by setWidth().

Friends And Related Function Documentation

◆ operator>>

std::istream & operator>> ( std::istream &  in,
Bool object 
)
friend

Input stream extractor for an Bool object.

Parameters
ininput stream
objectBool object to be read from stream
Returns
modified input stream

Definition at line 47 of file Bool.cpp.

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const Bool object 
)
friend

Output stream inserter for an Bool object.

Parameters
outoutput stream
objectBool to be written to stream
Returns
modified output stream

Definition at line 56 of file Bool.cpp.


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