bindings: Add Device::get_description() method.
This commit is contained in:
parent
e194c01197
commit
f36ca8893d
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "libsigrok/libsigrok.hpp"
|
#include "libsigrok/libsigrok.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
namespace sigrok
|
namespace sigrok
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -362,6 +364,20 @@ Device::~Device()
|
||||||
delete entry.second;
|
delete entry.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string Device::get_description()
|
||||||
|
{
|
||||||
|
ostringstream s;
|
||||||
|
|
||||||
|
vector<string> parts =
|
||||||
|
{get_vendor(), get_model(), get_version()};
|
||||||
|
|
||||||
|
for (string part : parts)
|
||||||
|
if (part.length() > 0)
|
||||||
|
s << part;
|
||||||
|
|
||||||
|
return s.str();
|
||||||
|
}
|
||||||
|
|
||||||
string Device::get_vendor()
|
string Device::get_vendor()
|
||||||
{
|
{
|
||||||
return valid_string(structure->vendor);
|
return valid_string(structure->vendor);
|
||||||
|
|
|
@ -276,6 +276,8 @@ class SR_API Device :
|
||||||
public StructureWrapper<Context, struct sr_dev_inst>
|
public StructureWrapper<Context, struct sr_dev_inst>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/** Description identifying this device. */
|
||||||
|
string get_description();
|
||||||
/** Vendor name for this device. */
|
/** Vendor name for this device. */
|
||||||
string get_vendor();
|
string get_vendor();
|
||||||
/** Model name for this device. */
|
/** Model name for this device. */
|
||||||
|
|
|
@ -180,6 +180,7 @@ typedef std::map<const sigrok::ConfigKey *, Glib::VariantBase>
|
||||||
%attributestring(sigrok::OutputFormat,
|
%attributestring(sigrok::OutputFormat,
|
||||||
std::string, description, get_description);
|
std::string, description, get_description);
|
||||||
|
|
||||||
|
%attributestring(sigrok::Device, std::string, description, get_description);
|
||||||
%attributestring(sigrok::Device, std::string, vendor, get_vendor);
|
%attributestring(sigrok::Device, std::string, vendor, get_vendor);
|
||||||
%attributestring(sigrok::Device, std::string, model, get_model);
|
%attributestring(sigrok::Device, std::string, model, get_model);
|
||||||
%attributestring(sigrok::Device, std::string, version, get_version);
|
%attributestring(sigrok::Device, std::string, version, get_version);
|
||||||
|
|
Loading…
Reference in New Issue