#include <convert_units.h>
Allow the user to convert between two different units after specifying a conversion factor. This class will also automatically combine two conversion factors to create a new unit conversion.
Conversions are performed by the convert() function and the conversion factors must be specified beforehand using the insert_cache() function.
Example:
convert_units cu; cu.insert_cache("in","cm",2.54); cout << "12 in is " << cu.convert("in","cm",12.0) << " cm. " << endl;
Definition at line 62 of file convert_units.h.
Data Structures | |
struct | unit_t |
The type for caching unit conversions. More... | |
Public Member Functions | |
virtual double | convert (std::string from, std::string to, double val) |
Return the value val after converting using units from and to . | |
int | insert_cache (std::string from, std::string to, double conv) |
Manually insert a unit conversion into the cache. | |
int | print_cache () |
Print the present unit cache. | |
int | energy_conv () |
Add conversion factors for energy equivalents. | |
Data Fields | |
int | verbose |
Verbosity (default 0). | |
Protected Types | |
typedef std::map< std::string, unit_t, string_comp > ::iterator | miter |
The iterator type. | |
Protected Attributes | |
std::map< std::string, unit_t, string_comp > | mcache |
The cache where unit conversions are stored. |
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page