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; }
117 virtual void anchor();
153 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"nautical mile")), constQLatin1(
"NM"),
169 static constexpr
CMeasurementUnit::Data km(constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"kilometer")),
178 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"centimeter")), constQLatin1(
"cm"),
195 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"statute mile")), constQLatin1(
"SM"),
213 argument >> unitName;
214 (*this) = CMeasurementUnit::unitFromSymbol<CLengthUnit>(unitName);
222 *
this = CMeasurementUnit::unitFromSymbol<CLengthUnit>(unitName);
237 struct RadiansToDegrees
239 static double factor() {
return 180.0 / M_PI; }
266 virtual QString makeRoundedQStringWithUnit(
double value,
int digits = -1,
bool withGroupSeparator =
false,
267 bool i18n =
false)
const override;
272 static constexpr
CMeasurementUnit::Data rad(constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"radian")),
280 static constexpr
CMeasurementUnit::Data deg(constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"degree")),
281 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"deg")),
290 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"degree, minute, second")), constQLatin1(
"DMS"),
293 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"%L1 %L2 %L3");
294 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"-%L1 %L2 %L3");
301 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"degree, minute")), constQLatin1(
"MinDec"),
304 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"%L1 %L2");
305 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"-%L1 %L2");
320 argument >> unitName;
321 (*this) = CMeasurementUnit::unitFromSymbol<CAngleUnit>(unitName);
329 *
this = CMeasurementUnit::unitFromSymbol<CAngleUnit>(unitName);
346 virtual void anchor();
382 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"kilohertz")), constQLatin1(
"kHz"),
391 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"megahertz")), constQLatin1(
"MHz"),
400 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"gigahertz")), constQLatin1(
"GHz"),
417 argument >> unitName;
418 (*this) = CMeasurementUnit::unitFromSymbol<CFrequencyUnit>(unitName);
426 *
this = CMeasurementUnit::unitFromSymbol<CFrequencyUnit>(unitName);
442 struct PoundsToKilograms
444 static double factor() {
return 0.45359237; }
447 virtual void anchor();
474 static constexpr
CMeasurementUnit::Data kg(constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"kilogram")),
499 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"short ton")), constQLatin1(
"ton"),
524 argument >> unitName;
525 (*this) = CMeasurementUnit::unitFromSymbol<CMassUnit>(unitName);
533 *
this = CMeasurementUnit::unitFromSymbol<CMassUnit>(unitName);
549 struct PsiToHectopascals
551 static double factor() {
return 68.948; }
553 struct InchesToHectopascals
555 static double factor() {
return 33.86389; }
557 struct MillimetersToHectopascals
559 static double factor() {
return 860.142806; }
562 virtual void anchor();
598 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"hectopascal")), constQLatin1(
"hPa"),
607 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"pound per square inch")), constQLatin1(
"psi"),
624 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"millibar")), constQLatin1(
"mbar"),
633 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"inch of mercury")), constQLatin1(
"inHg"),
642 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"millimeter of mercury")), constQLatin1(
"mmHg"),
661 argument >> unitName;
662 (*this) = CMeasurementUnit::unitFromSymbol<CPressureUnit>(unitName);
670 *
this = CMeasurementUnit::unitFromSymbol<CPressureUnit>(unitName);
685 struct KelvinToCentigrade
687 static double factor() {
return 1.0; }
688 static double offset() {
return 273.15; }
690 struct FahrenheitToCentigrade
692 static double factor() {
return 5.0 / 9.0; }
693 static double offset() {
return 32.0; }
696 virtual void anchor();
731 static constexpr
CMeasurementUnit::Data C(constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"centigrade")),
732 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"C")),
740 static constexpr
CMeasurementUnit::Data F(constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"Fahrenheit")),
741 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"F")),
758 argument >> unitName;
759 (*this) = CMeasurementUnit::unitFromSymbol<CTemperatureUnit>(unitName);
767 *
this = CMeasurementUnit::unitFromSymbol<CTemperatureUnit>(unitName);
784 static double factor() {
return 1852.0 / 3600.0; }
788 static double factor() {
return 1.0 / 3.6; }
792 static double factor() {
return 0.3048; }
796 static double factor() {
return 0.3048 / 60.0; }
799 virtual void anchor();
827 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"meter per second")), constQLatin1(
"m/s"),
844 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"nautical mile per hour")), constQLatin1(
"NM/h"),
853 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"foot per second")), constQLatin1(
"ft/s"),
862 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"foot per minute")), constQLatin1(
"ft/min"),
871 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"kilometer per hour")), constQLatin1(
"km/h"),
889 argument >> unitName;
890 (*this) = CMeasurementUnit::unitFromSymbol<CSpeedUnit>(unitName);
898 *
this = CMeasurementUnit::unitFromSymbol<CSpeedUnit>(unitName);
916 static double factor() {
return 60.0 * 60.0 * 24.0; }
918 struct HoursToSeconds
920 static double factor() {
return 60.0 * 60.0; }
922 struct MinutesToSeconds
924 static double factor() {
return 60.0; }
950 virtual QString makeRoundedQStringWithUnit(
double value,
int digits = -1,
bool withGroupSeparator =
false,
951 bool i18n =
false)
const override;
965 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"millisecond")), constQLatin1(
"ms"),
982 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"minute")), constQLatin1(
"min"),
999 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"hour, minute, second")), constQLatin1(
"hms"),
1002 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"%L1h%L2m%L3s");
1003 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"%-L1h%L2m%L3s");
1010 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"hour, minute")), constQLatin1(
"hm"),
1013 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"%L1h%L2m");
1014 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"-%L1h%L2m");
1021 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"minute, second")), constQLatin1(
"minsec"),
1024 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"%L1m%L2s");
1025 (void)QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"-%L1m%L2s");
1041 argument >> unitName;
1042 (*this) = CMeasurementUnit::unitFromSymbol<CTimeUnit>(unitName);
1050 *
this = CMeasurementUnit::unitFromSymbol<CTimeUnit>(unitName);
1067 static double factor() {
return 0.3048; }
1070 virtual void anchor();
1098 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"meter per second per second")),
1099 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"m/s^2")),
IdentityConverter(), 1);
1107 constQLatin1(QT_TRANSLATE_NOOP(
"CMeasurementUnit",
"foot per second per second")),
1124 argument >> unitName;
1125 (*this) = CMeasurementUnit::unitFromSymbol<CAccelerationUnit>(unitName);
1133 *
this = CMeasurementUnit::unitFromSymbol<CAccelerationUnit>(unitName);
1149 #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 ...