xo-unit: docs: document xo::qty::dimension enum
This commit is contained in:
parent
1a2023a9a2
commit
28023d8a45
5 changed files with 37 additions and 7 deletions
|
|
@ -6,7 +6,14 @@
|
|||
|
||||
namespace xo {
|
||||
namespace qty {
|
||||
/** @enum dimension
|
||||
* @brief represent an abstract dimension.
|
||||
*
|
||||
* *xo-unit* units are expressed as a cartesian product
|
||||
* of powers of these dimensions.
|
||||
**/
|
||||
enum class dimension {
|
||||
/** sentinel value. not a dimension **/
|
||||
invalid = -1,
|
||||
|
||||
/** weight. native unit = 1 gram **/
|
||||
|
|
@ -18,19 +25,24 @@ namespace xo {
|
|||
/** a currency amount. native unit depends on actual currency.
|
||||
* For USD: one US dollar.
|
||||
*
|
||||
* NOTE: unit system isn't suitable for multicurrency work:
|
||||
* (1usd + 1eur) is well-defined, but (1sec + 1m) is not.
|
||||
* NOTE: multicurrency work not supported by *xo-unit*.
|
||||
* - (1usd + 1eur) is well-defined.
|
||||
* - (1sec + 1m) is not.
|
||||
**/
|
||||
currency,
|
||||
/** a screen price **/
|
||||
/** A screen price.
|
||||
* The interpretation of prices is highly context dependent;
|
||||
* expect useful to bucket separately from currenty amounts.
|
||||
**/
|
||||
price,
|
||||
|
||||
/** comes last, counts entries **/
|
||||
/** not a dimension. comes last, counts entries **/
|
||||
n_dim
|
||||
};
|
||||
|
||||
using dim = dimension;
|
||||
|
||||
/** @brief string value for a dimension enum **/
|
||||
inline const char *
|
||||
dim2str(dimension x)
|
||||
{
|
||||
|
|
@ -45,6 +57,7 @@ namespace xo {
|
|||
return "?dim";
|
||||
}
|
||||
|
||||
/** @brief number of built-in dimensions, convenient for array sizing **/
|
||||
static constexpr std::size_t n_dim = static_cast<std::size_t>(dimension::n_dim);
|
||||
} /*namespace qty*/
|
||||
} /*namespace xo*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue