Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FNumericUnit< NumericType > Struct Template Reference

#include <UnitConversion.h>

Public Member Functions

 FNumericUnit ()
 
 FNumericUnit (const NumericType &InValue, EUnit InUnits=EUnit::Unspecified)
 
 FNumericUnit (const FNumericUnit &Other)
 
FNumericUnitoperator= (const FNumericUnit &Other)
 
template<typename OtherType >
 FNumericUnit (const FNumericUnit< OtherType > &Other)
 
template<typename OtherType >
FNumericUnitoperator= (const FNumericUnit< OtherType > &Other)
 
TOptional< FNumericUnit< NumericType > > ConvertTo (EUnit ToUnits) const
 
FNumericUnit< NumericType > QuantizeUnitsToBestFit () const
 
template<typename OtherType >
FNumericUnit< NumericType > & operator= (const FNumericUnit< OtherType > &Other)
 

Static Public Member Functions

static TValueOrError< FNumericUnit< NumericType >, FTextTryParseExpression (const TCHAR *InExpression, EUnit InDefaultUnit, const FNumericUnit< NumericType > &InExistingValue)
 
static TOptional< FNumericUnit< NumericType > > TryParseString (const TCHAR *InSource)
 

Public Attributes

NumericType Value
 
const EUnit Units
 

Private Member Functions

 operator const NumericType & () const
 
template<typename OtherType >
void CopyValueWithConversion (const FNumericUnit< OtherType > &Other)
 

Static Private Member Functions

static bool ExtractNumberBoundary (const TCHAR *Start, const TCHAR *&End)
 

Friends

template<typename OtherType >
bool operator== (const FNumericUnit< NumericType > &LHS, const FNumericUnit< OtherType > &RHS)
 
template<typename OtherType >
bool operator!= (const FNumericUnit< NumericType > &LHS, const FNumericUnit< OtherType > &RHS)
 

Detailed Description

template<typename NumericType>
struct FNumericUnit< NumericType >

FNumericUnit is a numeric type that wraps the templated type, whilst a specified unit. It handles conversion to/from related units automatically. The units are considered not to contribute to the type's state, and as such should be considered immutable once set.

Definition at line 148 of file UnitConversion.h.

Constructor & Destructor Documentation

◆ FNumericUnit() [1/4]

template<typename NumericType >
FNumericUnit< NumericType >::FNumericUnit ( )

Constructors

Definition at line 212 of file UnitConversion.inl.

◆ FNumericUnit() [2/4]

template<typename NumericType >
FNumericUnit< NumericType >::FNumericUnit ( const NumericType & InValue,
EUnit InUnits = EUnit::Unspecified )

Definition at line 217 of file UnitConversion.inl.

◆ FNumericUnit() [3/4]

template<typename NumericType >
FNumericUnit< NumericType >::FNumericUnit ( const FNumericUnit< NumericType > & Other)

Copy construction/assignment from the same type

Definition at line 222 of file UnitConversion.inl.

◆ FNumericUnit() [4/4]

template<typename NumericType >
template<typename OtherType >
FNumericUnit< NumericType >::FNumericUnit ( const FNumericUnit< OtherType > & Other)

Templated Copy construction/assignment from differing numeric types. Relies on implicit conversion of the two numeric types.

Definition at line 237 of file UnitConversion.inl.

Member Function Documentation

◆ ConvertTo()

template<typename NumericType >
TOptional< FNumericUnit< NumericType > > FNumericUnit< NumericType >::ConvertTo ( EUnit ToUnits) const

Convert this quantity to a different unit

Definition at line 251 of file UnitConversion.inl.

◆ CopyValueWithConversion()

template<typename NumericType >
template<typename OtherType >
void FNumericUnit< NumericType >::CopyValueWithConversion ( const FNumericUnit< OtherType > & Other)
private

Copy another unit into this one, taking account of its units, and applying necessary conversion

Definition at line 325 of file UnitConversion.inl.

◆ ExtractNumberBoundary()

template<typename NumericType >
bool FNumericUnit< NumericType >::ExtractNumberBoundary ( const TCHAR * Start,
const TCHAR *& End )
staticprivate

Given a string, skip past whitespace, then any numeric characters. Set End pointer to the end of the last numeric character.

Definition at line 356 of file UnitConversion.inl.

◆ operator const NumericType &()

template<typename NumericType >
FNumericUnit< NumericType >::operator const NumericType & ( ) const
private

Conversion to the numeric type disabled as coupled with implicit construction from NumericType can easily lead to loss of associated units.

◆ operator=() [1/3]

template<typename NumericType >
FNumericUnit< NumericType > & FNumericUnit< NumericType >::operator= ( const FNumericUnit< NumericType > & Other)

Definition at line 229 of file UnitConversion.inl.

◆ operator=() [2/3]

template<typename NumericType >
template<typename OtherType >
FNumericUnit & FNumericUnit< NumericType >::operator= ( const FNumericUnit< OtherType > & Other)

◆ operator=() [3/3]

template<typename NumericType >
template<typename OtherType >
FNumericUnit< NumericType > & FNumericUnit< NumericType >::operator= ( const FNumericUnit< OtherType > & Other)

Definition at line 243 of file UnitConversion.inl.

◆ QuantizeUnitsToBestFit()

template<typename NumericType >
FNumericUnit< NumericType > FNumericUnit< NumericType >::QuantizeUnitsToBestFit ( ) const

Quantizes this number to the most appropriate unit for user friendly presentation (e.g. 1000m returns 1km).

Definition at line 266 of file UnitConversion.inl.

◆ TryParseExpression()

template<typename NumericType >
TValueOrError< FNumericUnit< NumericType >, FText > FNumericUnit< NumericType >::TryParseExpression ( const TCHAR * InExpression,
EUnit InDefaultUnit,
const FNumericUnit< NumericType > & InExistingValue )
static

Try and parse an expression into a numeric unit

Definition at line 272 of file UnitConversion.inl.

◆ TryParseString()

template<typename NumericType >
TOptional< FNumericUnit< NumericType > > FNumericUnit< NumericType >::TryParseString ( const TCHAR * InSource)
static

Parse a numeric unit from a string

Definition at line 285 of file UnitConversion.inl.

Friends And Related Symbol Documentation

◆ operator!=

template<typename NumericType >
template<typename OtherType >
bool operator!= ( const FNumericUnit< NumericType > & LHS,
const FNumericUnit< OtherType > & RHS )
friend

Definition at line 219 of file UnitConversion.h.

◆ operator==

template<typename NumericType >
template<typename OtherType >
bool operator== ( const FNumericUnit< NumericType > & LHS,
const FNumericUnit< OtherType > & RHS )
friend

Global arithmetic operators for number types. Deals with conversion from related units correctly. Note must be inlined for hidden friend optimization to work

Definition at line 194 of file UnitConversion.h.

Member Data Documentation

◆ Units

template<typename NumericType >
const EUnit FNumericUnit< NumericType >::Units

The associated units for the value. Can never change once set to anything other than EUnit::Unspecified.

Definition at line 153 of file UnitConversion.h.

◆ Value

template<typename NumericType >
NumericType FNumericUnit< NumericType >::Value

The numeric (scalar) value

Definition at line 151 of file UnitConversion.h.


The documentation for this struct was generated from the following files: