Esempio n. 1
0
Result validate(const SampledDimension &sampled_dim) {
    return validator({
        must(sampled_dim, &SampledDimension::index, notSmaller(1), "index is not set to valid value (size_t > 0)!"),
        must(sampled_dim, &SampledDimension::samplingInterval, isGreater(0), "samplingInterval is not set to valid value (> 0)!"),
        must(sampled_dim, &SampledDimension::dimensionType, isEqual<DimensionType>(DimensionType::Sample), "dimension type is not correct!"),
        could(sampled_dim, &SampledDimension::offset, notFalse(), {
            should(sampled_dim, &SampledDimension::unit, isAtomicUnit(), "offset is set, but no valid unit set!") }),
        could(sampled_dim, &SampledDimension::unit, notFalse(), {
            must(sampled_dim, &SampledDimension::unit, isAtomicUnit(), "Unit is set but not an atomic SI. Note: So far composite units are not supported!") })
    });
}
Esempio n. 2
0
Result validate(const RangeDimension &range_dim) {
    return validator({
        must(range_dim, &RangeDimension::index, notSmaller(1), "index is not set to valid value (size_t > 0)!"),
        must(range_dim, &RangeDimension::ticks, notEmpty(), "ticks are not set!"),
        must(range_dim, &RangeDimension::dimensionType, isEqual<DimensionType>(DimensionType::Range), "dimension type is not correct!"),
        could(range_dim, &RangeDimension::unit, notFalse(), {
            must(range_dim, &RangeDimension::unit, isAtomicUnit(), "Unit is set but not an atomic SI. Note: So far composite units are not supported!") }),
        must(range_dim, &RangeDimension::ticks, isSorted(), "Ticks are not sorted!")
    });
}
Esempio n. 3
0
std::pair<std::string,int> decomposeAtomicUnitString(const std::string& s) {

  if (!isAtomicUnit(s)) {
    LOG_FREE_AND_THROW("openstudio.QuantityRegex","Cannot decompose " << s
      << " into a base unit and exponent because it is not an atomic unit.");
  }
  std::pair<std::string,int> result;
  boost::smatch match;

  boost::regex_search(s,match,regexBaseUnit());
  result.first = std::string(match[0].first,match[0].second);
  if (boost::regex_search(s,match,regexExponent())) {
    std::istringstream iss(std::string(match[0].first,match[0].second));
    iss >> result.second;
  }
  else {