* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <libsigrokdecode/libsigrokdecode.h>
#include <boost/none_t.hpp>
-#include <pv/data/decoderstack.hpp>
#include <pv/data/decode/decoder.hpp>
+#include <pv/data/decoderstack.hpp>
#include <pv/prop/double.hpp>
#include <pv/prop/enum.hpp>
#include <pv/prop/int.hpp>
const srd_decoder *const dec = decoder_->decoder();
assert(dec);
- for (GSList *l = dec->options; l; l = l->next)
- {
+ for (GSList *l = dec->options; l; l = l->next) {
const srd_decoder_option *const opt =
(srd_decoder_option*)l->data;
shared_ptr<Property> prop;
if (opt->values)
- prop = bind_enum(name, opt, get, set);
+ prop = bind_enum(name, "", opt, get, set);
else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("d")))
- prop = shared_ptr<Property>(new Double(name, 2, "",
+ prop = shared_ptr<Property>(new Double(name, "", 2, "",
none, none, get, set));
else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("x")))
prop = shared_ptr<Property>(
- new Int(name, "", none, get, set));
+ new Int(name, "", "", none, get, set));
else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("s")))
prop = shared_ptr<Property>(
- new String(name, get, set));
+ new String(name, "", get, set));
else
continue;
}
shared_ptr<Property> Decoder::bind_enum(
- const QString &name, const srd_decoder_option *option,
+ const QString &name, const QString &desc,
+ const srd_decoder_option *option,
Property::Getter getter, Property::Setter setter)
{
vector< pair<Glib::VariantBase, QString> > values;
values.push_back(make_pair(var, print_gvariant(var)));
}
- return shared_ptr<Property>(new Enum(name, values, getter, setter));
+ return shared_ptr<Property>(new Enum(name, desc, values, getter, setter));
}
Glib::VariantBase Decoder::getter(const char *id)
if (iter != options.end())
val = (*iter).second;
- else
- {
+ else {
assert(decoder_->decoder());
// Get the default value if not
- for (GSList *l = decoder_->decoder()->options; l; l = l->next)
- {
+ for (GSList *l = decoder_->decoder()->options; l; l = l->next) {
const srd_decoder_option *const opt =
(srd_decoder_option*)l->data;
if (strcmp(opt->id, id) == 0) {
}
}
- if (val)
- return Glib::VariantBase(val, true);
- else
- return Glib::VariantBase();
+ return (val) ? Glib::VariantBase(val, true) : Glib::VariantBase();
}
void Decoder::setter(const char *id, Glib::VariantBase value)
decoder_stack_->begin_decode();
}
-} // binding
-} // pv
+} // namespace binding
+} // namespace pv