SatDump 2.0.0-alpha-520736c72
Loading...
Searching...
No Matches
unit_parser.h File Reference

Utilities to help parse physical units. More...

#include <string>
#include <vector>

Go to the source code of this file.

Classes

struct  satdump::UnitInfo
 Unit information struct, that must be provided in a vector with all possible options and their corresponding power. More...

Functions

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.

Variables

const std::vector< UnitInfosatdump::UNIT_METER
 Unit declaration (to be used in parseUnitFromString) for Meters.
const std::vector< UnitInfosatdump::UNIT_HERTZ
 Unit declaration (to be used in parseUnitFromString) for Hertz.

Detailed Description

Utilities to help parse physical units.

Function Documentation

◆ 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
strinput string
outoutput value
unitunit to parse (must contain all expected representations)
Returns
true if parsing was sucessful

Variable Documentation

◆ 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.