5#include "Containers/Array.h"
6#include "Containers/UnrealString.h"
8#include "Delegates/Delegate.h"
9#include "Internationalization/Text.h"
10#include "Misc/Optional.h"
11#include "Templates/ValueOrError.h"
14template<
typename NumericType>
struct FNumericUnit;
66 Distance,
Angle,
Speed,
Temperature,
Mass,
Force,
Frequency,
DataSize,
LuminousFlux,
LuminousIntensity,
Illuminance,
Luminance,
Time,
PixelDensity,
Multipliers,
72template<
typename NumericType>
struct FNumericUnit;
144
145
146
147template<
typename NumericType>
161 FNumericUnit&
operator=(
const FNumericUnit& Other);
164 template<
typename OtherType>
FNumericUnit(
const FNumericUnit<OtherType>& Other);
165 template<
typename OtherType> FNumericUnit&
operator=(
const FNumericUnit<OtherType>& Other);
176 static TValueOrError<FNumericUnit<NumericType>,
FText>
TryParseExpression(
const TCHAR* InExpression,
EUnit InDefaultUnit,
const FNumericUnit<NumericType>& InExistingValue);
186 template<
typename OtherType>
193 template<
typename OtherType>
194 friend inline bool operator==(
const FNumericUnit<NumericType>& LHS,
const FNumericUnit<OtherType>& RHS)
196 if (LHS.Units != EUnit::Unspecified && RHS.Units != EUnit::Unspecified)
198 if (LHS.Units == RHS.Units)
200 return LHS.Value == RHS.Value;
202 else if (FUnitConversion::AreUnitsCompatible(LHS.Units, RHS.Units))
204 return LHS.Value == FUnitConversion::Convert(RHS.Value, RHS.Units, LHS.Units);
214 return LHS.Value == RHS.Value;
218 template<
typename OtherType>
219 friend inline bool operator!=(
const FNumericUnit<NumericType>& LHS,
const FNumericUnit<OtherType>& RHS)
221 return !(LHS == RHS);
232void LexFromString(FNumericUnit<T>& OutValue,
const TCHAR* String);
239#include "Math/UnitConversion.inl"
#define DECLARE_EVENT(OwningType, EventName)
FString LexToSanitizedString(const FNumericUnit< T > &NumericUnit)
bool LexTryParseString(FNumericUnit< T > &OutValue, const TCHAR *String)
void LexFromString(FNumericUnit< T > &OutValue, const TCHAR *String)
FString LexToString(const FNumericUnit< T > &NumericUnit)
bool ShouldDisplayUnits() const
const TArray< EUnit > & GetDisplayUnits(EUnitType InType) const
void SetShouldDisplayUnits(bool bInGlobalUnitDisplay)
void SetDisplayUnits(EUnitType InType, EUnit Units)
FDisplaySettingChanged & OnDisplaySettingsChanged()
void SetDisplayUnits(EUnitType InType, const TArray< EUnit > &Units)
FDisplaySettingChanged SettingChangedEvent
TOptional< FNumericUnit< NumericType > > ConvertTo(EUnit ToUnits) const
FNumericUnit & operator=(const FNumericUnit< OtherType > &Other)
static bool ExtractNumberBoundary(const TCHAR *Start, const TCHAR *&End)
operator const NumericType &() const
void CopyValueWithConversion(const FNumericUnit< OtherType > &Other)
static TValueOrError< FNumericUnit< NumericType >, FText > TryParseExpression(const TCHAR *InExpression, EUnit InDefaultUnit, const FNumericUnit< NumericType > &InExistingValue)
FNumericUnit(const NumericType &InValue, EUnit InUnits=EUnit::Unspecified)
FNumericUnit & operator=(const FNumericUnit &Other)
friend bool operator==(const FNumericUnit< NumericType > &LHS, const FNumericUnit< OtherType > &RHS)
FNumericUnit(const FNumericUnit &Other)
static TOptional< FNumericUnit< NumericType > > TryParseString(const TCHAR *InSource)
FNumericUnit< NumericType > QuantizeUnitsToBestFit() const
friend bool operator!=(const FNumericUnit< NumericType > &LHS, const FNumericUnit< OtherType > &RHS)
FNumericUnit(const FNumericUnit< OtherType > &Other)
static TOptional< EUnit > UnitFromString(const TCHAR *UnitString)
static FUnitSettings & Settings()
static bool IsUnitOfType(EUnit Unit, EUnitType Type)
static EUnitType GetUnitType(EUnit)
static EUnit CalculateDisplayUnit(T Value, EUnit InUnits)
static const TCHAR * GetUnitDisplayString(EUnit Unit)
static FNumericUnit< T > QuantizeUnitsToBestFit(T Value, EUnit Units)
static bool AreUnitsCompatible(EUnit From, EUnit To)
static T Convert(T InValue, EUnit From, EUnit To)