Loxahatchee  v0.0.1-1346
Lox Convenience C++ Library
Lox::Prices Namespace Reference

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 &cents)
 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...
 

Detailed Description

Common functions to work with dollar amounts.

Function Documentation

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.

Returns
TRUE if the absolute difference between 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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

bool Lox::Prices::validate ( const std::string &  str)

Determine if the text is a valid dollar string.

References Lox::Numbers::parse().

Here is the call graph for this function: