diff options
Diffstat (limited to 'src/lib/util.cc')
| -rw-r--r-- | src/lib/util.cc | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc index 01a7f0248..ef15b90e5 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -1120,7 +1120,6 @@ word_wrap(string input, int columns) } - #ifdef DCPOMATIC_GROK void setup_grok_library_path() @@ -1147,3 +1146,31 @@ setup_grok_library_path() setenv("LD_LIBRARY_PATH", new_path.c_str(), 1); } #endif + +string +screen_names_to_string(vector<string> 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<int>(a) < dcp::raw_convert<int>(b); + }); + } else { + std::sort(names.begin(), names.end()); + } + + string result; + for (auto const& name: names) { + result += name + ", "; + } + + return result.substr(0, result.length() - 2); +} + |
