X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsession.cpp;h=fa5f95bb2ca7832cb6ba478524a70a564ba06ed3;hp=d7041d8ba2bea774e01cde16aabbd6e8b987f53b;hb=ad908057e13224eee9f983685e0ccc7db1ded0e9;hpb=aca9aa834c742ba70f49d1ac3eb2d1e02e759416 diff --git a/pv/session.cpp b/pv/session.cpp index d7041d8b..fa5f95bb 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -17,15 +17,10 @@ * along with this program; if not, see . */ -#ifdef _WIN32 -// Windows: Avoid boost/thread namespace pollution (which includes windows.h). -#define NOGDI -#define NORESOURCE -#endif - #include #include +#include #include #include @@ -48,16 +43,17 @@ #include "toolbars/mainbar.hpp" -#include "view/analogsignal.hpp" -#include "view/decodetrace.hpp" -#include "view/logicsignal.hpp" -#include "view/signal.hpp" -#include "view/view.hpp" +#include "views/trace/analogsignal.hpp" +#include "views/trace/decodetrace.hpp" +#include "views/trace/logicsignal.hpp" +#include "views/trace/signal.hpp" +#include "views/trace/view.hpp" #include #ifdef ENABLE_DECODE #include +#include "data/decodesignal.hpp" #endif using std::bad_alloc; @@ -77,6 +73,7 @@ using std::recursive_mutex; using std::runtime_error; using std::shared_ptr; using std::string; +using std::unique_ptr; using std::unordered_set; using std::vector; @@ -438,26 +435,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