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

Wrapper for an int, for formatted ostream output. More...

#include <Int.h>

Public Member Functions

Constructors
 Int ()
 Default constructor. More...
 
 Int (int value)
 Constructor, value only. More...
 
 Int (int value, int width)
 Constructor, value and width. More...
 
Setters
void setValue (int value)
 Set the integer value. More...
 
void setWidth (int width)
 Set the output field width. More...
 

Accessors

int value ()
 Get the integer value. More...
 
int width ()
 Get the minimum field width. More...
 
std::istream & operator>> (std::istream &in, Int &object)
 Input stream extractor for an Int object. More...
 
std::ostream & operator<< (std::ostream &out, const Int &object)
 Output stream inserter for an Int object. More...
 

Detailed Description

Wrapper for an int, for formatted ostream output.

An Int object has a int numerical value, and a minimum output field width. The << operator for an Int uses the specified width. The numerical 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 a default value equal to Format::defaultWidth().

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

std::cout << Int(13) << Int(25, 10) << std::endl;
Int()
Default constructor.
Definition: Int.cpp:19

outputs the number 13 using the default width, followed by the number 25 in a field of minimum width 10.

Definition at line 36 of file Int.h.

Constructor & Destructor Documentation

◆ Int() [1/3]

Util::Int::Int ( )

Default constructor.

Definition at line 19 of file Int.cpp.

◆ Int() [2/3]

Util::Int::Int ( int  value)
explicit

Constructor, value only.

Definition at line 27 of file Int.cpp.

◆ Int() [3/3]

Util::Int::Int ( int  value,
int  width 
)

Constructor, value and width.

Definition at line 35 of file Int.cpp.

Member Function Documentation

◆ setValue()

void Util::Int::setValue ( int  value)

Set the integer value.

Parameters
valuevalue of the associated int variable

Definition at line 43 of file Int.cpp.

References value().

◆ setWidth()

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

Set the output field width.

Parameters
widthoutput field width

Definition at line 49 of file Int.cpp.

References width().

◆ value()

int Util::Int::value ( )

Get the integer value.

Definition at line 55 of file Int.cpp.

Referenced by setValue().

◆ width()

int Util::Int::width ( )

Get the minimum field width.

Definition at line 61 of file Int.cpp.

Referenced by setWidth().

Friends And Related Function Documentation

◆ operator>>

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

Input stream extractor for an Int object.

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

Definition at line 71 of file Int.cpp.

◆ operator<<

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

Output stream inserter for an Int object.

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

Definition at line 84 of file Int.cpp.


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