CoastalME (Coastal Modelling Environment)
Simulates the long-term behaviour of complex coastlines
|
Globally-available utility routines. More...
#include <cmath>
#include <cfloat>
#include <cstdio>
#include <sstream>
#include <ios>
#include <iomanip>
#include "cme.h"
Go to the source code of this file.
Data Structures | |
class | istringstream |
STL class. More... | |
Functions | |
double | dRound (double const d) |
Correctly rounds doubles. | |
int | nRound (double const d) |
Version of the above that returns an int. | |
bool | bIsStringValidDouble (string &str) |
Checks to see if a string can be read as a valid double number. Does not find trailing (i.e.post-number) rubbish, but then neither does strtod(). From https://stackoverflow.com/questions/392981/how-can-i-convert-string-to-double-in-c. | |
bool | bIsStringValidInt (string &str) |
Checks to see if a string can be read as a valid integer, from https://stackoverflow.com/questions/2844817/how-do-i-check-if-a-c-string-is-an-int. | |
ostream & | operator<< (ostream &ostr, const FillToWidth &args) |
Operator that inserts a given fill character, to a given width, into an output stream. From http://stackoverflow.com/questions/2839592/equivalent-of-02d-with-stdstringstream. | |
string | strDbl (double const dX, int const nDigits) |
Converts double to string with specified number of places after the decimal. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c. | |
string | strDblRight (double const dX, int const nDigits, int const nWidth, bool const bShowDash) |
Converts double to string with specified number of decimal places, within a field of given width, pads with blank spaces to enforce right alignment. Modified from https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c. | |
string | strIntRight (int const nX, int const nWidth) |
Converts int to string within a field of given width, pads with blank spaces to enforce alignment.. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c. | |
string | strCentre (const char *pchIn, int const nWidth) |
Centre-aligns char array within a field of given width, pads with blank spaces to enforce alignment. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c. | |
string | strCentre (const string &strIn, int const nWidth) |
Centre-aligns string within a field of given width, pads with blank spaces to enforce alignment. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c. | |
string | strRight (const string &strIn, int const nWidth) |
Right-aligns string within a field of given width, pads with blank spaces to enforce alignment. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c. | |
string | strRight (const char *pchIn, int const nWidth) |
Right-aligns char array within a field of given width, pads with blank spaces to enforce alignment. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c. | |
string | strLeft (const string &strIn, int const nWidth) |
Left-aligns string within a field of given width, pads with blank spaces to enforce alignment. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c. | |
string | strLeft (const char *pchIn, int const nWidth) |
Left-aligns char array within a field of given width, pads with blank spaces to enforce alignment. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c. | |
string | strRightPerCent (double const d1, double const d2, int const nWidth, int const nDigits, bool const bShowDash) |
Calculates a percentage from two numbers then, if the result is non-zero, right-aligns the result as a string within a field of given width, pads with blank spaces to enforce alignment. Modified from https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c. | |
Globally-available utility routines.
TODO 001 A more detailed description of these routines.
Definition in file utils_global.cpp.
bool bIsStringValidDouble | ( | string & | str | ) |
Checks to see if a string can be read as a valid double number. Does not find trailing (i.e.post-number) rubbish, but then neither does strtod(). From https://stackoverflow.com/questions/392981/how-can-i-convert-string-to-double-in-c.
Definition at line 71 of file utils_global.cpp.
Referenced by CSimulation::bReadRunDataFile(), CSimulation::nReadSedimentInputEventFile(), CSimulation::nReadShapeFunctionFile(), CSimulation::nReadTideDataFile(), and CSimulation::nReadWaveStationInputFile().
bool bIsStringValidInt | ( | string & | str | ) |
Checks to see if a string can be read as a valid integer, from https://stackoverflow.com/questions/2844817/how-do-i-check-if-a-c-string-is-an-int.
Definition at line 85 of file utils_global.cpp.
Referenced by CSimulation::bParseDate(), CSimulation::bParseTime(), CSimulation::bReadRunDataFile(), CSimulation::nReadSedimentInputEventFile(), CSimulation::nReadWaveStationInputFile(), and CSimulation::ulConvertToTimestep().
double dRound | ( | double const | d | ) |
Correctly rounds doubles.
Definition at line 47 of file utils_global.cpp.
Referenced by CSimulation::bTimeToQuit(), CSimulation::bWriteRasterGISFile(), CSimulation::strDispTime(), and CSimulation::ulConvertToTimestep().
int nRound | ( | double const | d | ) |
Version of the above that returns an int.
Definition at line 56 of file utils_global.cpp.
Referenced by CGeom2DIPoint::AddXAddY(), CSimulation::AppendEnsureNoGap(), CSimulation::CreateRasterizedProfile(), CGeom2DIPoint::DivXDivY(), CSimulation::DoShadowZoneAndDownDriftZone(), CSimulation::InterpolateWavePropertiesBetweenProfiles(), CSimulation::KeepWithinValidGrid(), CSimulation::nConvertMetresToNumCells(), CSimulation::nDoAllShadowZones(), CSimulation::nDoSedimentInputEvent(), CSimulation::nDoSimulation(), CSimulation::nGetCoastNormalEndPoint(), CSimulation::nLocateAndCreateGridEdgeProfile(), CSimulation::PtiExtCRSToGridRound(), CGeomCoastPolygon::PtiGetFillStartPoint(), CSimulation::PtiGetPerpendicular(), CSimulation::PtiGetPerpendicular(), CSimulation::PtiWeightedAverage(), CSimulation::RasterizeCliffCollapseProfile(), and CSimulation::RasterizePolygonJoiningLine().
Operator that inserts a given fill character, to a given width, into an output stream. From http://stackoverflow.com/questions/2839592/equivalent-of-02d-with-stdstringstream.
Definition at line 103 of file utils_global.cpp.
string strCentre | ( | const char * | pchIn, |
int const | nWidth ) |
Centre-aligns char array within a field of given width, pads with blank spaces to enforce alignment. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c.
Definition at line 167 of file utils_global.cpp.
Referenced by CSimulation::DoEndOfTimestepTotals(), CSimulation::WritePolygonActualMovement(), CSimulation::WritePolygonCliffCollapseErosion(), CSimulation::WritePolygonPotentialErosion(), CSimulation::WritePolygonPreExistingSedimentTable(), CSimulation::WritePolygonSedimentBeforeMovement(), CSimulation::WritePolygonSedimentInputEventTable(), CSimulation::WritePolygonShareTable(), CSimulation::WritePolygonShorePlatformErosion(), CSimulation::WritePolygonSortedSequence(), and CSimulation::WritePolygonUnsortedSequence().
Centre-aligns string within a field of given width, pads with blank spaces to enforce alignment. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c.
Definition at line 187 of file utils_global.cpp.
string strDbl | ( | double const | dX, |
int const | nDigits ) |
Converts double to string with specified number of places after the decimal. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c.
Definition at line 114 of file utils_global.cpp.
string strDblRight | ( | double const | dX, |
int const | nDigits, | ||
int const | nWidth, | ||
bool const | bShowDash ) |
Converts double to string with specified number of decimal places, within a field of given width, pads with blank spaces to enforce right alignment. Modified from https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c.
Definition at line 126 of file utils_global.cpp.
Referenced by CSimulation::DoEndOfTimestepTotals(), CSimulation::WritePolygonActualMovement(), CSimulation::WritePolygonCliffCollapseErosion(), CSimulation::WritePolygonPotentialErosion(), CSimulation::WritePolygonPreExistingSedimentTable(), CSimulation::WritePolygonSedimentBeforeMovement(), CSimulation::WritePolygonSedimentInputEventTable(), CSimulation::WritePolygonShareTable(), and CSimulation::WritePolygonShorePlatformErosion().
string strIntRight | ( | int const | nX, |
int const | nWidth ) |
Converts int to string within a field of given width, pads with blank spaces to enforce alignment.. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c.
Definition at line 153 of file utils_global.cpp.
Referenced by CSimulation::WritePolygonActualMovement(), CSimulation::WritePolygonCliffCollapseErosion(), CSimulation::WritePolygonPotentialErosion(), CSimulation::WritePolygonPreExistingSedimentTable(), CSimulation::WritePolygonSedimentBeforeMovement(), CSimulation::WritePolygonSedimentInputEventTable(), CSimulation::WritePolygonShareTable(), CSimulation::WritePolygonShorePlatformErosion(), CSimulation::WritePolygonSortedSequence(), and CSimulation::WritePolygonUnsortedSequence().
string strLeft | ( | const char * | pchIn, |
int const | nWidth ) |
Left-aligns char array within a field of given width, pads with blank spaces to enforce alignment. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c.
Definition at line 248 of file utils_global.cpp.
Left-aligns string within a field of given width, pads with blank spaces to enforce alignment. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c.
Definition at line 235 of file utils_global.cpp.
Referenced by CSimulation::DoEndOfTimestepTotals(), and CSimulation::WritePolygonActualMovement().
string strRight | ( | const char * | pchIn, |
int const | nWidth ) |
Right-aligns char array within a field of given width, pads with blank spaces to enforce alignment. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c.
Definition at line 220 of file utils_global.cpp.
Right-aligns string within a field of given width, pads with blank spaces to enforce alignment. From https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c.
Definition at line 206 of file utils_global.cpp.
Referenced by CSimulation::WritePolygonSortedSequence().
string strRightPerCent | ( | double const | d1, |
double const | d2, | ||
int const | nWidth, | ||
int const | nDigits, | ||
bool const | bShowDash ) |
Calculates a percentage from two numbers then, if the result is non-zero, right-aligns the result as a string within a field of given width, pads with blank spaces to enforce alignment. Modified from https://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c.
Definition at line 262 of file utils_global.cpp.
Referenced by CSimulation::DoEndOfTimestepTotals().