]> sigrok.org Git - libsigrok.git/commitdiff
C++: Add Configurable::config_keys() method.
authorMartin Ling <redacted>
Sat, 6 Sep 2014 12:08:51 +0000 (13:08 +0100)
committerUwe Hermann <redacted>
Mon, 8 Sep 2014 17:27:38 +0000 (19:27 +0200)
bindings/cxx/classes.cpp
bindings/cxx/include/libsigrok/libsigrok.hpp

index f00ff760ced69b140dd011cefbf4df94e22ab149..68124b5a39cd50938a827d10e5154105b5050f0e 100644 (file)
@@ -358,6 +358,28 @@ Glib::VariantContainerBase Configurable::config_list(const ConfigKey *key)
        return Glib::VariantContainerBase(data);
 }
 
+vector<const ConfigKey *> Configurable::config_keys(const ConfigKey *key)
+{
+       GVariant *gvar_opts;
+       gsize num_opts;
+       const int32_t *opts;
+       vector<const ConfigKey *> 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)
index 557b08d1d6b5aadf5181b81e0f8813238a1ce512..637daf912114e99dd4b8efe1a5eb1922579eaf77 100644 (file)
@@ -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<const ConfigKey *> config_keys(const ConfigKey *key);
 protected:
        Configurable(
                struct sr_dev_driver *driver,