48 MooseUnits(Real f, Real s, std::vector<std::pair<MooseUnits::BaseUnit, int>> b)
60 void parse(
const std::string & unit_string);
66 static const std::map<std::string, Real>
_si_prefix;
67 static const std::vector<std::pair<std::string, MooseUnits>>
_unit_table;
93 explicit operator Real()
const;
99 static std::ostream &
latex(std::ostream & os);
100 static std::ostream &
text(std::ostream & os);
105 template <
typename... Args>
106 void parseError(
const std::string & unit_string, std::string::const_iterator it, Args... args);
118 std::vector<std::pair<BaseUnit, int>>
_base;
124template <
typename... Args>
127 std::string::const_iterator it,
130 auto d = std::distance(unit_string.begin(), it);
131 mooseError(
"At position ", d,
" in ", unit_string,
": ", std::forward<Args>(args)...);
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
std::ostream & operator<<(std::ostream &os, const MooseUnits &u)
Physical unit management class with runtime unit string parsing, unit checking, unit conversion,...
void parseError(const std::string &unit_string, std::string::const_iterator it, Args... args)
helper function to generate a pretty mooseError
bool isBase(const MooseUnits::BaseUnit) const
check if the unit has a pure base
MooseUnits(Real f, Real s, std::vector< std::pair< MooseUnits::BaseUnit, int > > b)
static int geti()
iosteam manipulator helper to toggle latex / text output
MooseUnits operator/(const MooseUnits &rhs) const
friend std::ostream & operator<<(std::ostream &os, const MooseUnits &dt)
bool isTemperature() const
bool isLength() const
query the nature of the unit
std::vector< std::pair< BaseUnit, int > > _base
base SI units and their exponents
Real convert(Real from_value, const MooseUnits &from_unit) const
Converts from_value in units of from_units to value this units.
Real _factor
conversion factor w.r.t. the base SI units
void parse(const std::string &unit_string)
parse a unit string into a MooseUnits object
bool conformsTo(const MooseUnits &) const
checks if the units are dimensionally conforming (i.e. the describe the same physical quanitity)
Real _shift
additive shift (for Celsius and Fahrenheit)
static const std::vector< std::pair< std::string, MooseUnits > > _unit_table
MooseUnits operator*(const Real f) const
Unit prefactor scaling.
bool operator==(const MooseUnits &rhs) const
static std::ostream & latex(std::ostream &os)
iostream manipulators
static const std::map< std::string, Real > _si_prefix
data tables with SI prefixes and known units
void simplify()
simplify into the canonical form that permits comparisons
static std::ostream & text(std::ostream &os)
MooseUnits pow(const MooseUnits &, int)