unit conversion class to easy the pain of conversions in dialogs.
More...
#include <UnitConversion.h>
|
| | UnitConverter ()=default |
| | Default constructor.
|
| |
| | UnitConverter (const std::string &unit, int sig_digits) |
| | Initializing constructor.
|
| |
| bool | set (const std::string &unit, int sig_digits) |
| | Retrieves the unit conversion using the passed values.
|
| |
| bool | set () |
| | Retrieves the unit conversion using the current set values
and passes them to the global function getUnitConversion.
|
| |
| double | getValue (double value) const |
| | Gets the converted value from an original one.
|
| |
| std::string | getString (double value) const |
| | Returns the converted value as a string using the digits.
|
| |
| std::string | getUnit () const |
| | Returns the unit after conversion.
|
| |
| int | getSigDigits () const |
| | Gets the significant digits after conversion.
|
| |
| bool | isValid () const |
| | Returns if there is a valid conversion present.
|
| |
| double | getOrgValue (double value) const |
| | Gets original value from the past converted value.
|
| |
| double | getOrgValue (const std::string &value, double def=0.0) const |
| | Gets the original value from the past string which may contain a calculation.
|
| |
| void | clear () |
| | clear the conversion and make it invalid.
|
| |
unit conversion class to easy the pain of conversions in dialogs.
Used dialogs to convert SI-unit's to be displayed as required and to store them as SI-units.
When performing scientific formula calculations in applications there is no need for obscure conversions since all values are in SI-units.
◆ UnitConverter() [1/2]
| sf::UnitConverter::UnitConverter |
( |
| ) |
|
|
default |
◆ UnitConverter() [2/2]
| sf::UnitConverter::UnitConverter |
( |
const std::string & |
unit, |
|
|
int |
sig_digits |
|
) |
| |
|
inline |
Initializing constructor.
- Parameters
-
| unit | Original unit. |
| sig_digits | Original significant digits. |
◆ clear()
| void sf::UnitConverter::clear |
( |
| ) |
|
|
inline |
clear the conversion and make it invalid.
Clearing makes this class pass through values unconverted.
◆ getOrgValue() [1/2]
| double sf::UnitConverter::getOrgValue |
( |
const std::string & |
value, |
|
|
double |
def = 0.0 |
|
) |
| const |
Gets the original value from the past string which may contain a calculation.
Calculations like:
"2*20+3"
"PI and sin(PI/2)"
This method parses the string and calls the other getOrgValue().
- Parameters
-
| value | String value to parse and to convert. |
| def | Default value when parsing the string fails. |
- Returns
- Original non converted value.
◆ getOrgValue() [2/2]
| double sf::UnitConverter::getOrgValue |
( |
double |
value | ) |
const |
Gets original value from the past converted value.
Turns converted value into original one.
- Parameters
-
- Returns
- Original non converted value.
◆ getSigDigits()
| int sf::UnitConverter::getSigDigits |
( |
| ) |
const |
|
inline |
Gets the significant digits after conversion.
- Returns
- If no valid conversion the original unit is returned.
◆ getString()
| std::string sf::UnitConverter::getString |
( |
double |
value | ) |
const |
Returns the converted value as a string using the digits.
Used to display this value appropriately.
- Parameters
-
| value | Value to turn into string. |
- Returns
- Value formatted into string using the digits.
◆ getUnit()
| std::string sf::UnitConverter::getUnit |
( |
| ) |
const |
|
inline |
Returns the unit after conversion.
- Returns
- If no valid conversion the original unit is returned.
◆ getValue()
| double sf::UnitConverter::getValue |
( |
double |
value | ) |
const |
Gets the converted value from an original one.
If not valid the passed value is returned in changed.
- Parameters
-
- Returns
- Converted value of the passed value.
◆ isValid()
| bool sf::UnitConverter::isValid |
( |
| ) |
const |
|
inline |
Returns if there is a valid conversion present.
- Returns
- True when valid.
◆ set() [1/2]
| bool sf::UnitConverter::set |
( |
| ) |
|
Retrieves the unit conversion using the current set values
and passes them to the global function getUnitConversion.
- Returns
- True when successful.
◆ set() [2/2]
| bool sf::UnitConverter::set |
( |
const std::string & |
unit, |
|
|
int |
sig_digits |
|
) |
| |
Retrieves the unit conversion using the passed values.
- Parameters
-
| unit | Original unit. |
| sig_digits | Original significant digits. |
- Returns
- True when successful.
The documentation for this class was generated from the following file: