X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Futil.cc;h=fe6602de380cf60c2b3f0cf9fc197471eeef011b;hb=4401895dfbb25834d4385621824e72ae19c8962c;hp=e0b5a294fe655dcb042a9014562ce8c26be4f114;hpb=4b8f2b64ebb7fcba20c3c03d7bccd08e48612fbb;p=dcpomatic.git diff --git a/src/lib/util.cc b/src/lib/util.cc index e0b5a294f..fe6602de3 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -46,7 +46,6 @@ #include "ratio.h" #include "rect.h" #include "render_text.h" -#include "scope_guard.h" #include "string_text.h" #include "text_decoder.h" #include "util.h" @@ -58,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -470,7 +470,7 @@ LIBDCP_ENABLE_WARNINGS vector subs; dcp::SubtitleString ss( optional(), false, false, false, dcp::Colour(), 42, 1, dcp::Time(), dcp::Time(), 0, dcp::HAlign::CENTER, 0, dcp::VAlign::CENTER, 0, dcp::Direction::LTR, - "Hello dolly", dcp::Effect::NONE, dcp::Colour(), dcp::Time(), dcp::Time(), 0 + "Hello dolly", dcp::Effect::NONE, dcp::Colour(), dcp::Time(), dcp::Time(), 0, std::vector() ); subs.push_back(StringText(ss, 0, make_shared("foo"), dcp::SubtitleStandard::SMPTE_2014)); render_text (subs, dcp::Size(640, 480), DCPTime(), 24); @@ -598,6 +598,7 @@ digest_head_tail (vector files, boost::uintmax_t size) string simple_digest (vector paths) { + DCP_ASSERT(!paths.empty()); return digest_head_tail(paths, 1000000) + raw_convert(dcp::filesystem::file_size(paths.front())); } @@ -673,7 +674,7 @@ short_audio_channel_name (int c) bool valid_image_file (boost::filesystem::path f) { - if (boost::starts_with (f.leaf().string(), "._")) { + if (boost::starts_with(f.filename().string(), "._")) { return false; } @@ -690,7 +691,7 @@ valid_image_file (boost::filesystem::path f) bool valid_sound_file (boost::filesystem::path f) { - if (boost::starts_with (f.leaf().string(), "._")) { + if (boost::starts_with(f.filename().string(), "._")) { return false; } @@ -1094,7 +1095,7 @@ word_wrap(string input, int columns) icu::Locale locale; UErrorCode status = U_ZERO_ERROR; auto iter = icu::BreakIterator::createLineInstance(locale, status); - ScopeGuard sg = [iter]() { delete iter; }; + dcp::ScopeGuard sg = [iter]() { delete iter; }; if (U_FAILURE(status)) { return input; } @@ -1122,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); +} +