Пример #1
0
void Property::unit(const std::string &unit) {
    util::checkEmptyString(unit, "unit");
    util::deblankString(unit);
    if (!unit.empty() && !(util::isSIUnit(unit) || util::isCompoundSIUnit(unit))) {
        throw InvalidUnit("Unit is not SI or composite of SI units.", "Property::unit(const string &unit)");
    }
    backend()->unit(unit);
}
Пример #2
0
void MultiTag::units(const std::vector<std::string> &units) {
    std::vector<std::string> sanitized;
    sanitized.reserve(units.size());
    std::transform(begin(units), end(units), std::back_inserter(sanitized), [](const std::string &x) {
        std::string unit = util::unitSanitizer(x);
        if (unit.length() > 0 && (unit != "none" && !(util::isSIUnit(unit)))) {
            std::string msg = "Unit " + unit +" is not a SI unit. Note: so far only atomic SI units are supported.";
            throw InvalidUnit(msg, "MultiTag::units(vector<string> &units)");
        }
        return unit;
    });
    backend()->units(sanitized);
}
Пример #3
0
 void unit(const std::string &unit) {
     if (!(util::isSIUnit(unit))) {
         throw InvalidUnit("Unit is not a SI unit. Note: so far, only atomic SI units are supported.", "SampledDimension::unit(const string &unit)");
     }
     backend()->unit(unit);
 }