00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GENLIB2_ULENGTH_INCLUDED
00022 #define GENLIB2_ULENGTH_INCLUDED
00023
00024 #include <string>
00025
00026 using namespace std;
00027
00028 namespace GenLib2
00029 {
00030
00035 class UnitLength
00036 {
00037 public:
00039 enum ecode
00040 {
00042 UNKNOWN,
00043
00045 KILOMETRE,
00046
00048 METRE,
00049
00051 CENTIMETRE,
00052
00054 MILLIMETRE,
00055
00057 MICROMETRE,
00058
00060 MILE,
00061
00063 MILES_US,
00064
00066 INCH,
00067
00069 FEET,
00070
00072 YARD,
00073
00075 NAUTICAL_MILE
00076 };
00077
00083 bool set(const char* symbol);
00084
00086 UnitLength() { set("m"); }
00087
00092 UnitLength(const char* symbol) { set(symbol); }
00093
00095 virtual ~UnitLength() { }
00096
00101 double scale() const { return _scale; }
00102
00107 const char* symbol() const { return _map[_code].symbol; }
00108
00114 static ecode code(const char* symbol);
00115
00121 static const char* name(int code);
00122
00128 static const char* symbol(int code);
00129
00138 static double scale(int code);
00139
00140
00141
00142
00143
00144
00145
00146 protected:
00148 ecode _code;
00149
00151 double _scale;
00152
00154 static const int _map_size;
00155
00157 struct map_t
00158 {
00160 int code;
00161
00163 const char* symbol;
00164
00166 const char* name;
00167
00169 double scale;
00170 };
00171
00173 static map_t _map[];
00174 };
00175
00176
00177
00178
00179
00180
00181
00182 }
00183
00184 #endif