void Sequence::setValues(QString minv, QString maxv, QString inc, QString start, QString cache) { minv=formatValue(minv); maxv=formatValue(maxv); inc=formatValue(inc); start=formatValue(start); cache=formatValue(cache); //Raises an error when some values are empty if(minv=="" || maxv=="" || inc=="" || start=="" || cache=="") throw Exception(ERR_ASG_INV_VALUE_SEQ_ATTRIBS,__PRETTY_FUNCTION__,__FILE__,__LINE__); //Raises an error when the min value is greater than max value else if(compareValues(minv,maxv) > 0) throw Exception(ERR_ASG_INV_SEQ_MIN_VALUE,__PRETTY_FUNCTION__,__FILE__,__LINE__); //Raises an error when the start value is less that min value or grater than max value else if(compareValues(start, minv) < 0 || compareValues(start, maxv) > 0) throw Exception(ERR_ASG_INV_SEQ_START_VALUE,__PRETTY_FUNCTION__,__FILE__,__LINE__); //Raises an error when the increment value is null (0) else if(isNullValue(inc)) throw Exception(ERR_ASG_INV_SEQ_INCR_VALUE,__PRETTY_FUNCTION__,__FILE__,__LINE__); //Raises an error when the cache value is null (0) else if(isNullValue(cache)) throw Exception(ERR_ASG_INV_SEQ_CACHE_VALUE,__PRETTY_FUNCTION__,__FILE__,__LINE__); this->min_value=minv; this->max_value=maxv; this->increment=inc; this->cache=cache; this->start=start; }
NullValue& Value::asNullValue() { if (!isNullValue()) throw openfluid::base::OFException("OpenFLUID framework","Value::asNullValue","Value is not a NullValue"); return static_cast<NullValue&>(*this); }
double MathLib::toDoubleNumber(const std::string &str) { if (str.compare(0, 2, "0x") == 0) { return std::strtoul(str.c_str(), '\0', 16); } // nullcheck else if (isNullValue(str)) return 0.0; // otherwise, convert to double std::istringstream istr(str.c_str()); double ret; istr >> ret; return ret; }