1 #ifndef MEASUREMENT_UNIT_H
2 #define MEASUREMENT_UNIT_H
41 double convert(
const std::string &unit)
const;
49 double convert(
const std::string &unit1,
const std::string &unit2)
const;
119 const std::string &separator);
124 const std::string &unit2)
throw() {
125 this->exceptionStr =
"Unknown conversion from unit " + unit1
126 +
" to unit " + unit2 +
".";
132 const char* what()
const throw() {
133 return this->exceptionStr.c_str();
137 std::string exceptionStr;
143 const std::string &base2)
throw() {
144 this->exceptionStr =
"Base unit mismatch: " + base1
145 +
" and " + base2 +
".";
151 const char* what()
const throw() {
152 return this->exceptionStr.c_str();
156 std::string exceptionStr;
162 const std::string &base);
165 const std::string base;
173 #endif //MEASUREMENT_UNIT_H
static MeasurementUnit prefixDerivation(const MeasurementUnit &prefix, const MeasurementUnit &target)
Definition: measurement-unit.cpp:71
double convert(const std::string &unit) const
Definition: measurement-unit.cpp:13
Definition: measurement-unit.h:10
static MeasurementUnit fractionalDerivation(const MeasurementUnit &numerator, const MeasurementUnit &denominator, const std::string &separator)
Definition: measurement-unit.cpp:88
void addConversions(const conversionsMapType &conversions_)
Definition: measurement-unit.cpp:51
void addConversion(std::string unit, double multiplier)
Definition: measurement-unit.cpp:47
Definition: measurement-unit.h:140
MeasurementUnit(const std::string &base_)
Definition: measurement-unit.cpp:5
std::string getBaseUnit() const
Definition: measurement-unit.cpp:33
MeasurementUnit & operator=(const MeasurementUnit &other)
Definition: measurement-unit.cpp:61
MeasurementUnit & combine(const MeasurementUnit &other)
Definition: measurement-unit.cpp:55
Definition: measurement-unit.h:121
std::map< std::string, double > conversionsMapType
Definition: measurement-unit.h:17
std::set< std::string > getAllUnits() const
Definition: measurement-unit.cpp:37