Qt Virtual Chart Table (QVCT)
CUnitElevation.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_CUNITELEVATION_HPP
20 #define QVCT_CUNITELEVATION_HPP
21 
22 // QT
23 #include <QMap>
24 #include <QString>
25 
26 // QVCT
27 class CUnitElevationSymbols; // see below
28 
29 
31 
37 {
38 
39  //------------------------------------------------------------------------------
40  // CONSTANTS / STATIC
41  //------------------------------------------------------------------------------
42 
43 public:
45  enum EUnit {
46  M,
47  FT,
48  UNDEFINED
49  };
50 
51 private:
54 
55 public:
57  static const QMap<EUnit,QString> &symbols();
59  static QString toSymbol( EUnit _eUnit );
61  static EUnit fromSymbol( const QString& _rqsSymbol );
63  static const QMap<EUnit,QString> &codes();
65  static QString toCode( EUnit _eUnit );
67  static EUnit fromCode( const QString& _rqsCode );
69  static double toValue( double _fdValue, EUnit _eUnit );
71  static QString toString( double _fdValue, EUnit _eUnit, int _iPrecision = 0 );
73  static QString toString( double _fdValue );
75 
84  static double fromString( const QString& _rqString, EUnit _eUnit = UNDEFINED, bool* _pbOK = 0 );
86  static double fromString( const QString& _rqString, bool* _pbOK = 0 );
87 
88 };
89 
92 {
93  friend class CUnitElevation;
94 
95  //------------------------------------------------------------------------------
96  // CONSTRUCTORS / DESTRUCTOR
97  //------------------------------------------------------------------------------
98 
99 private:
101  {
102  qMapSymbols.insert( CUnitElevation::M, "m" );
103  qMapSymbols.insert( CUnitElevation::FT, "ft" );
104  };
105  QMap<CUnitElevation::EUnit,QString> qMapSymbols;
106 };
107 
108 #endif // QVCT_CUNITELEVATION_HPP
Container class for supported human-readable format/unit symbols.
QMap< CUnitElevation::EUnit, QString > qMapSymbols
Elevation unit (m,ft) rendering/parsing class.
static double toValue(double _fdValue, EUnit _eUnit)
Returns the converted value, using the specified format/unit.
static const QMap< EUnit, QString > & codes()
Returns the list of supported machine-friendly format/unit codes.
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...
static QString toCode(EUnit _eUnit)
Returns the machine-friendly code corresponding to the given format/unit ID.
EUnit
Format/unit ID.
@ UNDEFINED
undefined 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 EUnit fromSymbol(const QString &_rqsSymbol)
Returns the format/unit ID corresponding to the given human-readable symbol.
static double fromString(const QString &_rqString, EUnit _eUnit=UNDEFINED, bool *_pbOK=0)
Returns the numeric value corresponding (parsed) from the string.
static EUnit fromCode(const QString &_rqsCode)
Returns the format/unit ID corresponding to the given machine-friendly code.
static const CUnitElevationSymbols oUnitElevationSymbols
Container for supported human-readable format/unit symbols.