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:73
double convert(const std::string &unit) const
Definition: measurement-unit.cpp:15
Definition: measurement-unit.h:10
static MeasurementUnit fractionalDerivation(const MeasurementUnit &numerator, const MeasurementUnit &denominator, const std::string &separator)
Definition: measurement-unit.cpp:90
void addConversion(std::string unit, double multiplier)
Definition: measurement-unit.cpp:49
Definition: measurement-unit.h:140
std::string getBaseUnit() const
Definition: measurement-unit.cpp:35
MeasurementUnit & operator=(const MeasurementUnit &other)
Definition: measurement-unit.cpp:63
MeasurementUnit & combine(const MeasurementUnit &other)
Definition: measurement-unit.cpp:57
void addConversions(const conversionsMapType &conversions)
Definition: measurement-unit.cpp:53
Definition: measurement-unit.h:121
std::map< std::string, double > conversionsMapType
Definition: measurement-unit.h:17
MeasurementUnit(const std::string &base)
Definition: measurement-unit.cpp:5
std::set< std::string > getAllUnits() const
Definition: measurement-unit.cpp:39