]> sigrok.org Git - libsigrok.git/commitdiff
C++: Implement InputFormat::get_options()
authorMartin Ling <redacted>
Sun, 24 Aug 2014 13:22:03 +0000 (14:22 +0100)
committerBert Vermeulen <redacted>
Mon, 25 Aug 2014 23:55:41 +0000 (01:55 +0200)
bindings/cxx/classes.cpp
bindings/cxx/include/libsigrok/libsigrok.hpp

index edd68bd451e7e0074c0fed47c043d9901ed0e89b..ed89b8bd60f55d16378e5b0e8cfd6916e3e33e44 100644 (file)
@@ -1128,6 +1128,19 @@ string InputFormat::get_description()
        return valid_string(sr_input_description_get(structure));
 }
 
+map<string, shared_ptr<Option>> InputFormat::get_options()
+{
+       const struct sr_option *option = sr_input_options_get(structure);
+       auto option_array = shared_ptr<const struct sr_option>(
+               option, [=](const struct sr_option *) {
+                       sr_input_options_free(structure); });
+       map<string, shared_ptr<Option>> result;
+       for (; option->id; option++)
+               result[option->id] = shared_ptr<Option>(
+                       new Option(option, option_array), Option::Deleter());
+       return result;
+}
+
 shared_ptr<Input> InputFormat::create_input(
        map<string, Glib::VariantBase> options)
 {
index cc57d1a026cd3e470789873fc60a233188b6a578..f05205a6c997445d9243865a7ca127100c56691a 100644 (file)
@@ -825,6 +825,7 @@ protected:
                void operator()(Option *option) { delete option; }
        };
        friend class Deleter;
+       friend class InputFormat;
        friend class OutputFormat;
 };