Cantera  2.0
PrintCtrl Class Reference

This class provides some printing and cropping utilities. More...

#include <PrintCtrl.h>

## Public Types

enum  CROP_TYPE { CT_OFF =0, CT_OFF_GLOBALOBEY, CT_ON_GLOBALOBEY, CT_ON }
enum for cropping control More...

enum  CROP_TYPE_GLOBAL { GCT_NOPREF = 0, GCT_CROP, GCT_NOCROP }
enum for global cropping control More...

## Public Member Functions

PrintCtrl (std::ostream &coutProxy=std::cout, int Ndec=-1000, CROP_TYPE ctlocal=CT_ON)
Constructor.

void pr_de (const double d, int sigDigits=-1, const int wMin=-1, const int wMax=-1)
Print a double using scientific notation.

void pr_de_c10 (const double d, int sigDigits=-1, const int wMin=-1, const int wMax=-1)
Print a double using scientific notation cropping decade values.

double cropSigDigits (const double d, int sigDigits) const
Crop a double at a certain number of significant digits.

double cropAbs10 (const double d, const int nDecades) const
Crop a double at a certain decade level.

Set the default value of N decade.

int setSigDigits (int sigDigits)
Set the default significant digits to output.

int setWmin (int wMin)
Set the default minimum width.

int setWmax (int wMax)
Set the default maximum width.

void setCropCntrl (CROP_TYPE ctlocal)
Set the cropping control flag.

## Static Public Attributes

static CROP_TYPE_GLOBAL GlobalCrop = GCT_NOPREF
static enum for turning on and off cropping

## Private Member Functions

bool doCrop () const
private function to figure out cropping logic

## Private Attributes

std::ostream & m_cout
This is the ostream to send all output from the object.

int m_Ndec

int m_precision
default precision level to use in printing

int m_wMin
default minimimum field width

int m_wMax
Default maximum field width.

CROP_TYPE m_cropCntrl
Local Cropping Control.

## Detailed Description

This class provides some printing and cropping utilities.

The class is used to provide some formatting options for printing out real numbers to files and to standard output. Specifically, it can make sure that a max and min field width is honored when conducting IO of numbers and strings. Basically, it's the spot to house all wrappers around commonly used printing facilities.

It can also handle cropping of numbers below a certain decade level. This is useful for IO for testing purposes. For example, if you don't care about anything below 1.0E-20, you can set up the IO so that it won't print out any digits below 1.0E-20, even digits that are in numbers greater than 1.0E-20. In other words the number

1.12345E-19

would be cropped to the value

1.1000E-19

The class wraps around a single std::ostream class. Its cropping functions are also available as a "double" conversion utility.

Definition at line 51 of file PrintCtrl.h.

## Member Enumeration Documentation

 enum CROP_TYPE

enum for cropping control

Enumerator:
 CT_OFF Turn off cropping always. CT_OFF_GLOBALOBEY Turn off cropping, unless the global toggle is turned on. CT_ON_GLOBALOBEY Turn on cropping unless the global toggle is turned off. CT_ON Turn on cropping always.

Definition at line 56 of file PrintCtrl.h.

 enum CROP_TYPE_GLOBAL

enum for global cropping control

Enumerator:
 GCT_NOPREF no preference for global cropping GCT_CROP global toggle for turning on cropping GCT_NOCROP global toggle for turning off cropping

Definition at line 68 of file PrintCtrl.h.

## Constructor & Destructor Documentation

 PrintCtrl ( std::ostream & coutProxy = std::cout, int Ndec = -1000, CROP_TYPE ctlocal = CT_ON )

Constructor.

This also serves to initialize the ticks within the object

Parameters
 coutProxy This is a reference to the ostream to use for all IO from ths object. Ndec value of Ndec. Defaults to -1000, i.e., no decade cropping ctlocal The default is to turn on cropping all the time.

Definition at line 30 of file PrintCtrl.cpp.

## Member Function Documentation

 void pr_de ( const double d, int sigDigits = -1, const int wMin = -1, const int wMax = -1 )

Print a double using scientific notation.

Prints a double using scientific notation in a fixed number of spaces.

The precision of the number will be adjusted to fit into the maximum space.

