Utilities to help parse physical units.
More...
#include <string>
#include <vector>
Go to the source code of this file.
|
| struct | satdump::UnitInfo |
| | Unit information struct, that must be provided in a vector with all possible options and their corresponding power. More...
|
Utilities to help parse physical units.
◆ parseUnitFromString()
| bool satdump::parseUnitFromString |
( |
std::string | str, |
|
|
double & | out, |
|
|
std::vector< UnitInfo > | unit ) |
Parse an unit down to its SI base (eg, Hz) from a string, for user-friendly input.
- Parameters
-
| str | input string |
| out | output value |
| unit | unit to parse (must contain all expected representations) |
- Returns
- true if parsing was sucessful
◆ UNIT_HERTZ
| const std::vector<UnitInfo> satdump::UNIT_HERTZ |
Initial value:= {
{"THz", 1e12},
{"GHz", 1e9},
{"MHz", 1e6},
{"kHz", 1e3},
{"hHz", 1e2},
{"daHz", 1e1},
{"Hz", 1},
{"dHz", 1e-1},
{"cHz", 1e-2},
{"mHz", 1e-3},
{"uHz", 1e-6},
{"nHz", 1e-9},
{"pHz", 1e-12},
}
Unit declaration (to be used in parseUnitFromString) for Hertz.
◆ UNIT_METER
| const std::vector<UnitInfo> satdump::UNIT_METER |
Initial value:= {
{"Tm", 1e12},
{"Gm", 1e9},
{"Mm", 1e6},
{"km", 1e3},
{"hm", 1e2},
{"dam", 1e1},
{"m", 1},
{"dm", 1e-1},
{"cm", 1e-2},
{"mm", 1e-3},
{"um", 1e-6},
{"nm", 1e-9},
{"pm", 1e-12},
}
Unit declaration (to be used in parseUnitFromString) for Meters.