From: Martin Ling Date: Sat, 6 Sep 2014 12:08:51 +0000 (+0100) Subject: C++: Add Configurable::config_keys() method. X-Git-Tag: libsigrok-0.4.0~1026 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d54190a3631250f23c51cd73770e9cfdd9076fe8;p=libsigrok.git C++: Add Configurable::config_keys() method. --- diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index f00ff760..68124b5a 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -358,6 +358,28 @@ Glib::VariantContainerBase Configurable::config_list(const ConfigKey *key) return Glib::VariantContainerBase(data); } +vector Configurable::config_keys(const ConfigKey *key) +{ + GVariant *gvar_opts; + gsize num_opts; + const int32_t *opts; + vector result; + + check(sr_config_list( + config_driver, config_sdi, config_channel_group, + key->get_id(), &gvar_opts)); + + opts = (const int32_t *) g_variant_get_fixed_array( + gvar_opts, &num_opts, sizeof(int32_t)); + + for (gsize i = 0; i < num_opts; i++) + result.push_back(ConfigKey::get(opts[i])); + + g_variant_unref(gvar_opts); + + return result; +} + Device::Device(struct sr_dev_inst *structure) : Configurable(structure->driver, structure, NULL), structure(structure) diff --git a/bindings/cxx/include/libsigrok/libsigrok.hpp b/bindings/cxx/include/libsigrok/libsigrok.hpp index 557b08d1..637daf91 100644 --- a/bindings/cxx/include/libsigrok/libsigrok.hpp +++ b/bindings/cxx/include/libsigrok/libsigrok.hpp @@ -295,6 +295,8 @@ public: /** Enumerate available values for the given configuration key. * @param key ConfigKey to enumerate values for. */ Glib::VariantContainerBase config_list(const ConfigKey *key); + /** Enumerate available keys, according to a given index key. */ + vector config_keys(const ConfigKey *key); protected: Configurable( struct sr_dev_driver *driver,