SatDump 2.0.0-alpha-520736c72
Loading...
Searching...
No Matches
unit_parser.h
Go to the documentation of this file.
1#pragma once
2
7
8#include <string>
9#include <vector>
10
11namespace satdump
12{
18 struct UnitInfo
19 {
20 std::string name;
21 double scale;
22 };
23
28 const std::vector<UnitInfo> UNIT_METER = {
29 {"Tm", 1e12}, //
30 {"Gm", 1e9}, //
31 {"Mm", 1e6}, //
32 {"km", 1e3}, //
33 {"hm", 1e2}, //
34 {"dam", 1e1}, //
35 {"m", 1}, //
36 {"dm", 1e-1}, //
37 {"cm", 1e-2}, //
38 {"mm", 1e-3}, //
39 {"um", 1e-6}, //
40 {"nm", 1e-9}, //
41 {"pm", 1e-12}, //
42 };
43
48 const std::vector<UnitInfo> UNIT_HERTZ = {
49 {"THz", 1e12}, //
50 {"GHz", 1e9}, //
51 {"MHz", 1e6}, //
52 {"kHz", 1e3}, //
53 {"hHz", 1e2}, //
54 {"daHz", 1e1}, //
55 {"Hz", 1}, //
56 {"dHz", 1e-1}, //
57 {"cHz", 1e-2}, //
58 {"mHz", 1e-3}, //
59 {"uHz", 1e-6}, //
60 {"nHz", 1e-9}, //
61 {"pHz", 1e-12}, //
62 };
63
73 bool parseUnitFromString(std::string str, double &out, std::vector<UnitInfo> unit);
74} // namespace satdump
Unit information struct, that must be provided in a vector with all possible options and their corres...
Definition unit_parser.h:19
const std::vector< UnitInfo > UNIT_METER
Unit declaration (to be used in parseUnitFromString) for Meters.
Definition unit_parser.h:28
const std::vector< UnitInfo > UNIT_HERTZ
Unit declaration (to be used in parseUnitFromString) for Hertz.
Definition unit_parser.h:48