6 #ifndef SWIFT_MISC_PQ_UNITS_H
7 #define SWIFT_MISC_PQ_UNITS_H
9 #pragma push_macro("min")
15 #include <QDBusArgument>
29 #define SWIFT_TEMPLATE_UNIT_MIXINS(MU, Extern, Export) \
30 namespace swift::misc::physical_quantities \
34 namespace swift::misc::private_ns \
36 Extern template struct Export CValueObjectMetaInfo<physical_quantities::MU>; \
37 Extern template struct Export MetaTypeHelper<physical_quantities::MU>; \
39 namespace swift::misc::mixin \
41 Extern template class Export MetaType<physical_quantities::MU>; \
42 Extern template class Export DBusOperators<physical_quantities::MU>; \
43 Extern template class Export DataStreamOperators<physical_quantities::MU>; \
44 Extern template class Export Index<physical_quantities::MU>; \
58 #if defined(Q_OS_WIN) && defined(Q_CC_GNU)
59 # define SWIFT_DECLARE_UNIT_MIXINS(MU)
60 # define SWIFT_DEFINE_UNIT_MIXINS(MU)
61 #elif defined(Q_OS_WIN) && defined(Q_CC_CLANG)
62 # define SWIFT_DECLARE_UNIT_MIXINS(MU) SWIFT_TEMPLATE_UNIT_MIXINS(MU, extern, )
63 # define SWIFT_DEFINE_UNIT_MIXINS(MU) SWIFT_TEMPLATE_UNIT_MIXINS(MU, , SWIFT_MISC_EXPORT)
65 # define SWIFT_DECLARE_UNIT_MIXINS(MU) SWIFT_TEMPLATE_UNIT_MIXINS(MU, extern, )
66 # define SWIFT_DEFINE_UNIT_MIXINS(MU) SWIFT_TEMPLATE_UNIT_MIXINS(MU, , )
86 namespace swift::misc::physical_quantities
99 struct NauticalMilesToMeters
101 static double factor() {
return 1852.0; }
105 static double factor() {
return 0.3048; }
109 static double factor() {
return 1609.344; }
111 struct StatuteMilesToMeters
113 static double factor() {
return 1609.3472; }
151 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"nautical mile")), constQLatin1(
"NM"),
167 static constexpr
CMeasurementUnit::Data km(constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"kilometer")),
176 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"centimeter")), constQLatin1(
"cm"),
193 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"statute mile")), constQLatin1(
"SM"),
211 argument >> unitName;
212 (*this) = CMeasurementUnit::unitFromSymbol<CLengthUnit>(unitName);
220 *
this = CMeasurementUnit::unitFromSymbol<CLengthUnit>(unitName);
235 struct RadiansToDegrees
237 static double factor() {
return 180.0 / M_PI; }
264 QString makeRoundedQStringWithUnit(
double value,
int digits = -1,
bool withGroupSeparator =
false,
265 bool i18n =
false)
const override;
270 static constexpr
CMeasurementUnit::Data rad(constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"radian")),
278 static constexpr
CMeasurementUnit::Data deg(constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"degree")),
279 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"deg")),
288 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"degree, minute, second")), constQLatin1(
"DMS"),
291 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"%L1 %L2 %L3");
292 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"-%L1 %L2 %L3");
299 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"degree, minute")), constQLatin1(
"MinDec"),
302 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"%L1 %L2");
303 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"-%L1 %L2");
318 argument >> unitName;
319 (*this) = CMeasurementUnit::unitFromSymbol<CAngleUnit>(unitName);
327 *
this = CMeasurementUnit::unitFromSymbol<CAngleUnit>(unitName);
378 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"kilohertz")), constQLatin1(
"kHz"),
387 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"megahertz")), constQLatin1(
"MHz"),
396 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"gigahertz")), constQLatin1(
"GHz"),
413 argument >> unitName;
414 (*this) = CMeasurementUnit::unitFromSymbol<CFrequencyUnit>(unitName);
422 *
this = CMeasurementUnit::unitFromSymbol<CFrequencyUnit>(unitName);
438 struct PoundsToKilograms
440 static double factor() {
return 0.45359237; }
468 static constexpr
CMeasurementUnit::Data kg(constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"kilogram")),
493 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"short ton")), constQLatin1(
"ton"),
518 argument >> unitName;
519 (*this) = CMeasurementUnit::unitFromSymbol<CMassUnit>(unitName);
527 *
this = CMeasurementUnit::unitFromSymbol<CMassUnit>(unitName);
543 struct PsiToHectopascals
545 static double factor() {
return 68.948; }
547 struct InchesToHectopascals
549 static double factor() {
return 33.86389; }
551 struct MillimetersToHectopascals
553 static double factor() {
return 860.142806; }
590 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"hectopascal")), constQLatin1(
"hPa"),
599 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"pound per square inch")), constQLatin1(
"psi"),
616 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"millibar")), constQLatin1(
"mbar"),
625 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"inch of mercury")), constQLatin1(
"inHg"),
634 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"millimeter of mercury")), constQLatin1(
"mmHg"),
653 argument >> unitName;
654 (*this) = CMeasurementUnit::unitFromSymbol<CPressureUnit>(unitName);
662 *
this = CMeasurementUnit::unitFromSymbol<CPressureUnit>(unitName);
677 struct KelvinToCentigrade
679 static double factor() {
return 1.0; }
680 static double offset() {
return 273.15; }
682 struct FahrenheitToCentigrade
684 static double factor() {
return 5.0 / 9.0; }
685 static double offset() {
return 32.0; }
721 static constexpr
CMeasurementUnit::Data C(constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"centigrade")),
722 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"C")),
730 static constexpr
CMeasurementUnit::Data F(constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"Fahrenheit")),
731 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"F")),
748 argument >> unitName;
749 (*this) = CMeasurementUnit::unitFromSymbol<CTemperatureUnit>(unitName);
757 *
this = CMeasurementUnit::unitFromSymbol<CTemperatureUnit>(unitName);
774 static double factor() {
return 1852.0 / 3600.0; }
778 static double factor() {
return 1.0 / 3.6; }
782 static double factor() {
return 0.3048; }
786 static double factor() {
return 0.3048 / 60.0; }
815 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"meter per second")), constQLatin1(
"m/s"),
832 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"nautical mile per hour")), constQLatin1(
"NM/h"),
841 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"foot per second")), constQLatin1(
"ft/s"),
850 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"foot per minute")), constQLatin1(
"ft/min"),
859 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"kilometer per hour")), constQLatin1(
"km/h"),
877 argument >> unitName;
878 (*this) = CMeasurementUnit::unitFromSymbol<CSpeedUnit>(unitName);
886 *
this = CMeasurementUnit::unitFromSymbol<CSpeedUnit>(unitName);
904 static double factor() {
return 60.0 * 60.0 * 24.0; }
906 struct HoursToSeconds
908 static double factor() {
return 60.0 * 60.0; }
910 struct MinutesToSeconds
912 static double factor() {
return 60.0; }
938 QString makeRoundedQStringWithUnit(
double value,
int digits = -1,
bool withGroupSeparator =
false,
939 bool i18n =
false)
const override;
953 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"millisecond")), constQLatin1(
"ms"),
970 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"minute")), constQLatin1(
"min"),
987 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"hour, minute, second")), constQLatin1(
"hms"),
990 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"%L1h%L2m%L3s");
991 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"%-L1h%L2m%L3s");
998 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"hour, minute")), constQLatin1(
"hm"),
1001 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"%L1h%L2m");
1002 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"-%L1h%L2m");
1009 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"minute, second")), constQLatin1(
"minsec"),
1012 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"%L1m%L2s");
1013 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"-%L1m%L2s");
1029 argument >> unitName;
1030 (*this) = CMeasurementUnit::unitFromSymbol<CTimeUnit>(unitName);
1038 *
this = CMeasurementUnit::unitFromSymbol<CTimeUnit>(unitName);
1055 static double factor() {
return 0.3048; }
1084 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"meter per second per second")),
1085 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"m/s^2")),
IdentityConverter(), 1);
1093 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"foot per second per second")),
1110 argument >> unitName;
1111 (*this) = CMeasurementUnit::unitFromSymbol<CAccelerationUnit>(unitName);
1119 *
this = CMeasurementUnit::unitFromSymbol<CAccelerationUnit>(unitName);
1135 #pragma pop_macro("min")
CRTP class template which will generate marshalling operators for a derived class with its own marsha...
CRTP class template to generate non-member QDataStream streaming operators.
CRTP class template from which a derived class can inherit property indexing functions.
Specialized class for acceleration units (m/s2, ft/s2).
static CAccelerationUnit defaultUnit()
Default unit.
static CAccelerationUnit ft_s2()
Feet/second^2.
void unmarshallFromDbus(const QDBusArgument &argument)
Unmarshall without begin/endStructure, for when composed within another object.
void unmarshalFromDataStream(QDataStream &stream)
Unmarshal a value from a QDataStream.
static CAccelerationUnit nullUnit()
Null unit.
CAccelerationUnit(std::nullptr_t)
Null constructor.
static CAccelerationUnit m_s2()
Meter/second^2 (m/s^2)
static const QList< CAccelerationUnit > & allUnits()
All units.
Specialized class for angles (degrees, radian).
static CAngleUnit sexagesimalDegMin()
Sexagesimal degree (degrees, minutes, decimal minutes)
void unmarshallFromDbus(const QDBusArgument &argument)
Unmarshall without begin/endStructure, for when composed within another object.
static CAngleUnit rad()
Radians.
static CAngleUnit nullUnit()
Null unit.
static const QList< CAngleUnit > & allUnits()
All units.
static CAngleUnit deg()
Degrees.
static CAngleUnit sexagesimalDeg()
Sexagesimal degree (degrees, minutes, seconds, decimal seconds)
static CAngleUnit defaultUnit()
Default unit.
CAngleUnit(std::nullptr_t)
Null constructor.
void unmarshalFromDataStream(QDataStream &stream)
Unmarshal a value from a QDataStream.
Specialized class for frequency (hertz, mega hertz, kilo hertz).
static CFrequencyUnit Hz()
Hertz.
static CFrequencyUnit nullUnit()
Null unit.
void unmarshallFromDbus(const QDBusArgument &argument)
Unmarshall without begin/endStructure, for when composed within another object.
static CFrequencyUnit MHz()
Megahertz.
static const QList< CFrequencyUnit > & allUnits()
All units.
CFrequencyUnit(std::nullptr_t)
Null constructor.
static CFrequencyUnit defaultUnit()
Default unit.
static CFrequencyUnit kHz()
Kilohertz.
static CFrequencyUnit GHz()
Gigahertz.
void unmarshalFromDataStream(QDataStream &stream)
Unmarshal a value from a QDataStream.
Specialized class for distance units (meter, foot, nautical miles).
void unmarshalFromDataStream(QDataStream &stream)
Unmarshal a value from a QDataStream.
static CLengthUnit km()
Kilometer km.
static CLengthUnit nullUnit()
Null unit.
static const QList< CLengthUnit > & allUnits()
All units.
static CLengthUnit m()
Meter m.
static CLengthUnit SM()
Statute mile.
static CLengthUnit NM()
Nautical miles NM.
static CLengthUnit ft()
Foot ft.
CLengthUnit(std::nullptr_t)
Null constructor.
static CLengthUnit mi()
International mile.
static CLengthUnit defaultUnit()
Default unit.
static CLengthUnit cm()
Centimeter cm.
void unmarshallFromDbus(const QDBusArgument &argument)
Unmarshall without begin/endStructure, for when composed within another object.
Specialized class for mass units (kg, lbs).
static const QList< CMassUnit > & allUnits()
All units.
CMassUnit(std::nullptr_t)
Null constructor.
static CMassUnit tonne()
Tonne, aka metric ton (1000kg)
static CMassUnit defaultUnit()
Default unit.
static CMassUnit shortTon()
Short ton (2000lb) used in the United States.
static CMassUnit g()
Gram, SI unit.
void unmarshalFromDataStream(QDataStream &stream)
Unmarshal a value from a QDataStream.
void unmarshallFromDbus(const QDBusArgument &argument)
Unmarshall without begin/endStructure, for when composed within another object.
static CMassUnit nullUnit()
Null unit.
static CMassUnit lb()
Pound, aka mass pound.
static CMassUnit kg()
Kilogram, SI base unit.
Base class for all units, such as meter, hertz.
CMeasurementUnit(const Data &data)
Constructor.
Specialized class for pressure (psi, hPa, bar).
static CPressureUnit nullUnit()
Null unit.
static CPressureUnit bar()
Bar.
CPressureUnit(std::nullptr_t)
Null constructor.
static CPressureUnit mbar()
Millibar, actually the same as hPa.
static CPressureUnit mmHg()
Millimeter of mercury.
static CPressureUnit Pa()
Pascal.
static CPressureUnit inHg()
Inch of mercury at 0°C.
static const QList< CPressureUnit > & allUnits()
All units.
static CPressureUnit psi()
Pounds per square inch.
static CPressureUnit defaultUnit()
Default unit.
void unmarshalFromDataStream(QDataStream &stream)
Unmarshal a value from a QDataStream.
static CPressureUnit hPa()
Hectopascal.
void unmarshallFromDbus(const QDBusArgument &argument)
Unmarshall without begin/endStructure, for when composed within another object.
Specialized class for speed units (m/s, ft/s, NM/h).
void unmarshallFromDbus(const QDBusArgument &argument)
Unmarshall without begin/endStructure, for when composed within another object.
static CSpeedUnit NM_h()
Nautical miles per hour NM/h (same as kts)
static const QList< CSpeedUnit > & allUnits()
All units.
static CSpeedUnit ft_s()
Feet/second ft/s.
static CSpeedUnit ft_min()
Feet/min ft/min.
void unmarshalFromDataStream(QDataStream &stream)
Unmarshal a value from a QDataStream.
static CSpeedUnit km_h()
Kilometer/hour km/h.
CSpeedUnit(std::nullptr_t)
Null constructor.
static CSpeedUnit m_s()
Meter/second m/s.
static CSpeedUnit kts()
Knots.
static CSpeedUnit defaultUnit()
Default unit.
static CSpeedUnit nullUnit()
Null unit.
Specialized class for temperatur units (kelvin, centidegree).
static const QList< CTemperatureUnit > & allUnits()
All units.
static CTemperatureUnit defaultUnit()
Default unit.
void unmarshallFromDbus(const QDBusArgument &argument)
Unmarshall without begin/endStructure, for when composed within another object.
static CTemperatureUnit nullUnit()
Null unit.
static CTemperatureUnit C()
Centigrade C.
static CTemperatureUnit K()
Kelvin.
CTemperatureUnit(std::nullptr_t)
Null constructor.
static CTemperatureUnit F()
Fahrenheit F.
void unmarshalFromDataStream(QDataStream &stream)
Unmarshal a value from a QDataStream.
Specialized class for time units (ms, hour, min).
static CTimeUnit min()
Minute.
void unmarshalFromDataStream(QDataStream &stream)
Unmarshal a value from a QDataStream.
static CTimeUnit nullUnit()
Null unit.
static CTimeUnit defaultUnit()
Default unit.
static CTimeUnit hrmin()
Hours, minutes.
CTimeUnit(std::nullptr_t)
Null constructor.
void unmarshallFromDbus(const QDBusArgument &argument)
Unmarshall without begin/endStructure, for when composed within another object.
static CTimeUnit hms()
Hours, minutes, seconds.
static CTimeUnit s()
Second s.
static CTimeUnit minsec()
Minutes, seconds.
static const QList< CTimeUnit > & allUnits()
All units.
static CTimeUnit ms()
Millisecond ms.
static CTimeUnit h()
Hour.
Concrete strategy pattern for converting unit with offset linear conversion.
Metapolicy that can be used to modify template parameters of converters.
Metapolicy that can be used to modify template parameters of converters.
Concrete strategy pattern for converting unit that does nothing.
Metapolicy that can be used to modify template parameters of converters.
Metapolicy that can be used to modify template parameters of converters.
Concrete strategy pattern for converting unit with linear conversion.
Metapolicy that can be used to modify template parameters of converters.
Metapolicy that can be used to modify template parameters of converters.
Metapolicy that can be used to modify template parameters of converters.
Concrete strategy pattern for converting unit with two subdivision conversions.
Concrete strategy pattern for converting unit with one subdivision conversion.
Metapolicy that can be used to modify template parameters of converters.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_UNIT_MIXINS(MU)
Explicit template declaration of mixins for a CMeasurementUnit subclass to be placed near the top of ...