#include <libsigrok/libsigrok.hpp>
+#include <boost/algorithm/string/join.hpp>
#include <boost/filesystem.hpp>
+using boost::algorithm::join;
+
using std::dynamic_pointer_cast;
using std::list;
using std::map;
-using std::ostringstream;
using std::remove_if;
using std::runtime_error;
using std::shared_ptr;
return;
}
- ostringstream s;
-
// First, build the device's full name. It always contains all
// possible information.
vector<string> parts = {device->vendor(), device->model(),
if (device->connection_id().length() > 0)
parts.push_back("("+device->connection_id()+")");
- for (size_t i = 0; i < parts.size(); i++)
- {
- if (parts[i].length() > 0)
- {
- if (i != 0)
- s << " ";
- s << parts[i];
- }
- }
-
- full_names_[device] = s.str();
+ full_names_[device] = join(parts, " ");
// Next, build the display name. It only contains fields as required.
bool multiple_dev = false;
dev != hardware_device;
} );
- s.str("");
- parts.clear();
parts = {device->vendor(), device->model()};
if (multiple_dev) {
parts.push_back("("+device->connection_id()+")");
}
- for (size_t i = 0; i < parts.size(); i++)
- {
- if (parts[i].length() > 0)
- {
- if (i != 0)
- s << " ";
- s << parts[i];
- }
- }
-
- display_names_[device] = s.str();
+ display_names_[device] = join(parts, " ");
}
const std::string DeviceManager::get_display_name(std::shared_ptr<sigrok::Device> dev)