Parameters
 d double to be printed sigDigits Number of significant digits (-1 = default, means to use the default number for the object, which is initially set to 13. wMin Minimum number of spaces to print out wMax Maximum number of spaces to print out

Definition at line 71 of file PrintCtrl.cpp.

Referenced by LogPrintCtrl::pr_de(), and PrintCtrl::pr_de_c10().

 void pr_de_c10 ( const double d, int sigDigits = -1, const int wMin = -1, const int wMax = -1 )

Print a double using scientific notation cropping decade values.

Prints a double using scientific notation in a fixed number of spaces. This routine also crops number below the default decade level.

The precision of the number will be adjusted to fit into the maximum space.

Parameters
 d double to be printed sigDigits Number of significant digits (-1 = default, means to use the default number for the object, which is initially set to 13. wMin Minimum number of spaces to print out wMax Maximum number of spaces to print out

Definition at line 54 of file PrintCtrl.cpp.

References PrintCtrl::cropAbs10(), PrintCtrl::m_Ndec, and PrintCtrl::pr_de().

Referenced by LogPrintCtrl::pr_de_c10().

 double cropSigDigits ( const double d, int sigDigits ) const

Crop a double at a certain number of significant digits.

This routine will crop a floating point number at a certain number of significant digits. Note, it does rounding up of the last digit.

Parameters
 d Double to be cropped sigDigits Number of significant digits example: d = 1.0305E-15; nsig = 3; This routine will return 1.03E-15

Definition at line 190 of file PrintCtrl.cpp.

References PrintCtrl::doCrop().

Referenced by PrintCtrl::cropAbs10(), and LogPrintCtrl::cropSigDigits().

 double cropAbs10 ( const double d, const int nDecades ) const

Crop a double at a certain decade level.

This routine will crop a floating point number at a certain decade lvl. In other words everything below a power of 10^Ndec will be deleted. Note, it does rounding up of the last digit.

Parameters
 d Double to be cropped nDecades Number of significant digits example: d = 1.1305E-15; nDecades = -16; This routine will return 1.1E-15

d = 8.0E-17 nDecades = -16 This routine will return 0.0

Definition at line 156 of file PrintCtrl.cpp.

References PrintCtrl::cropSigDigits(), and PrintCtrl::doCrop().

 int setNdec ( int nDecades )

Set the default value of N decade.

Parameters
Returns
returns the old value of Ndec

Definition at line 230 of file PrintCtrl.cpp.

References PrintCtrl::m_Ndec.

Referenced by LogPrintCtrl::setNdec().

 int setSigDigits ( int sigDigits )

Set the default significant digits to output.

Parameters
 sigDigits new value of the sig digits
Returns
returns the old value of Ndec

Definition at line 243 of file PrintCtrl.cpp.

References PrintCtrl::m_precision.

Referenced by LogPrintCtrl::setSigDigits().

 int setWmin ( int wMin )

Set the default minimum width.

Parameters
 wMin Default minimum width
Returns
returns the old default

Definition at line 259 of file PrintCtrl.cpp.

References PrintCtrl::m_wMin.

Referenced by LogPrintCtrl::setWmin().

 int setWmax ( int wMax )

Set the default maximum width.

Parameters
 wMax Default maximum width
Returns
returns the old default

Definition at line 273 of file PrintCtrl.cpp.

References PrintCtrl::m_wMax.

Referenced by LogPrintCtrl::setWmax().

 void setCropCntrl ( CROP_TYPE ctlocal )

Set the cropping control flag.

Parameters
 ctlocal Local enum value for the cropping type

Definition at line 295 of file PrintCtrl.cpp.

References PrintCtrl::m_cropCntrl.

 bool doCrop ( ) const
private

private function to figure out cropping logic

Returns
Returns the decision as to whether to crop or not

Definition at line 280 of file PrintCtrl.cpp.

Referenced by PrintCtrl::cropAbs10(), and PrintCtrl::cropSigDigits().

## Member Data Documentation

 PrintCtrl::CROP_TYPE_GLOBAL GlobalCrop = GCT_NOPREF
static

static enum for turning on and off cropping

The default is to not have a preference for cropping

Definition at line 81 of file PrintCtrl.h.

Referenced by PrintCtrl::doCrop().

 std::ostream& m_cout
private

This is the ostream to send all output from the object.

It defaults to cout

Definition at line 223 of file PrintCtrl.h.

Referenced by PrintCtrl::pr_de().

 int m_Ndec
private

This is initially set to -1000, which means that no cropping will be carried out

Definition at line 230 of file PrintCtrl.h.

Referenced by PrintCtrl::pr_de_c10(), and PrintCtrl::setNdec().

 int m_precision
private

default precision level to use in printing

This actually is one less than the number of significant digits.

Initially set to 12

Definition at line 238 of file PrintCtrl.h.

Referenced by PrintCtrl::pr_de(), and PrintCtrl::setSigDigits().

 int m_wMin
private

default minimimum field width

Initially, this is set to 9

Definition at line 244 of file PrintCtrl.h.

Referenced by PrintCtrl::pr_de(), and PrintCtrl::setWmin().

 int m_wMax
private

Default maximum field width.

Initially this is set to 19

Definition at line 250 of file PrintCtrl.h.

Referenced by PrintCtrl::pr_de(), and PrintCtrl::setWmax().

 CROP_TYPE m_cropCntrl
private

Local Cropping Control.

Definition at line 253 of file PrintCtrl.h.

Referenced by PrintCtrl::doCrop(), and PrintCtrl::setCropCntrl().

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