|
Sen API
Sen Libraries
|
Represents the definition of a unit. More...
#include <unit.h>
Classes | |
| struct | EnsureTag |
Public Member Functions | |
| Unit (UnitSpec spec, Private notUsable) noexcept | |
| Constructor is only usable by this class. Use make (see below). | |
| ~Unit () noexcept=default | |
| UnitCategory | getCategory () const noexcept |
| Measurement type. | |
| std::string_view | getName () const noexcept |
| Plain name. | |
| std::string_view | getNamePlural () const noexcept |
| Plural name. | |
| std::string_view | getAbbreviation () const noexcept |
| Unique abbreviation. | |
| float64_t | toSI (float64_t value) const noexcept |
| Converts 'value' given in this unit to an equivalent SI unit. | |
| float64_t | fromSI (float64_t value) const noexcept |
| Converts 'value' given in SI to this unit. | |
| Result< float64_t, std::string > | fromString (const std::string &str) const noexcept |
| Parses a string, searching for a valid unit specification within the same category. Returns a valid value if the string contains a number and it also converts the value from the specified unit. | |
| MemberHash | getHash () const noexcept |
| Returns a unique hash computed for the UnitSpec at compilation time. | |
| bool | operator== (const Unit &other) const noexcept |
| Comparison. | |
| bool | operator!= (const Unit &other) const noexcept |
Static Public Member Functions | |
| static std::unique_ptr< Unit > | make (UnitSpec spec) |
| Moves the spec into a member. | |
| static float64_t | convert (const Unit &from, const Unit &to, float64_t value) noexcept |
| Converts a a value between units. | |
| static std::string_view | getCategoryString (UnitCategory category) noexcept |
| A string that describes the category. | |
Static Public Attributes | |
| static constexpr EnsureTag | ensurePresent {} |
| Tag to request that a unit is required. | |
Represents the definition of a unit.
| struct sen::Unit::EnsureTag |
|
noexcept |
Constructor is only usable by this class. Use make (see below).
|
defaultnoexcept |
|
nodiscardnoexcept |
Measurement type.
|
nodiscardnoexcept |
Plain name.
|
nodiscardnoexcept |
Plural name.
|
nodiscardnoexcept |
Unique abbreviation.
Converts 'value' given in this unit to an equivalent SI unit.
Converts 'value' given in SI to this unit.
|
nodiscardnoexcept |
Parses a string, searching for a valid unit specification within the same category. Returns a valid value if the string contains a number and it also converts the value from the specified unit.
|
staticnodiscardnoexcept |
Converts a a value between units.
|
staticnodiscardnoexcept |
A string that describes the category.
|
nodiscardnoexcept |
Returns a unique hash computed for the UnitSpec at compilation time.
|
nodiscardnoexcept |
Comparison.
|
nodiscardnoexcept |
|
inlinestaticconstexpr |
Tag to request that a unit is required.