54     throw std::invalid_argument(
"-f expects an option");
 
   57   const std::string p = argv[0];
 
   59   if (p.compare(0, 5, 
"name=") == 0)
 
   61     filter.
name.push_back(p.substr(5));
 
   63   else if (p.compare(0, 7, 
"serial=") == 0)
 
   65     filter.
serial.push_back(p.substr(7));
 
   67   else if (p.compare(0, 4, 
"mac=") == 0)
 
   69     filter.
mac.push_back(p.substr(4));
 
   71   else if (p.compare(0, 6, 
"iface=") == 0)
 
   73     filter.
iface.push_back(p.substr(6));
 
   75   else if (p.compare(0, 6, 
"model=") == 0)
 
   77     filter.
model.push_back(p.substr(6));
 
   81     throw std::invalid_argument(
"Unknown option for parameter -f: " + p);
 
   90   const auto matches_filter = [](
const std::string &str,
 
   91                                  const std::vector<std::string> &filter)
 
   93     return filter.empty() ||
 
   94            std::any_of(filter.begin(), filter.end(),
 
   95                        [&str](
const std::string &f)
 
   97                          return wildcardMatch(str.begin(), str.end(),
 
  101   const std::string &name = device_info.
getUserName().empty()
 
  104   if (!matches_filter(name, filter.
name)) 
return false;
 
  106   if (!matches_filter(serial, filter.
serial)) 
return false;
 
  108   if (!matches_filter(mac, filter.
mac)) 
return false;
 
  110   if (!matches_filter(iface, filter.
iface)) 
return false;
 
  112   if (!matches_filter(model, filter.
model)) 
return false;
 
  122   std::chrono::steady_clock::time_point tstart=std::chrono::steady_clock::now();
 
  123   std::chrono::steady_clock::time_point tend=tstart;
 
  125   std::vector<rcdiscover::DeviceInfo> infos;
 
  127     std::chrono::duration<double, std::milli>(tend-tstart).count() < 1000)
 
  129     tend=std::chrono::steady_clock::now();
 
  132   std::sort(infos.begin(), infos.end());
 
  133   infos.erase(std::unique(infos.begin(), infos.end(),
 
  137                             return lhs.getMAC() == rhs.getMAC() &&
 
  138                                    lhs.getIfaceName() == rhs.getIfaceName();
 
  141   std::vector<rcdiscover::DeviceInfo> filtered_devices;
 
  142   for (
const auto &info : infos)
 
  146       filtered_devices.push_back(info);
 
  149   return filtered_devices;
 
  153                 const std::vector<std::vector<std::string>> &to_be_printed)
 
  155   std::size_t max_columns = 0;
 
  156   for (
const auto &row : to_be_printed)
 
  158     max_columns = std::max(max_columns, row.size());
 
  161   std::vector<std::size_t> column_width(max_columns, 0);
 
  162   for (
const auto &row : to_be_printed)
 
  164     for (std::size_t col = 0; col < row.size(); ++col)
 
  166       column_width[col] = std::max(column_width[col], row[col].size());
 
  170   for (
const auto &row : to_be_printed)
 
  172     for (std::size_t col = 0; col < row.size(); ++col)
 
  174       std::string s = row[col];
 
  175       if (col < row.size() - 1)
 
  177         s.append(column_width[col] - s.length(), 
' ');
 
  187                       const std::vector<rcdiscover::DeviceInfo> &devices,
 
  189                       bool iponly, 
bool serialonly)
 
  191   std::vector<std::vector<std::string>> to_be_printed;
 
  195     to_be_printed.push_back({
"Name", 
"Serial Number", 
"IP", 
"MAC", 
"Model", 
"Interface(s)"});
 
  199   for (
const auto &info : devices)
 
  203       if (info.getMAC() == last_info->
getMAC() && !iponly && !serialonly)
 
  206         to_be_printed.back().back() += 
"," + info.
getIfaceName();
 
  211     to_be_printed.emplace_back();
 
  212     auto &print = to_be_printed.back();
 
  216       print.push_back(
ip2string(info.getIP()));
 
  220       print.push_back(info.getSerialNumber());
 
  224       const std::string &name = info.getUserName().empty()
 
  225                                 ? info.getModelName()
 
  226                                 : info.getUserName();
 
  228       print.push_back(name);
 
  229       print.push_back(info.getSerialNumber());
 
  230       print.push_back(
ip2string(info.getIP()));
 
  232       print.push_back(info.getModelName());
 
  233       print.push_back(info.getIfaceName());