|
swift
|
Base class for all units, such as meter, hertz. More...
Classes | |
| struct | AffineConverter |
| Concrete strategy pattern for converting unit with offset linear conversion. More... | |
| struct | Centi |
| Metapolicy that can be used to modify template parameters of converters. More... | |
| struct | Data |
| Pimpl class. More... | |
| struct | Giga |
| Metapolicy that can be used to modify template parameters of converters. More... | |
| struct | Hecto |
| Metapolicy that can be used to modify template parameters of converters. More... | |
| struct | IdentityConverter |
| Concrete strategy pattern for converting unit that does nothing. More... | |
| struct | InEachHundred |
| Metapolicy that can be used to modify template parameters of converters. More... | |
| struct | Kilo |
| Metapolicy that can be used to modify template parameters of converters. More... | |
| struct | LinearConverter |
| Concrete strategy pattern for converting unit with linear conversion. More... | |
| struct | Mega |
| Metapolicy that can be used to modify template parameters of converters. More... | |
| struct | Milli |
| Metapolicy that can be used to modify template parameters of converters. More... | |
| struct | NilConverter |
| Converter for default values, such as None, used with public constructor. More... | |
| struct | One |
| Metapolicy that can be used to modify template parameters of converters. More... | |
| struct | SubdivisionConverter |
| Concrete strategy pattern for converting unit with one subdivision conversion. More... | |
| struct | SubdivisionConverter2 |
| Concrete strategy pattern for converting unit with two subdivision conversions. More... | |
| struct | Two |
| Metapolicy that can be used to modify template parameters of converters. More... | |
Public Member Functions | |
| CMeasurementUnit (const Data &&)=delete | |
| Constructor saves the address of its argument, so forbid rvalues. | |
| QString | convertToQString (bool i18n=false) const |
| Cast as QString. More... | |
| void | marshallToDbus (QDBusArgument &argument) const |
| Marshall without begin/endStructure, for when composed within another object. More... | |
| void | unmarshallFromDbus (const QDBusArgument &) |
| Unmarshall without begin/endStructure, for when composed within another object. More... | |
| void | marshalToDataStream (QDataStream &stream) const |
| Marshal a value to a QDataStream. More... | |
| void | unmarshalFromDataStream (QDataStream &) |
| Unmarshal a value from a QDataStream. More... | |
| QString | getName (bool i18n=false) const |
| Name such as "meter". | |
| QString | getSymbol (bool i18n=false) const |
| Unit name such as "m". | |
| bool | endsStringWithNameOrSymbol (const QString &candidate, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
| Does a string end with name or symbol? E.g. 3meter, 3m, 3deg. | |
| double | roundValue (double value, int digits=-1) const |
| Rounded value. More... | |
| double | roundToEpsilon (double value) const |
| Rounded to the nearest CMeasurementUnit::getEpsilon. More... | |
| virtual QString | makeRoundedQString (double value, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const |
| Rounded string utility method, virtual so units can have specialized formatting. More... | |
| virtual QString | makeRoundedQStringWithUnit (double value, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const |
| Value rounded with unit, e.g. "5.00m", "30kHz". More... | |
| double | getEpsilon () const |
| Threshold for comparions. | |
| int | getDisplayDigits () const |
| Display digits. | |
| double | convertFrom (double value, const CMeasurementUnit &unit) const |
| Convert from other unit to this unit. | |
| bool | isEpsilon (double value) const |
| Is given value <= epsilon? | |
| bool | isNull () const |
| Is unit null? | |
Public Member Functions inherited from swift::misc::mixin::String< CMeasurementUnit > | |
| QString | toQString (bool i18n=false) const |
| Cast as QString. | |
| std::string | toStdString (bool i18n=false) const |
| To std string. | |
| QString | stringForStreaming () const |
| String for streaming operators. | |
Public Member Functions inherited from swift::misc::mixin::Icon< CMeasurementUnit > | |
| CIcons::IconIndex | toIcon () const |
| As icon, not implemented by all classes. | |
Static Public Member Functions | |
| template<class U > | |
| static U | unitFromSymbol (const QString &symbol, bool strict=true) |
| Unit from symbol. More... | |
| template<class U > | |
| static const QStringList & | allSymbols () |
| All symbols. | |
| template<class U > | |
| static const QStringList & | allSymbolsLowerCase () |
| All symbols case insensitive. | |
| template<class U > | |
| static bool | hasCaseSensitiveSymbols () |
| Are symbols case sensitive? | |
| template<class U > | |
| static bool | isValidUnitSymbol (const QString &symbol) |
| Valid unit symbol? More... | |
| template<class U > | |
| static bool | isValidUnitSymbol (const QString &symbol, Qt::CaseSensitivity caseSensitivity) |
| Valid unit symbol? More... | |
| template<class U > | |
| static bool | containsValidUnitSymbol (const QString &candidate, Qt::CaseSensitivity caseSensitivity=Qt::CaseSensitive) |
| Contains valid unit symbol? More... | |
| template<class U > | |
| static bool | endWithValidUnitSymbol (const QString &candidate, Qt::CaseSensitivity caseSensitivity=Qt::CaseSensitive) |
| Ends with valid unit symbol? More... | |
| static CMeasurementUnit | None () |
| Dimensionless unit. | |
Protected Types | |
| using | ConverterFunction = double(*)(double) |
| Pointer to function for converting between units. | |
Protected Member Functions | |
| CMeasurementUnit (const Data &data) | |
| Constructor. | |
| ~CMeasurementUnit ()=default | |
| Destructor. | |
| CMeasurementUnit (const CMeasurementUnit &)=default | |
| Copy constructor. | |
| CMeasurementUnit & | operator= (const CMeasurementUnit &)=default |
| Copy assignment operator. | |
Static Protected Member Functions | |
| template<int N> | |
| static constexpr QLatin1String | constQLatin1 (const char(&str)[N]) |
| Constant-initialize QLatin1String without using strlen. | |
Friends | |
| bool | operator== (const CMeasurementUnit &a, const CMeasurementUnit &b) |
| Equal operator ==. | |
| bool | operator!= (const CMeasurementUnit &a, const CMeasurementUnit &b) |
| Unequal operator !=. | |
| size_t | qHash (const CMeasurementUnit &unit) |
| qHash overload, needed for storing value in a QSet. More... | |
Base class for all units, such as meter, hertz.
Definition at line 36 of file measurementunit.h.
|
inlinestatic |
Contains valid unit symbol?
| candidate | to be tested |
| caseSensitivity | check case sensitiv? |
Definition at line 457 of file measurementunit.h.
|
inline |
Cast as QString.
Definition at line 262 of file measurementunit.h.
|
inlinestatic |
Ends with valid unit symbol?
| candidate | to be tested |
| caseSensitivity | check case sensitiv? |
Definition at line 474 of file measurementunit.h.
|
inlinestatic |
|
inlinestatic |
Valid unit symbol?
| symbol | to be tested |
| caseSensitivity | check case sensitiv? |
Definition at line 443 of file measurementunit.h.
|
virtual |
Rounded string utility method, virtual so units can have specialized formatting.
Definition at line 40 of file measurementunit.cpp.
|
virtual |
Value rounded with unit, e.g. "5.00m", "30kHz".
Reimplemented in swift::misc::physical_quantities::CTimeUnit, and swift::misc::physical_quantities::CAngleUnit.
Definition at line 22 of file measurementunit.cpp.
|
inline |
Marshall without begin/endStructure, for when composed within another object.
Definition at line 265 of file measurementunit.h.
|
inline |
Marshal a value to a QDataStream.
Definition at line 276 of file measurementunit.h.
| double swift::misc::physical_quantities::CMeasurementUnit::roundToEpsilon | ( | double | value | ) | const |
Rounded to the nearest CMeasurementUnit::getEpsilon.
Definition at line 34 of file measurementunit.cpp.
| double swift::misc::physical_quantities::CMeasurementUnit::roundValue | ( | double | value, |
| int | digits = -1 |
||
| ) | const |
Rounded value.
Definition at line 28 of file measurementunit.cpp.
|
inlinestatic |
Unit from symbol.
| symbol | must be a valid unit symbol (without i18n) or empty string (empty means default unit) |
| strict | strict check means if unit is not found, program terminates |
Definition at line 367 of file measurementunit.h.
|
inline |
Unmarshal a value from a QDataStream.
Definition at line 279 of file measurementunit.h.
|
inline |
Unmarshall without begin/endStructure, for when composed within another object.
Definition at line 268 of file measurementunit.h.
|
friend |
qHash overload, needed for storing value in a QSet.
Definition at line 297 of file measurementunit.h.