Qt Virtual Chart Table (QVCT)
CUnitDistance Class Reference

Distance unit (m,km,ft,mi,nm) rendering/parsing class. More...

#include <units/CUnitDistance.hpp>

Public Types

enum  EUnit {
  M , KM , FT , MI ,
  NM , UNDEFINED
}
 Format/unit ID. More...
 

Static Public Member Functions

static const QMap< EUnit, QString > & symbols ()
 Returns the list of supported human-readable format/unit symbols. More...
 
static QString toSymbol (EUnit _eUnit)
 Returns the human-readable symbol corresponding to the given format/unit ID. More...
 
static EUnit fromSymbol (const QString &_rqsSymbol)
 Returns the format/unit ID corresponding to the given human-readable symbol. More...
 
static const QMap< EUnit, QString > & codes ()
 Returns the list of supported machine-friendly format/unit codes. More...
 
static QString toCode (EUnit _eUnit)
 Returns the machine-friendly code corresponding to the given format/unit ID. More...
 
static EUnit fromCode (const QString &_rqsCode)
 Returns the format/unit ID corresponding to the given machine-friendly code. More...
 
static double toValue (double _fdValue, EUnit _eUnit)
 Returns the converted value, using the specified format/unit. More...
 
static QString toString (double _fdValue, EUnit _eUnit, int _iPrecision=0)
 Returns the formatted represention of the given value, using the specified format/unit and decimal precision. More...
 
static QString toString (double _fdValue)
 Returns the formatted represention of the given value, using the application settings. More...
 
static double fromString (const QString &_rqString, EUnit _eUnit=UNDEFINED, bool *_pbOK=0)
 Returns the numeric value corresponding (parsed) from the string. More...
 
static double fromString (const QString &_rqString, bool *_pbOK=0)
 Returns the numeric value corresponding (parsed) from the string, using the application settings. More...
 

Static Private Attributes

static const CUnitDistanceSymbols oUnitDistanceSymbols
 Container for supported human-readable format/unit symbols. More...
 

Detailed Description

Distance unit (m,km,ft,mi,nm) rendering/parsing class.

This class allows to render/parse distance values according to the various supported (and user specified) formats/units.

Author
Cedric Dufour http://cedric.dufour.name

Definition at line 36 of file CUnitDistance.hpp.

Member Enumeration Documentation

◆ EUnit

Format/unit ID.

Enumerator

meters [m]

KM 

kilometers [km]

FT 

feet [ft]

MI 

statute miles [mi]

NM 

nautical miles [nm]

UNDEFINED 

undefined format/unit

Definition at line 45 of file CUnitDistance.hpp.

Member Function Documentation

◆ symbols()

const QMap< CUnitDistance::EUnit, QString > & CUnitDistance::symbols ( )
static

Returns the list of supported human-readable format/unit symbols.

Definition at line 35 of file CUnitDistance.cpp.

◆ toSymbol()

QString CUnitDistance::toSymbol ( CUnitDistance::EUnit  _eUnit)
static

Returns the human-readable symbol corresponding to the given format/unit ID.

Definition at line 40 of file CUnitDistance.cpp.

◆ fromSymbol()

CUnitDistance::EUnit CUnitDistance::fromSymbol ( const QString &  _rqsSymbol)
static

Returns the format/unit ID corresponding to the given human-readable symbol.

Definition at line 45 of file CUnitDistance.cpp.

◆ codes()

const QMap< CUnitDistance::EUnit, QString > & CUnitDistance::codes ( )
static

Returns the list of supported machine-friendly format/unit codes.

Definition at line 50 of file CUnitDistance.cpp.

◆ toCode()

QString CUnitDistance::toCode ( CUnitDistance::EUnit  _eUnit)
static

Returns the machine-friendly code corresponding to the given format/unit ID.

Definition at line 55 of file CUnitDistance.cpp.

◆ fromCode()

CUnitDistance::EUnit CUnitDistance::fromCode ( const QString &  _rqsCode)
static

Returns the format/unit ID corresponding to the given machine-friendly code.

Definition at line 60 of file CUnitDistance.cpp.

◆ toValue()

double CUnitDistance::toValue ( double  _fdValue,
CUnitDistance::EUnit  _eUnit 
)
static

Returns the converted value, using the specified format/unit.

Definition at line 65 of file CUnitDistance.cpp.

◆ toString() [1/2]

QString CUnitDistance::toString ( double  _fdValue,
CUnitDistance::EUnit  _eUnit,
int  _iPrecision = 0 
)
static

Returns the formatted represention of the given value, using the specified format/unit and decimal precision.

Definition at line 78 of file CUnitDistance.cpp.

◆ toString() [2/2]

QString CUnitDistance::toString ( double  _fdValue)
static

Returns the formatted represention of the given value, using the application settings.

Definition at line 91 of file CUnitDistance.cpp.

◆ fromString() [1/2]

double CUnitDistance::fromString ( const QString &  _rqString,
EUnit  _eUnit = UNDEFINED,
bool *  _pbOK = 0 
)
static

Returns the numeric value corresponding (parsed) from the string.

This methods will attempt to automatically detect the used format/unit. If the format/unit can not be determined, it will default to the (optionally) specified format/unit). The success of the parsing may be retrieved using the (optionally) supplied boolean flag.

Parameters
[in]_rqStringFormatted represention of the value
[in]_eUnitDefault format/unit (if none can be automatically determined)
[out]_pbOKParsing success status

Definition at line 97 of file CUnitDistance.cpp.

◆ fromString() [2/2]

double CUnitDistance::fromString ( const QString &  _rqString,
bool *  _pbOK = 0 
)
static

Returns the numeric value corresponding (parsed) from the string, using the application settings.

Definition at line 120 of file CUnitDistance.cpp.

Member Data Documentation

◆ oUnitDistanceSymbols

const CUnitDistanceSymbols CUnitDistance::oUnitDistanceSymbols
staticprivate

Container for supported human-readable format/unit symbols.

Definition at line 56 of file CUnitDistance.hpp.


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