Beispiel #1
0
std::vector<std::string> oskar_settings_utility_string_get_type_params(
                const std::string& s)
{
    std::vector<std::string> params;
    std::stringstream ss_all(s);
    std::string p;
    while (getline(ss_all, p, '"')) {
        std::stringstream ss(p);
        while (getline(ss, p, ',')) {
            p = oskar_settings_utility_string_trim(p);
            if (!p.empty()) params.push_back(p);
        }
        if (getline(ss_all, p, '"')) {
            if (!p.empty()) params.push_back(p);
        }
    }
    return params;
}
Beispiel #2
0
std::string oskar_settings_utility_string_reduce(const std::string& str,
                                                 const std::string& fill,
                                                 const std::string& whitespace)
{
    // Trim first
    std::string result = oskar_settings_utility_string_trim(str, whitespace);

    // Replace sub ranges
    size_t begin_space = result.find_first_of(whitespace);
    while (begin_space != std::string::npos)
    {
        const size_t end_space = result.find_first_not_of(whitespace,
                                                          begin_space);
        const size_t range = end_space - begin_space;
        result.replace(begin_space, range, fill);
        const size_t new_start = begin_space + fill.length();
        begin_space = result.find_first_of(whitespace, new_start);
    }

    return result;
}
Beispiel #3
0
bool InputFile::set_value(const std::string& value)
{
    value_ = oskar_settings_utility_string_trim(value);
    return true;
}
Beispiel #4
0
bool InputFile::set_default(const std::string& value)
{
    default_ = oskar_settings_utility_string_trim(value);
    value_ = default_;
    return true;
}