1#ifndef included_AMP_Units
2#define included_AMP_Units
116 constexpr Units(
const char *unit );
124 constexpr Units(
const std::string_view &unit );
133 constexpr Units(
const std::string_view &unit,
double value );
190 constexpr
bool operator==( const
Units &rhs ) const noexcept;
193 constexpr
bool operator!=( const
Units &rhs ) const noexcept {
return !
operator==( rhs ); }
236 static constexpr int atoi( std::string_view,
bool =
true );
239 static constexpr double strtod( std::string_view );
254 static constexpr std::pair<size_t, char>
findToken(
const std::string_view &,
size_t );
255 static constexpr size_t findPar(
const std::string_view &,
size_t );
272#include "AMP/utils/Units.hpp"
Provides a class for storing units.
constexpr bool isNull() const
Check if unit is null.
friend constexpr Units pow(Units base, int exponent)
constexpr Units(const char *unit)
Construct the units from a const char array.
static constexpr Units read(std::string_view str)
std::array< int8_t, 9 > SI_type
static constexpr std::string_view getPrefixStr(UnitPrefix) noexcept
Get a string representation for the prefix.
constexpr Units()=default
Empty constructor.
constexpr bool operator==(const Units &rhs) const noexcept
Operator ==.
constexpr void operator*=(const Units &rhs) noexcept
Operator *=.
constexpr Units pow(int p) const noexcept
Raise the unit to the given power.
static constexpr int atoi(std::string_view, bool=true)
static constexpr double strtod(std::string_view)
constexpr Units(const SI_type &unit, double scale=1.0)
Construct the units.
constexpr Units(const std::string_view &unit, double value)
Construct the units from a const char array.
static constexpr SI_type getSI(UnitType)
static constexpr SI_type combine(const SI_type &a, const SI_type &b)
static constexpr std::pair< size_t, char > findToken(const std::string_view &, size_t)
constexpr bool compatible(const Units &unit) noexcept
Check if two units are compatible.
constexpr void operator*=(double x) noexcept
Operator *=.
static constexpr size_t findPar(const std::string_view &, size_t)
constexpr UnitType getType() const noexcept
Get the unit type.
constexpr double convert(const Units &unit) const
Convert the unit to a new type.
std::string printSIBase() const
constexpr Units(const UnitType &unit, double scale=1.0)
Construct the units.
std::string printSI() const
Get a string representation of the units in SI units (with scaling factor)
static constexpr Units readUnit(const std::string_view &str, bool throwErr=true)
static std::vector< std::string > getAllUnits()
Get all supported units.
constexpr Units(const std::string_view &unit)
Construct the units from a const char array.
static constexpr Units read2(std::string_view str)
std::string printUnit() const
Get a string representation of the units in SI units (with scaling factor)
std::array< char, 31 > unit_type
std::string printFull() const
Get the full unit and conversion string.
constexpr void operator/=(const Units &rhs) noexcept
Operator /=.
std::string str() const
Get a string representation of the units.
static constexpr UnitPrefix getUnitPrefix(const std::string_view &str) noexcept
Get the prefix from a string.
static std::vector< std::string > getAllPrefixes()
Get all supported unit prefixes.
std::ostream & operator<<(std::ostream &out, const AMP::ArraySize &s)
UnitPrefix
Enum to hold prefix.
UnitType
Enum to hold type.