X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsession.cpp;h=516e1acd5ad6ff1e6b52a277f97c042e28e37872;hp=66d80f1a4bde58b649cc571d1194431824f6f516;hb=6e2a5b1d677a26a637465cd4d304e2bc52e14f36;hpb=1573bf16ba50d1c023ad3a9ce596f0ab6eaeacff diff --git a/pv/session.cpp b/pv/session.cpp index 66d80f1a..516e1acd 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -434,26 +434,76 @@ void Session::set_default_device() set_device((iter == devices.end()) ? devices.front() : *iter); } +/** + * Convert generic options to data types that are specific to InputFormat. + * + * @param[in] user_spec vector of tokenized words, string format + * @param[in] fmt_opts input format's options, result of InputFormat::options() + * + * @return map of options suitable for InputFormat::create_input() + */ +map +Session::input_format_options(vector user_spec, + map> fmt_opts) +{ + map result; + + for (auto entry : user_spec) { + /* + * Split key=value specs. Accept entries without separator + * (for simplified boolean specifications). + */ + string key, val; + size_t pos = entry.find("="); + if (pos == std::string::npos) { + key = entry; + val = ""; + } else { + key = entry.substr(0, pos); + val = entry.substr(pos + 1); + } + + /* + * Skip user specifications that are not a member of the + * format's set of supported options. Have the text input + * spec converted to the required input format specific + * data type. + */ + auto found = fmt_opts.find(key); + if (found == fmt_opts.end()) + continue; + shared_ptr