Beispiel #1
0
bool OptionList::init(const char* s)
{
    options_.clear();
    options_ = oskar_settings_utility_string_get_type_params(s);
    if (options_.size() > 0)
        set_default(options_[0].c_str());
    return true;
}
Beispiel #2
0
bool DoubleRangeExt::init(const std::string& s)
{
    // Reset the value.
    ext_min_.clear();
    ext_max_.clear();
    value_ = 0.0;
    default_ = 0.0;

    // Extract range from the parameter CSV string.
    // Parameters, p, for DoubleRangeExt should be length 3 or 4.
    //  - With 3 entries the range is (p[0] to p[1]) with an extended minimum
    //    value of p[2]
    //  - With 4 entries the range is (p[0] to p[1]) with an extended minimum
    //    value of p[2] and an extended maximum value of p[3]
    //  - For the double range parameters, p[0] and p[1], special values
    //    of 'MIN' and 'MAX' map to -DBL_MAX and DBL_MIN respectively.
    bool ok = true;
    std::vector<std::string> p;
    p = oskar_settings_utility_string_get_type_params(s);
    if (p.size() < 3u || p.size() > 4u) {
        return false;
    }
    if (p[0] == "-DBL_MAX" || p[0] == "-MAX")
        min_ = -DBL_MAX;
    else if (p[0] == "DBL_MIN" || p[0] == "-DBL_MIN"
                    || p[0] == "MIN" || p[0] == "-MIN")
        min_ = -DBL_MIN;
    else
        min_ = oskar_settings_utility_string_to_double(p[0], &ok);
    if (!ok) return false;
    if (p[1] == "DBL_MAX" || p[1] == "MAX")
        max_ =  DBL_MAX;
    else
        max_ = oskar_settings_utility_string_to_double(p[1], &ok);
    ext_min_ = p[2];
    if (p.size() == 4u) {
        ext_max_ = p[3];
    }
    return ok;
}