Qt Virtual Chart Table (QVCT)
CUnitSpeedVertical.hpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Qt Virtual Chart Table (QVCT)
5  * Copyright (C) 2012 Cedric Dufour <http://cedric.dufour.name>
6  * Author: Cedric Dufour <http://cedric.dufour.name>
7  *
8  * The Qt Virtual Chart Table (QVCT) is free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Qt Virtual Chart Table (QVCT) is distributed in the hope
13  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU General Public License for more details.
17  */
18 
19 #ifndef QVCT_CUNITSPEEDVERTICAL_HPP
20 #define QVCT_CUNITSPEEDVERTICAL_HPP
21 
22 // QT
23 #include <QMap>
24 #include <QString>
25 
26 // QVCT
27 class CUnitSpeedVerticalSymbols; // see below
28 class CUnitSpeedVerticalCodes; // see below
29 
30 
32 
38 {
39 
40  //------------------------------------------------------------------------------
41  // CONSTANTS / STATIC
42  //------------------------------------------------------------------------------
43 
44 public:
46  enum EUnit {
47  M_S,
49  UNDEFINED
50  };
51 
52 private:
57 
58 public:
60  static const QMap<EUnit,QString> &symbols();
62  static QString toSymbol( EUnit _eUnit );
64  static EUnit fromSymbol( const QString& _rqsSymbol );
66  static const QMap<EUnit,QString> &codes();
68  static QString toCode( EUnit _eUnit );
70  static EUnit fromCode( const QString& _rqsCode );
72  static double toValue( double _fdValue, EUnit _eUnit );
74  static QString toString( double _fdValue, EUnit _eUnit, int _iPrecision = 0 );
76  static QString toString( double _fdValue );
78 
87  static double fromString( const QString& _rqString, EUnit _eUnit, bool* _pbOK = 0 );
89  static double fromString( const QString& _rqString, bool* _pbOK = 0 );
90 
91 };
92 
95 {
96  friend class CUnitSpeedVertical;
97 
98  //------------------------------------------------------------------------------
99  // CONSTRUCTORS / DESTRUCTOR
100  //------------------------------------------------------------------------------
101 
102 private:
104  {
105  qMapSymbols.insert( CUnitSpeedVertical::M_S, "m/s" );
106  qMapSymbols.insert( CUnitSpeedVertical::FT_MIN, "ft/min" );
107  };
108  QMap<CUnitSpeedVertical::EUnit,QString> qMapSymbols;
109 };
110 
113 {
114  friend class CUnitSpeedVertical;
115 
116  //------------------------------------------------------------------------------
117  // CONSTRUCTORS / DESTRUCTOR
118  //------------------------------------------------------------------------------
119 
120 private:
122  {
123  qMapCodes.insert( CUnitSpeedVertical::M_S, "m_s" );
124  qMapCodes.insert( CUnitSpeedVertical::FT_MIN, "ft_min" );
125  };
126  QMap<CUnitSpeedVertical::EUnit,QString> qMapCodes;
127 };
128 
129 #endif // QVCT_CUNITSPEEDVERTICAL_HPP
Container class for supported machine-friendly format/unit codes.
QMap< CUnitSpeedVertical::EUnit, QString > qMapCodes
Container class for supported human-readable format/unit symbols.
QMap< CUnitSpeedVertical::EUnit, QString > qMapSymbols
Vertical speed unit (m/s,ft/min) rendering/parsing class.
static double toValue(double _fdValue, EUnit _eUnit)
Returns the converted value, using the specified format/unit.
static QString toSymbol(EUnit _eUnit)
Returns the human-readable symbol corresponding to the given format/unit ID.
static const QMap< EUnit, QString > & symbols()
Returns the list of supported human-readable format/unit symbols.
static double fromString(const QString &_rqString, EUnit _eUnit, bool *_pbOK=0)
Returns the numeric value corresponding (parsed) from the string.
@ FT_MIN
feet per minut [ft/min]
@ UNDEFINED
undefined format/unit
@ M_S
meters per second [m/s]
static const CUnitSpeedVerticalCodes oUnitSpeedVerticalCodes
Container for supported machine-friendly format/unit codes.
static const CUnitSpeedVerticalSymbols oUnitSpeedVerticalSymbols
Container for supported human-readable format/unit symbols.
static const QMap< EUnit, QString > & codes()
Returns the list of supported machine-friendly format/unit codes.
static EUnit fromSymbol(const QString &_rqsSymbol)
Returns the format/unit ID corresponding to the given human-readable symbol.
static EUnit fromCode(const QString &_rqsCode)
Returns the format/unit ID corresponding to the given machine-friendly code.
static QString toCode(EUnit _eUnit)
Returns the machine-friendly code corresponding to the given format/unit ID.
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 pr...