Common functions to work with dollar amounts. More...
Functions | |
std::string | format (const double &price) |
Format a numeric price into a standard price string. More... | |
bool | nearlyTheSame (const double a, const double b) |
Determine if the two values are nearly the same. More... | |
bool | parse (const std::string &str, double &price) |
Parse a text string and get back price information. More... | |
bool | parse (const std::string &str, double &dollars, double ¢s) |
Parse a text string and get back price information. More... | |
std::string | reformatStr (const std::string &str) |
If the input string is a valid price, reformat the string. Make no change if the string is not a valid price. More... | |
bool | validate (const std::string &str) |
Determine if the text is a valid dollar string. More... | |
Common functions to work with dollar amounts.
std::string Lox::Prices::format | ( | const double & | price | ) |
Format a numeric price into a standard price string.
bool Lox::Prices::nearlyTheSame | ( | const double | a, |
const double | b | ||
) |
Determine if the two values are nearly the same.
a
and b
is smaller than $0.01 bool Lox::Prices::parse | ( | const std::string & | str, |
double & | price | ||
) |
Parse a text string and get back price information.
References Lox::Numbers::parse().
bool Lox::Prices::parse | ( | const std::string & | str, |
double & | dollars, | ||
double & | cents | ||
) |
Parse a text string and get back price information.
std::string Lox::Prices::reformatStr | ( | const std::string & | str | ) |
If the input string is a valid price, reformat the string. Make no change if the string is not a valid price.
References Lox::Numbers::format(), and Lox::Numbers::parse().
bool Lox::Prices::validate | ( | const std::string & | str | ) |
Determine if the text is a valid dollar string.
References Lox::Numbers::parse().