1571 using Quantity_t = Quantity;
1573 using unit_t =
typename Quantity_t::unit_t;
1574 using baseunit_t =
typename unit_t::baseunit_t;
1577 using namespace std::string_literals;
1579 using PrefixMap_t = std::map<std::string, value_t>;
1580 using PrefixValue_t =
typename PrefixMap_t::value_type;
1581 static PrefixMap_t
const factors {
1582 PrefixValue_t{
"a"s, 1
e-18 },
1583 PrefixValue_t{
"f"s, 1
e-15 },
1584 PrefixValue_t{
"p"s, 1
e-12 },
1585 PrefixValue_t{
"n"s, 1
e-09 },
1586 PrefixValue_t{
"u"s, 1
e-06 },
1587 PrefixValue_t{
"m"s, 1
e-03 },
1588 PrefixValue_t{
"c"s, 1
e-02 },
1589 PrefixValue_t{
"d"s, 1
e-01 },
1590 PrefixValue_t{
""s, 1
e+00 },
1591 PrefixValue_t{
"da"s, 1
e+01 },
1592 PrefixValue_t{
"h"s, 1
e+02 },
1593 PrefixValue_t{
"k"s, 1
e+03 },
1594 PrefixValue_t{
"M"s, 1
e+06 },
1595 PrefixValue_t{
"G"s, 1
e+09 },
1596 PrefixValue_t{
"T"s, 1
e+12 },
1597 PrefixValue_t{
"P"s, 1
e+15 },
1598 PrefixValue_t{
"E"s, 1
e+18 }
1600 static auto const composePrefixPattern = [](
auto b,
auto e) -> std::string
1604 pattern += b->first;
1605 while (++b !=
e) { pattern +=
'|'; pattern += b->first; }
1607 return pattern +=
")";
1609 static std::string
const prefixPattern
1610 = composePrefixPattern(factors.begin(), factors.end());
1613 std::regex
const unitPattern {
1614 "[[:blank:]]*(" + prefixPattern +
"?"
1618 std::smatch unitMatch;
1619 if (!std::regex_search(str, unitMatch, unitPattern)) {
1620 if (!unitOptional) {
1621 throw MissingUnit(
"Unit is mandatory and must derive from '"
1633 auto const iFactor = factors.find(unitMatch.str(2U));
1634 if (iFactor == factors.end()) {
1635 throw InvalidUnitPrefix(
1636 "Unit '" + unitMatch.str(1U)
1637 +
"' has unsupported prefix '" + unitMatch.str(2U)
1638 +
"' (parsing '" + str +
"')"
1643 str.substr(0U, str.length() - unitMatch.length()),
1644 static_cast<value_t>(unit_t::scale(iFactor->second))
value_t
the JSON type enumeration
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
then echo File list $list not found else cat $list while read file do echo $file sed s