X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Futil.cc;h=fe6602de380cf60c2b3f0cf9fc197471eeef011b;hp=7f6e9da5aff95feaee14a7cac247952d2e5cbd5d;hb=04b5957318df591f56e0a5d39720df143dc8230d;hpb=9bebb9724c5b7f254e3cea62a5cdb3c5e0e8571e diff --git a/src/lib/util.cc b/src/lib/util.cc index 7f6e9da5a..fe6602de3 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -1123,3 +1123,31 @@ word_wrap(string input, int columns) return output; } + +string +screen_names_to_string(vector names) +{ + if (names.empty()) { + return {}; + } + + auto number = [](string const& s) { + return s.find_first_not_of("0123456789") == string::npos; + }; + + if (std::find_if(names.begin(), names.end(), [number](string const& s) { return !number(s); }) == names.end()) { + std::sort(names.begin(), names.end(), [](string const& a, string const& b) { + return dcp::raw_convert(a) < dcp::raw_convert(b); + }); + } else { + std::sort(names.begin(), names.end()); + } + + string result; + for (auto const& name: names) { + result += name + ", "; + } + + return result.substr(0, result.length() - 2); +} +