Cantera  2.1.2
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. More...

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

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. More...

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

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

Set the default value of N decade. More...

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

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

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

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

## Static Public Attributes

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

## Private Member Functions

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

## Private Attributes

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

int m_Ndec

int m_precision
default precision level to use in printing More...

int m_wMin
default minimimum field width More...

int m_wMax
Default maximum field width. More...

CROP_TYPE m_cropCntrl
Local Cropping Control. More...

## 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.

Deprecated:
To be removed in Cantera 2.2.

Definition at line 50 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 54 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 66 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 25 of file PrintCtrl.cpp.

References Cantera::warn_deprecated().

## 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 44 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 37 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 133 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 111 of file PrintCtrl.cpp.

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

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

 int setNdec ( int nDecades )

Set the default value of N decade.

Parameters
Returns
returns the old value of Ndec

Definition at line 167 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 174 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 184 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 191 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 213 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 198 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 79 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 210 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 217 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 225 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 231 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 237 of file PrintCtrl.h.

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

 CROP_TYPE m_cropCntrl
private

Local Cropping Control.

Definition at line 240 of file PrintCtrl.h.

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

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