Map from unit to the multiplier required to convert to the base unit, eg. km -> 1000.
fnss::MeasurementUnit::MeasurementUnit |
( |
const std::string & |
base_ | ) |
|
Constructor.
- Parameters
-
the | base the unit base(eg. sec, m). |
fnss::MeasurementUnit::MeasurementUnit |
( |
const std::string & |
base_, |
|
|
const conversionsMapType & |
conversions_ |
|
) |
| |
Constructor.
- Parameters
-
the | base the unit base(eg. sec, m). |
the | conversion map. |
void fnss::MeasurementUnit::addConversion |
( |
std::string |
unit, |
|
|
double |
multiplier |
|
) |
| |
Add or overwrite a conversion unit.
- Parameters
-
unit | the unit the conversion if from. |
multiplier | the multiplier of the conversion. |
Adds conversion unit. Does not overwrite exiting units.
- Parameters
-
conversions | conversionsMapType object to add. |
Insert all the units from other
into this
. Does not overwrite existing units. Does not change this->base
and other->base
is just added to the conversions map.
- Parameters
-
other | the object to add the units from. |
- Returns
- reference to for chaining.
double fnss::MeasurementUnit::convert |
( |
const std::string & |
unit | ) |
const |
Convert the given unit to the base unit. Throws an exception if the conversion is not found in this->conversions
.
- Returns
- unit conversion multiplier.
double fnss::MeasurementUnit::convert |
( |
const std::string & |
unit1, |
|
|
const std::string & |
unit2 |
|
) |
| const |
Convert between the given units. Throws an exception if the conversion is not found in this->conversions
.
- Returns
- the multiplier required to convert
unit1
to unit2
.
Get an object with all the combinations of numerator
over denominator
units possible. The created unit string representation is "numerator +
separator + denominator".
- Parameters
-
numerator | the numerator unit. |
denominator | the denominator unit. |
separator | the separator used in the string representation. |
- Returns
- the resulting unit.
std::set< std::string > fnss::MeasurementUnit::getAllUnits |
( |
| ) |
const |
Get a std::set
of all known units for this measure(eg. ms, us, mm).
- Returns
- a
std::set
of all known units for this measure.
std::string fnss::MeasurementUnit::getBaseUnit |
( |
| ) |
const |
Get the base unit.
- Returns
- the base unit.
Assignment operator. Throws an exception if trying to assign an object with a different this->base
.
Get an object with units constructed by applying all the units in the prefix
object to all the units in the target
object.
- Parameters
-
prefix | the prefix unit. |
target | the target unit. |
The documentation for this class was generated from the following files: