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

Wrapper for a double precision number, for formatted ostream output. More...

#include <Dbl.h>

Public Member Functions

Constructors
 Dbl ()
 Default constructor. More...
 
 Dbl (double value)
 Constructor, value only. More...
 
 Dbl (double value, int width)
 Constructor, value and width. More...
 
 Dbl (double value, int width, int precision, bool isFixed=false)
 Constructor: value, width, precision, and format. More...
 
Mutators
void setValue (double value)
 Set value of associated double. More...
 
void setWidth (int width)
 Set output field width. More...
 
void setPrecision (int precision)
 Set output floating point precision. More...
 

Accessors

double value ()
 Get value of associated double. More...
 
int width ()
 Get field width. More...
 
int precision ()
 Get floating point precision. More...
 
std::istream & operator>> (std::istream &in, Dbl &object)
 Input stream extractor for an Dbl object. More...
 
std::ostream & operator<< (std::ostream &out, const Dbl &object)
 Output stream inserter for an Dbl object. More...
 

Detailed Description

Wrapper for a double precision number, for formatted ostream output.

An Dbl object has a double precision numerical value, as well as members (width and precision) that control its output format. The << operator for an Dbl object uses the specified width and precision. The double precision number, the width and the precision may all be specified as parameters to one of several constructors. Values of width and precision that are not specified as parameters of a constructor are set within the constructor to default values given by Format::defaultWidth() and Format::defaultPrecision(), respectively.

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

std::cout << Dbl(2.0) << Dbl(3.0, 15, 8) << std::endl;
Dbl()
Default constructor.
Definition: Dbl.cpp:17

outputs the number 2.0 using the default width and precision, followed by the number 3.0 in a field of minimum width 15 and precision 8.

Definition at line 39 of file Dbl.h.

Constructor & Destructor Documentation

◆ Dbl() [1/4]

Util::Dbl::Dbl ( )

Default constructor.

Definition at line 17 of file Dbl.cpp.

◆ Dbl() [2/4]

Util::Dbl::Dbl ( double  value)
explicit

Constructor, value only.

Definition at line 25 of file Dbl.cpp.

◆ Dbl() [3/4]

Util::Dbl::Dbl ( double  value,
int  width 
)

Constructor, value and width.

Definition at line 33 of file Dbl.cpp.

◆ Dbl() [4/4]

Util::Dbl::Dbl ( double  value,
int  width,
int  precision,
bool  isFixed = false 
)

Constructor: value, width, precision, and format.

Definition at line 41 of file Dbl.cpp.

Member Function Documentation

◆ setValue()

void Util::Dbl::setValue ( double  value)

Set value of associated double.

Definition at line 48 of file Dbl.cpp.

References value().

◆ setWidth()

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

Set output field width.

Definition at line 51 of file Dbl.cpp.

References width().

◆ setPrecision()

void Util::Dbl::setPrecision ( int  precision)

Set output floating point precision.

Definition at line 54 of file Dbl.cpp.

References precision().

◆ value()

double Util::Dbl::value ( )

Get value of associated double.

Definition at line 57 of file Dbl.cpp.

Referenced by setValue().

◆ width()

int Util::Dbl::width ( )

Get field width.

Definition at line 60 of file Dbl.cpp.

Referenced by setWidth().

◆ precision()

int Util::Dbl::precision ( )

Get floating point precision.

Definition at line 63 of file Dbl.cpp.

Referenced by setPrecision().

Friends And Related Function Documentation

◆ operator>>

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

Input stream extractor for an Dbl object.

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

Definition at line 73 of file Dbl.cpp.

◆ operator<<

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

Output stream inserter for an Dbl object.

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

Definition at line 86 of file Dbl.cpp.


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