Cantera
2.1.2
|
This class provides some printing and cropping utilities for writing to the logfile. More...
#include <LogPrintCtrl.h>
Public Member Functions | |
LogPrintCtrl (int Ndec=-1000) | |
Constructor. More... | |
~LogPrintCtrl () | |
Destructor. 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... | |
int | setNdec (int nDecades) |
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... | |
Private Attributes | |
std::ostringstream | m_os |
local stringstream class for temp output More... | |
std::ostream * | m_ffss |
Pointer to the ostream where this class actually prints its information. More... | |
PrintCtrl * | m_pc |
Pointer to the PrintCtrl class. More... | |
This class provides some printing and cropping utilities for writing to the logfile.
This class writes its output to Cantera's logfile utility. It's a wrapper around PrintCtrl object. First, we direct PrintCtrl to write to a string and then we redirect the string to the logfile utility. This is a first cut, and it's pretty much a kluge. The logfile utility, however, demands a string, and this is what I came up with.
Definition at line 37 of file LogPrintCtrl.h.
LogPrintCtrl | ( | int | Ndec = -1000 | ) |
Constructor.
This also serves to initialize the ticks within the object
Ndec | value of Ndec. Defaults to -1000, i.e., no decade cropping |
Definition at line 21 of file LogPrintCtrl.cpp.
References LogPrintCtrl::m_ffss, LogPrintCtrl::m_os, LogPrintCtrl::m_pc, and Cantera::warn_deprecated().
~LogPrintCtrl | ( | ) |
Destructor.
Definition at line 30 of file LogPrintCtrl.cpp.
References LogPrintCtrl::m_ffss, and LogPrintCtrl::m_pc.
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.
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 LogPrintCtrl.cpp.
References LogPrintCtrl::m_os, LogPrintCtrl::m_pc, PrintCtrl::pr_de(), and Cantera::writelog().
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.
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 36 of file LogPrintCtrl.cpp.
References LogPrintCtrl::m_os, LogPrintCtrl::m_pc, PrintCtrl::pr_de_c10(), and Cantera::writelog().
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.
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 57 of file LogPrintCtrl.cpp.
References PrintCtrl::cropSigDigits(), and LogPrintCtrl::m_pc.
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.
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 52 of file LogPrintCtrl.cpp.
References PrintCtrl::cropAbs10(), and LogPrintCtrl::m_pc.
int setNdec | ( | int | nDecades | ) |
Set the default value of N decade.
nDecades | new value of Ndec |
Definition at line 62 of file LogPrintCtrl.cpp.
References LogPrintCtrl::m_pc, and PrintCtrl::setNdec().
int setSigDigits | ( | int | sigDigits | ) |
Set the default significant digits to output.
sigDigits | new value of the sig digits |
Definition at line 67 of file LogPrintCtrl.cpp.
References LogPrintCtrl::m_pc, and PrintCtrl::setSigDigits().
int setWmin | ( | int | wMin | ) |
Set the default minimum width.
wMin | Default minimum width |
Definition at line 72 of file LogPrintCtrl.cpp.
References LogPrintCtrl::m_pc, and PrintCtrl::setWmin().
int setWmax | ( | int | wMax | ) |
Set the default maximum width.
wMax | Default maximum width |
Definition at line 77 of file LogPrintCtrl.cpp.
References LogPrintCtrl::m_pc, and PrintCtrl::setWmax().
|
private |
local stringstream class for temp output
Definition at line 154 of file LogPrintCtrl.h.
Referenced by LogPrintCtrl::LogPrintCtrl(), LogPrintCtrl::pr_de(), and LogPrintCtrl::pr_de_c10().
|
private |
Pointer to the ostream where this class actually prints its information.
Definition at line 158 of file LogPrintCtrl.h.
Referenced by LogPrintCtrl::LogPrintCtrl(), and LogPrintCtrl::~LogPrintCtrl().
|
private |
Pointer to the PrintCtrl class.
Definition at line 161 of file LogPrintCtrl.h.
Referenced by LogPrintCtrl::cropAbs10(), LogPrintCtrl::cropSigDigits(), LogPrintCtrl::LogPrintCtrl(), LogPrintCtrl::pr_de(), LogPrintCtrl::pr_de_c10(), LogPrintCtrl::setNdec(), LogPrintCtrl::setSigDigits(), LogPrintCtrl::setWmax(), LogPrintCtrl::setWmin(), and LogPrintCtrl::~LogPrintCtrl().