diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-07-09 01:49:10 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-07-09 21:29:57 +0200 |
| commit | fe5bed524942c1ffc157f8a5ef59f5d291789891 (patch) | |
| tree | cf3ed3ed7672ab3c38673fa0d15927d80ed0c5d2 | |
| parent | bb07c53c501365b6380ae2c7e1a149b955d13d4d (diff) | |
Replace String::compose with fmt.
77 files changed, 324 insertions, 323 deletions
diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index d2c3b04e5..eb3fcecb7 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -21,7 +21,6 @@ #include "analyse_audio_job.h" #include "audio_analysis.h" -#include "compose.hpp" #include "dcpomatic_log.h" #include "film.h" #include "filter.h" diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index 60b0f07ad..6520f8175 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -25,7 +25,6 @@ #include "dcpomatic_log.h" #include "log.h" #include "resampler.h" -#include "compose.hpp" #include <iostream> #include "i18n.h" diff --git a/src/lib/butler.cc b/src/lib/butler.cc index 5edd84115..17eb48b34 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -20,7 +20,6 @@ #include "butler.h" -#include "compose.hpp" #include "cross.h" #include "dcpomatic_log.h" #include "exceptions.h" @@ -28,6 +27,7 @@ #include "player.h" #include "util.h" #include "video_content.h" +#include <fmt/format.h> using std::cout; @@ -104,7 +104,7 @@ Butler::Butler( multi-thread JPEG2000 decoding. */ - LOG_TIMING("start-prepare-threads %1", boost::thread::hardware_concurrency() * 2); + LOG_TIMING("start-prepare-threads {}", boost::thread::hardware_concurrency() * 2); for (size_t i = 0; i < boost::thread::hardware_concurrency() * 2; ++i) { _prepare_pool.create_thread(bind(&dcpomatic::io_context::run, &_prepare_context)); @@ -140,10 +140,10 @@ Butler::should_run() const auto pos = _audio.peek(); if (pos) { throw ProgrammingError - (__FILE__, __LINE__, String::compose("Butler video buffers reached %1 frames (audio is %2 at %3)", _video.size(), _audio.size(), pos->get())); + (__FILE__, __LINE__, fmt::format("Butler video buffers reached {} frames (audio is {} at {})", _video.size(), _audio.size(), pos->get())); } else { throw ProgrammingError - (__FILE__, __LINE__, String::compose("Butler video buffers reached %1 frames (audio is %2)", _video.size(), _audio.size())); + (__FILE__, __LINE__, fmt::format("Butler video buffers reached {} frames (audio is {})", _video.size(), _audio.size())); } } @@ -152,19 +152,19 @@ Butler::should_run() const auto pos = _audio.peek(); if (pos) { throw ProgrammingError - (__FILE__, __LINE__, String::compose("Butler audio buffers reached %1 frames at %2 (video is %3)", _audio.size(), pos->get(), _video.size())); + (__FILE__, __LINE__, fmt::format("Butler audio buffers reached {} frames at {} (video is {})", _audio.size(), pos->get(), _video.size())); } else { throw ProgrammingError - (__FILE__, __LINE__, String::compose("Butler audio buffers reached %1 frames (video is %3)", _audio.size(), _video.size())); + (__FILE__, __LINE__, fmt::format("Butler audio buffers reached {} frames (video is {})", _audio.size(), _video.size())); } } if (_video.size() >= MAXIMUM_VIDEO_READAHEAD * 2) { - LOG_WARNING("Butler video buffers reached %1 frames (audio is %2)", _video.size(), _audio.size()); + LOG_WARNING("Butler video buffers reached {} frames (audio is {})", _video.size(), _audio.size()); } if (_audio.size() >= MAXIMUM_AUDIO_READAHEAD * 2) { - LOG_WARNING("Butler audio buffers reached %1 frames (video is %2)", _audio.size(), _video.size()); + LOG_WARNING("Butler audio buffers reached {} frames (video is {})", _audio.size(), _video.size()); } if (_stop_thread || _finished || _died || _suspended) { @@ -324,9 +324,9 @@ try auto video = weak_video.lock(); /* If the weak_ptr cannot be locked the video obviously no longer requires any work */ if (video) { - LOG_TIMING("start-prepare in %1", thread_id()); + LOG_TIMING("start-prepare in {}", thread_id()); video->prepare(_pixel_format, _video_range, _alignment, _fast, _prepare_only_proxy); - LOG_TIMING("finish-prepare in %1", thread_id()); + LOG_TIMING("finish-prepare in {}", thread_id()); } } catch (std::exception& e) @@ -472,7 +472,7 @@ Butler::Error::summary() const case Error::Code::AGAIN: return "Butler not ready"; case Error::Code::DIED: - return String::compose("Butler died (%1)", message); + return fmt::format("Butler died ({})", message); case Error::Code::FINISHED: return "Butler finished"; } diff --git a/src/lib/cinema_list.cc b/src/lib/cinema_list.cc index 8673f9c8b..7bea7ad95 100644 --- a/src/lib/cinema_list.cc +++ b/src/lib/cinema_list.cc @@ -30,6 +30,7 @@ #include "util.h" #include <dcp/certificate.h> #include <sqlite3.h> +#include <fmt/format.h> #include <boost/algorithm/string.hpp> #include <iostream> #include <numeric> @@ -156,7 +157,7 @@ void CinemaList::clear() { for (auto table: { "cinemas", "screens", "trusted_devices" }) { - SQLiteStatement sql(_db, String::compose("DELETE FROM %1", table)); + SQLiteStatement sql(_db, fmt::format("DELETE FROM {}", table)); sql.execute(); } } diff --git a/src/lib/collator.cc b/src/lib/collator.cc index 21e89fd78..b349eb490 100644 --- a/src/lib/collator.cc +++ b/src/lib/collator.cc @@ -29,6 +29,7 @@ #include <unicode/ustring.h> #include <fmt/format.h> #include <boost/scoped_array.hpp> +#include <algorithm> #include <cstring> #include <vector> @@ -102,8 +103,8 @@ Collator::find(string pattern, string text) const usearch_close(search); return index != -1; } else { - transform(pattern.begin(), pattern.end(), pattern.begin(), ::tolower); - transform(text.begin(), text.end(), text.begin(), ::tolower); + std::transform(pattern.begin(), pattern.end(), pattern.begin(), ::tolower); + std::transform(text.begin(), text.end(), text.begin(), ::tolower); return pattern.find(text) != string::npos; } } diff --git a/src/lib/config.cc b/src/lib/config.cc index 5f3f2f6fe..5ad0f16d8 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -21,7 +21,6 @@ #include "cinema_list.h" #include "colour_conversion.h" -#include "compose.hpp" #include "config.h" #include "constants.h" #include "cross.h" @@ -276,7 +275,7 @@ Config::backup() auto copy_adding_number = [](path const& path_to_copy) { auto add_number = [](path const& path, int number) { - return String::compose("%1.%2", path, number); + return fmt::format("{}.{}", path.string(), number); }; int n = 1; diff --git a/src/lib/content.cc b/src/lib/content.cc index 2a69adefd..196288f4a 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -26,7 +26,6 @@ #include "audio_content.h" #include "change_signaller.h" -#include "compose.hpp" #include "content.h" #include "content_factory.h" #include "exceptions.h" @@ -296,9 +295,9 @@ Content::clone() const string Content::technical_summary() const { - auto s = String::compose("%1 %2 %3", path_summary(), digest(), position().seconds()); + auto s = fmt::format("{} {} {}", path_summary(), digest(), position().seconds()); if (_video_frame_rate) { - s += String::compose(" %1", *_video_frame_rate); + s += fmt::format(" {}", *_video_frame_rate); } return s; } @@ -452,7 +451,7 @@ Content::add_properties(shared_ptr<const Film>, list<UserProperty>& p) const } } if (paths_to_show < number_of_paths()) { - paths += String::compose("... and %1 more", number_of_paths() - paths_to_show); + paths += fmt::format("... and {} more", number_of_paths() - paths_to_show); } p.push_back( UserProperty( diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index fa3f0876c..0b419098c 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -39,7 +39,6 @@ #include "string_text_file_content.h" #include "util.h" #include "video_mxf_content.h" -#include "compose.hpp" #include <libcxml/cxml.h> #include <dcp/filesystem.h> #include <dcp/smpte_text_asset.h> diff --git a/src/lib/copy_to_drive_job.cc b/src/lib/copy_to_drive_job.cc index 4ed9421d6..504a3ae9e 100644 --- a/src/lib/copy_to_drive_job.cc +++ b/src/lib/copy_to_drive_job.cc @@ -77,9 +77,9 @@ CopyToDriveJob::run () LOG_DISK("%1", dcp.string()); } - string request = String::compose(DISK_WRITER_WRITE "\n%1\n", _drive.device()); + string request = fmt::format(DISK_WRITER_WRITE "\n{}\n", _drive.device()); for (auto dcp: _dcps) { - request += String::compose("%1\n", dcp.string()); + request += fmt::format("{}\n", dcp.string()); } request += "\n"; if (!_nanomsg.send(request, 2000)) { diff --git a/src/lib/create_cli.cc b/src/lib/create_cli.cc index 51518ae82..df040e134 100644 --- a/src/lib/create_cli.cc +++ b/src/lib/create_cli.cc @@ -20,7 +20,6 @@ #include "audio_content.h" -#include "compose.hpp" #include "config.h" #include "content_factory.h" #include "create_cli.h" @@ -61,8 +60,8 @@ help() DCPOMATIC_ASSERT(colour_conversions.length() > 2); colour_conversions = colour_conversions.substr(0, colour_conversions.length() - 2); - return string("\nSyntax: %1 [OPTION] <CONTENT> [OPTION] [<CONTENT> ...]\n") + - variant::insert_dcpomatic(" -v, --version show %1 version\n") + + return string("\nSyntax: {} [OPTION] <CONTENT> [OPTION] [<CONTENT> ...]\n") + + variant::insert_dcpomatic(" -v, --version show {} version\n") + " -h, --help show this help\n" " -n, --name <name> film name\n" " -t, --template <name> template name\n" @@ -107,7 +106,7 @@ argument_option (int& n, int argc, char* argv[], string short_name, string long_ } if ((n + 1) >= argc) { - **error = String::compose("%1: option %2 requires an argument", argv[0], long_name); + **error = fmt::format("{}: option {} requires an argument", argv[0], long_name); return; } @@ -126,7 +125,7 @@ argument_option(int& n, int argc, char* argv[], string short_name, string long_n } if ((n + 1) >= argc) { - **error = String::compose("%1: option %2 requires an argument", argv[0], long_name); + **error = fmt::format("{}: option {} requires an argument", argv[0], long_name); return; } @@ -155,14 +154,14 @@ argument_option( } if ((n + 1) >= argc) { - **error = String::compose("%1: option %2 requires an argument", argv[0], long_name); + **error = fmt::format("{}: option {} requires an argument", argv[0], long_name); return; } auto const arg = argv[++n]; auto const value = convert(arg); if (!value) { - *error = String::compose("%1: %2 is not valid for %3", argv[0], arg, long_name); + *error = fmt::format("{}: {} is not valid for {}", argv[0], arg, long_name); *claimed = true; return; } @@ -203,7 +202,7 @@ CreateCLI::CreateCLI(int argc, char* argv[]) } else if (a == "-h" || a == "--help") { error = "Create a film directory (ready for making a DCP) or metadata file from some content files.\n" "A film directory will be created if -o or --output is specified, otherwise a metadata file\n" - "will be written to stdout.\n" + String::compose(help(), argv[0]); + "will be written to stdout.\n" + fmt::format(help(), argv[0]); return; } @@ -312,7 +311,7 @@ CreateCLI::CreateCLI(int argc, char* argv[]) if (!claimed) { if (a.length() > 2 && a.substr(0, 2) == "--") { - error = String::compose("%1: unrecognised option '%2'", argv[0], a) + String::compose(help(), argv[0]); + error = fmt::format("{}: unrecognised option '{}'", argv[0], a) + fmt::format(help(), argv[0]); return; } else { if (next_colour_conversion) { @@ -368,7 +367,7 @@ CreateCLI::CreateCLI(int argc, char* argv[]) if (dcp_content_type_string) { _dcp_content_type = DCPContentType::from_isdcf_name(*dcp_content_type_string); if (!_dcp_content_type) { - error = String::compose("%1: unrecognised DCP content type '%2'", argv[0], *dcp_content_type_string); + error = fmt::format("{}: unrecognised DCP content type '{}'", argv[0], *dcp_content_type_string); return; } } @@ -376,7 +375,7 @@ CreateCLI::CreateCLI(int argc, char* argv[]) if (!container_ratio_string.empty()) { _container_ratio = Ratio::from_id_if_exists(container_ratio_string); if (!_container_ratio) { - error = String::compose("%1: unrecognised container ratio %2", argv[0], container_ratio_string); + error = fmt::format("{}: unrecognised container ratio {}", argv[0], container_ratio_string); return; } } @@ -387,21 +386,21 @@ CreateCLI::CreateCLI(int argc, char* argv[]) } else if (*standard_string == "SMPTE") { _standard = dcp::Standard::SMPTE; } else { - error = String::compose("%1: standard must be SMPTE or interop", argv[0]); + error = fmt::format("{}: standard must be SMPTE or interop", argv[0]); return; } } if (_twod && _threed) { - error = String::compose("%1: specify one of --twod or --threed, not both", argv[0]); + error = fmt::format("{}: specify one of --twod or --threed, not both", argv[0]); } if (_no_encrypt && _encrypt) { - error = String::compose("%1: specify one of --no-encrypt or --encrypt, not both", argv[0]); + error = fmt::format("{}: specify one of --no-encrypt or --encrypt, not both", argv[0]); } if (content.empty()) { - error = String::compose("%1: no content specified", argv[0]); + error = fmt::format("{}: no content specified", argv[0]); return; } @@ -410,7 +409,7 @@ CreateCLI::CreateCLI(int argc, char* argv[]) } if (_video_bit_rate && (*_video_bit_rate < 10000000 || *_video_bit_rate > Config::instance()->maximum_video_bit_rate(VideoEncoding::JPEG2000))) { - error = String::compose("%1: video-bit-rate must be between 10 and %2 Mbit/s", argv[0], (Config::instance()->maximum_video_bit_rate(VideoEncoding::JPEG2000) / 1000000)); + error = fmt::format("{}: video-bit-rate must be between 10 and {} Mbit/s", argv[0], (Config::instance()->maximum_video_bit_rate(VideoEncoding::JPEG2000) / 1000000)); return; } diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc index ccd78a3b1..a50b4a21f 100644 --- a/src/lib/cross_linux.cc +++ b/src/lib/cross_linux.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "config.h" #include "cross.h" #include "dcpomatic_log.h" @@ -31,6 +30,7 @@ #include <dcp/raw_convert.h> #include <dcp/warnings.h> #include <glib.h> +#include <fmt/format.h> #include <boost/algorithm/string.hpp> #if BOOST_VERSION >= 106100 #include <boost/dll/runtime_symbol_info.hpp> @@ -114,7 +114,7 @@ void run_ffprobe(boost::filesystem::path content, boost::filesystem::path out, bool err, string args) { string const redirect = err ? "2>" : ">"; - auto const ffprobe = String::compose("ffprobe %1 \"%2\" %3 \"%4\"", args.empty() ? " " : args, content.string(), redirect, out.string()); + auto const ffprobe = fmt::format("ffprobe {} \"{}\" {} \"{}\"", args.empty() ? " " : args, content.string(), redirect, out.string()); LOG_GENERAL (N_("Probing with %1"), ffprobe); int const r = system (ffprobe.c_str()); if (r == -1 || (WIFEXITED(r) && WEXITSTATUS(r) != 0)) { @@ -336,12 +336,12 @@ show_in_file_manager (boost::filesystem::path dir, boost::filesystem::path) { int r = system ("which nautilus"); if (WEXITSTATUS(r) == 0) { - r = system (String::compose("nautilus \"%1\"", dir.string()).c_str()); + r = system(fmt::format("nautilus \"{}\"", dir.string()).c_str()); return static_cast<bool>(WEXITSTATUS(r)); } else { int r = system ("which konqueror"); if (WEXITSTATUS(r) == 0) { - r = system (String::compose("konqueror \"%1\"", dir.string()).c_str()); + r = system(fmt::format("konqueror \"{}\"", dir.string()).c_str()); return static_cast<bool>(WEXITSTATUS(r)); } } diff --git a/src/lib/curl_uploader.cc b/src/lib/curl_uploader.cc index 753c66496..b62830bde 100644 --- a/src/lib/curl_uploader.cc +++ b/src/lib/curl_uploader.cc @@ -94,7 +94,7 @@ CurlUploader::upload_file(boost::filesystem::path from, boost::filesystem::path curl_easy_setopt( _curl, CURLOPT_URL, /* Use generic_string so that we get forward-slashes in the path, even on Windows */ - String::compose("ftp://%1/%2/%3", Config::instance()->tms_ip(), Config::instance()->tms_path(), to.generic_string()).c_str() + fmt::format("ftp://{}/{}/{}", Config::instance()->tms_ip(), Config::instance()->tms_path(), to.generic_string()).c_str() ); dcp::File file(from, "rb"); diff --git a/src/lib/dcp_text_track.cc b/src/lib/dcp_text_track.cc index ec1d6828b..ef3890401 100644 --- a/src/lib/dcp_text_track.cc +++ b/src/lib/dcp_text_track.cc @@ -20,7 +20,7 @@ #include "dcp_text_track.h" -#include "compose.hpp" +#include <fmt/format.h> #include <string> #include "i18n.h" @@ -50,7 +50,7 @@ DCPTextTrack::DCPTextTrack (string name_, optional<dcp::LanguageTag> language_) string DCPTextTrack::summary () const { - return String::compose("%1 (%2)", name, language ? language->as_string() : _("Unknown")); + return fmt::format("{} ({})", name, language ? language->as_string() : _("Unknown")); } void diff --git a/src/lib/disk_writer_messages.cc b/src/lib/disk_writer_messages.cc index 0a11ce618..562e9e876 100644 --- a/src/lib/disk_writer_messages.cc +++ b/src/lib/disk_writer_messages.cc @@ -72,24 +72,24 @@ DiskWriterBackEndResponse::write_to_nanomsg(Nanomsg& nanomsg, int timeout) const switch (_type) { case Type::OK: - message = String::compose("%1\n", DISK_WRITER_OK); + message = fmt::format("{}\n", DISK_WRITER_OK); break; case Type::ERROR: - message = String::compose("%1\n%2\n%3\n%4\n", DISK_WRITER_ERROR, _error_message, _ext4_error_number, _platform_error_number); + message = fmt::format("{}\n{}\n{}\n{}\n", DISK_WRITER_ERROR, _error_message, _ext4_error_number, _platform_error_number); break; case Type::PONG: - message = String::compose("%1\n", DISK_WRITER_PONG); + message = fmt::format("{}\n", DISK_WRITER_PONG); break; case Type::FORMAT_PROGRESS: - message = String::compose("%1\n", DISK_WRITER_FORMAT_PROGRESS); + message = fmt::format("{}\n", DISK_WRITER_FORMAT_PROGRESS); message += fmt::to_string(_progress) + "\n"; break; case Type::COPY_PROGRESS: - message = String::compose("%1\n", DISK_WRITER_COPY_PROGRESS); + message = fmt::format("{}\n", DISK_WRITER_COPY_PROGRESS); message += fmt::to_string(_progress) + "\n"; break; case Type::VERIFY_PROGRESS: - message = String::compose("%1\n", DISK_WRITER_VERIFY_PROGRESS); + message = fmt::format("{}\n", DISK_WRITER_VERIFY_PROGRESS); message += fmt::to_string(_progress) + "\n"; break; } diff --git a/src/lib/email.cc b/src/lib/email.cc index 1333b9e2d..4f926eef7 100644 --- a/src/lib/email.cc +++ b/src/lib/email.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "config.h" #include "dcpomatic_log.h" #include "email.h" @@ -27,6 +26,7 @@ #include "util.h" #include "variant.h" #include <curl/curl.h> +#include <fmt/format.h> #include <boost/algorithm/string.hpp> #include "i18n.h" @@ -205,9 +205,9 @@ Email::send(string server, int port, EmailProtocol protocol, string user, string if ((protocol == EmailProtocol::AUTO && port == 465) || protocol == EmailProtocol::SSL) { /* "SSL" or "Implicit TLS"; I think curl wants us to use smtps here */ - curl_easy_setopt(curl, CURLOPT_URL, String::compose("smtps://%1:%2", server, port).c_str()); + curl_easy_setopt(curl, CURLOPT_URL, fmt::format("smtps://{}:{}", server, port).c_str()); } else { - curl_easy_setopt(curl, CURLOPT_URL, String::compose("smtp://%1:%2", server, port).c_str()); + curl_easy_setopt(curl, CURLOPT_URL, fmt::format("smtp://{}:{}", server, port).c_str()); } if (!user.empty()) { @@ -247,7 +247,7 @@ Email::send(string server, int port, EmailProtocol protocol, string user, string auto const r = curl_easy_perform(curl); if (r != CURLE_OK) { - throw NetworkError(_("Failed to send email"), String::compose("%1 sending to %2:%3", curl_easy_strerror(r), server, port)); + throw NetworkError(_("Failed to send email"), fmt::format("{} sending to {}:{}", curl_easy_strerror(r), server, port)); } curl_slist_free_all(recipients); diff --git a/src/lib/environment_info.cc b/src/lib/environment_info.cc index d6592d126..503050870 100644 --- a/src/lib/environment_info.cc +++ b/src/lib/environment_info.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "cross.h" #include "log.h" #include "variant.h" @@ -36,6 +35,7 @@ extern "C" { #include <libavutil/pixfmt.h> } LIBDCP_ENABLE_WARNINGS +#include <fmt/format.h> #include <boost/thread.hpp> #include "i18n.h" @@ -86,18 +86,18 @@ environment_info () { list<string> info; - info.push_back(String::compose("%1 %2 git %3 using %4", variant::dcpomatic(), dcpomatic_version, dcpomatic_git_commit, dependency_version_summary())); + info.push_back(fmt::format("{} {} git {} using {}", variant::dcpomatic(), dcpomatic_version, dcpomatic_git_commit, dependency_version_summary())); { char buffer[128]; gethostname (buffer, sizeof (buffer)); - info.push_back (String::compose ("Host name %1", &buffer[0])); + info.push_back(fmt::format("Host name {}", &buffer[0])); } #ifdef DCPOMATIC_DEBUG - info.push_back(variant::insert_dcpomatic("%1 built in debug mode.")); + info.push_back(variant::insert_dcpomatic("{} built in debug mode.")); #else - info.push_back(variant::insert_dcpomatic("%1 built in optimised mode.")); + info.push_back(variant::insert_dcpomatic("{} built in optimised mode.")); #endif #ifdef LIBDCP_DEBUG info.push_back ("libdcp built in debug mode."); @@ -110,8 +110,8 @@ environment_info () os_info.dwOSVersionInfoSize = sizeof (os_info); GetVersionEx (&os_info); info.push_back ( - String::compose ( - "Windows version %1.%2.%3", + fmt::format( + "Windows version {}.{}.{}", (int) os_info.dwMajorVersion, (int) os_info.dwMinorVersion, (int) os_info.dwBuildNumber ) ); @@ -142,9 +142,9 @@ environment_info () #endif #endif - info.push_back (String::compose ("CPU: %1, %2 processors", cpu_info(), boost::thread::hardware_concurrency())); + info.push_back(fmt::format("CPU: {}, {} processors", cpu_info(), boost::thread::hardware_concurrency())); for (auto const& i: mount_info()) { - info.push_back (String::compose("Mount: %1 %2", i.first, i.second)); + info.push_back(fmt::format("Mount: {} {}", i.first, i.second)); } return info; diff --git a/src/lib/exceptions.cc b/src/lib/exceptions.cc index 5f0fe935a..c0cf5a815 100644 --- a/src/lib/exceptions.cc +++ b/src/lib/exceptions.cc @@ -47,7 +47,7 @@ OpenFileError::OpenFileError (boost::filesystem::path f, int error, Mode mode) FileNotFoundError::FileNotFoundError (boost::filesystem::path f) - : runtime_error(String::compose("File %1 not found", f.string())) + : runtime_error(fmt::format("File {} not found", f.string())) , _file (f) { @@ -118,7 +118,7 @@ KDMAsContentError::KDMAsContentError () NetworkError::NetworkError (string s, optional<string> d) - : runtime_error (String::compose("%1%2", s, d ? String::compose(" (%1)", *d) : "")) + : runtime_error(fmt::format("{}{}", s, d ? fmt::format(" ({})", *d) : "")) , _summary (s) , _detail (d) { @@ -127,7 +127,7 @@ NetworkError::NetworkError (string s, optional<string> d) KDMError::KDMError (string s, string d) - : runtime_error (String::compose("%1 (%2)", s, d)) + : runtime_error(fmt::format("{} ({})", s, d)) , _summary (s) , _detail (d) { @@ -136,7 +136,7 @@ KDMError::KDMError (string s, string d) GLError::GLError (char const* last, int e) - : runtime_error (String::compose("%1 failed %2", last, e)) + : runtime_error(fmt::format("{} failed {}", last, e)) { } @@ -150,7 +150,7 @@ GLError::GLError (char const* message) CopyError::CopyError(string m, optional<int> ext4, optional<int> platform) - : runtime_error(String::compose("%1%2%3", m, ext4 ? String::compose(" (%1)", *ext4) : "", platform ? String::compose(" (%1)", *platform) : "")) + : runtime_error(fmt::format("{}{}{}", m, ext4 ? fmt::format(" ({})", *ext4) : "", platform ? fmt::format(" ({})", *platform) : "")) , _message (m) , _ext4_number(ext4) , _platform_number(platform) @@ -167,7 +167,7 @@ CommunicationFailedError::CommunicationFailedError () VerifyError::VerifyError (string m, int n) - : runtime_error (String::compose("%1 (%2)", m, n)) + : runtime_error(fmt::format("{} ({})", m, n)) , _message (m) , _number (n) { diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index dae64fb5d..b1daa0624 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -28,10 +28,10 @@ #define DCPOMATIC_EXCEPTIONS_H -#include "compose.hpp" extern "C" { #include <libavutil/pixfmt.h> } +#include <fmt/format.h> #include <boost/filesystem.hpp> #include <boost/optional.hpp> #include <sqlite3.h> @@ -54,19 +54,19 @@ public: {} DecodeError (std::string function, std::string caller) - : std::runtime_error (String::compose("%1 failed [%2]", function, caller)) + : std::runtime_error(fmt::format("{} failed [{}]", function, caller)) {} DecodeError (std::string function, std::string caller, int error) - : std::runtime_error (String::compose("%1 failed [%2] (%3)", function, caller, error)) + : std::runtime_error(fmt::format("{} failed [{}] ({})", function, caller, error)) {} DecodeError (std::string function, std::string caller, boost::filesystem::path file) - : std::runtime_error (String::compose("%1 failed [%2] (%3)", function, caller, file.string())) + : std::runtime_error(fmt::format("{} failed [{}] ({})", function, caller, file.string())) {} DecodeError (std::string function, std::string caller, int error, boost::filesystem::path file) - : std::runtime_error (String::compose("%1 failed [%2] (%3) (%4)", function, caller, error, file.string())) + : std::runtime_error(fmt::format("{} failed [{}] ({}) ({})", function, caller, error, file.string())) {} }; @@ -91,11 +91,11 @@ public: {} explicit EncodeError (std::string function, std::string caller) - : std::runtime_error (String::compose("%1 failed [%2]", function, caller)) + : std::runtime_error(fmt::format("{} failed [{}]", function, caller)) {} explicit EncodeError (std::string function, std::string caller, int error) - : std::runtime_error (String::compose("%1 failed [%2] (%3)", function, caller, error)) + : std::runtime_error(fmt::format("{} failed [{}] ({})", function, caller, error)) {} }; @@ -110,7 +110,7 @@ public: * @param f Name of the file that this exception concerns. */ FileError (std::string m, boost::filesystem::path f) - : std::runtime_error (String::compose("%1 with %2", m, f.string())) + : std::runtime_error(fmt::format("{} with {}", m, f.string())) , _file (f) {} @@ -343,7 +343,7 @@ class CPLNotFoundError : public DCPError { public: CPLNotFoundError(std::string id) - : DCPError(String::compose("CPL %1 not found", id)) + : DCPError(fmt::format("CPL {} not found", id)) {} }; @@ -514,17 +514,17 @@ private: std::string get_message(SQLiteDatabase& db, char const* s) { - return String::compose("%1 (in %2)", s, get_filename(db)); + return fmt::format("{} (in {})", s, get_filename(db).string()); } std::string get_message(SQLiteDatabase& db, int rc) { - return String::compose("%1 (in %2)", sqlite3_errstr(rc), get_filename(db)); + return fmt::format("{} (in {})", sqlite3_errstr(rc), get_filename(db).string()); } std::string get_message(SQLiteDatabase& db, int rc, std::string doing) { - return String::compose("%1 (while doing %2) (in %3)", sqlite3_errstr(rc), doing, get_filename(db)); + return fmt::format("{} (while doing {}) (in {})", sqlite3_errstr(rc), doing, get_filename(db).string()); } boost::filesystem::path _filename; diff --git a/src/lib/ext.cc b/src/lib/ext.cc index 7dfc2b856..0eba706db 100644 --- a/src/lib/ext.cc +++ b/src/lib/ext.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "cross.h" #include "dcpomatic_log.h" #include "digester.h" @@ -58,6 +57,7 @@ extern "C" { #include <lwext4/ext4_mbr.h> #include <lwext4/ext4_mkfs.h> } +#include <fmt/format.h> #include <boost/filesystem.hpp> #include <chrono> #include <string> @@ -114,13 +114,13 @@ write(boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_ ext4_file out; int r = ext4_fopen(&out, to.generic_string().c_str(), "wb"); if (r != EOK) { - throw CopyError(String::compose("Failed to open file %1", to.generic_string()), r, ext4_blockdev_errno); + throw CopyError(fmt::format("Failed to open file {}", to.generic_string()), r, ext4_blockdev_errno); } dcp::File in(from, "rb"); if (!in) { ext4_fclose(&out); - throw CopyError(String::compose("Failed to open file %1", from.string()), 0); + throw CopyError(fmt::format("Failed to open file {}", from.string()), 0); } std::vector<uint8_t> buffer(block_size); @@ -134,7 +134,7 @@ write(boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_ size_t read = in.read(buffer.data(), 1, this_time); if (read != this_time) { ext4_fclose(&out); - throw CopyError(String::compose("Short read; expected %1 but read %2", this_time, read), 0, ext4_blockdev_errno); + throw CopyError(fmt::format("Short read; expected {} but read {}", this_time, read), 0, ext4_blockdev_errno); } digester.add(buffer.data(), this_time); @@ -147,7 +147,7 @@ write(boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_ } if (written != this_time) { ext4_fclose(&out); - throw CopyError(String::compose("Short write; expected %1 but wrote %2", this_time, written), 0, ext4_blockdev_errno); + throw CopyError(fmt::format("Short write; expected {} but wrote {}", this_time, written), 0, ext4_blockdev_errno); } remaining -= this_time; total_remaining -= this_time; @@ -171,12 +171,12 @@ string read(boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_remaining, uint64_t total, Nanomsg* nanomsg) { ext4_file in; - LOG_DISK("Opening %1 for read", to.generic_string()); + LOG_DISK("Opening {} for read", to.generic_string()); int r = ext4_fopen(&in, to.generic_string().c_str(), "rb"); if (r != EOK) { - throw VerifyError(String::compose("Failed to open file %1", to.generic_string()), r); + throw VerifyError(fmt::format("Failed to open file {}", to.generic_string()), r); } - LOG_DISK("Opened %1 for read", to.generic_string()); + LOG_DISK("Opened {} for read", to.generic_string()); std::vector<uint8_t> buffer(block_size); Digester digester; @@ -188,7 +188,7 @@ read(boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_r r = ext4_fread(&in, buffer.data(), this_time, &read); if (read != this_time) { ext4_fclose(&in); - throw VerifyError(String::compose("Short read; expected %1 but read %2", this_time, read), 0); + throw VerifyError(fmt::format("Short read; expected {} but read {}", this_time, read), 0); } digester.add(buffer.data(), this_time); @@ -228,7 +228,7 @@ static void copy(boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_remaining, uint64_t total, vector<CopiedFile>& copied_files, Nanomsg* nanomsg) { - LOG_DISK("Copy %1 -> %2", from.string(), to.generic_string()); + LOG_DISK("Copy {} -> {}", from.string(), to.generic_string()); from = dcp::filesystem::fix_long_path(from); using namespace boost::filesystem; @@ -238,7 +238,7 @@ copy(boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_r if (is_directory(from)) { int r = ext4_dir_mk(cr.generic_string().c_str()); if (r != EOK) { - throw CopyError(String::compose("Failed to create directory %1", cr.generic_string()), r, ext4_blockdev_errno); + throw CopyError(fmt::format("Failed to create directory {}", cr.generic_string()), r, ext4_blockdev_errno); } set_timestamps_to_now(cr); @@ -247,7 +247,7 @@ copy(boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_r } } else { string const write_digest = write(from, cr, total_remaining, total, nanomsg); - LOG_DISK("Wrote %1 %2 with %3", from.string(), cr.generic_string(), write_digest); + LOG_DISK("Wrote {} {} with %3", from.string(), cr.generic_string(), write_digest); copied_files.push_back(CopiedFile(from, cr, write_digest)); } } @@ -260,7 +260,7 @@ verify(vector<CopiedFile> const& copied_files, uint64_t total, Nanomsg* nanomsg) uint64_t total_remaining = total; for (auto const& i: copied_files) { string const read_digest = read(i.from, i.to, total_remaining, total, nanomsg); - LOG_DISK("Read %1 %2 was %3 on write, now %4", i.from.string(), i.to.generic_string(), i.write_digest, read_digest); + LOG_DISK("Read {} {} was %3 on write, now %4", i.from.string(), i.to.generic_string(), i.write_digest, read_digest); if (read_digest != i.write_digest) { throw VerifyError("Hash of written data is incorrect", 0); } @@ -348,7 +348,7 @@ try close(fd); #endif - LOG_DISK("Writing to partition at %1 size %2; bd part size is %3", bdevs.partitions[0].part_offset, bdevs.partitions[0].part_size, bd->part_size); + LOG_DISK("Writing to partition at {} size {}; bd part size is %3", bdevs.partitions[0].part_offset, bdevs.partitions[0].part_size, bd->part_size); #ifdef DCPOMATIC_WINDOWS file_windows_partition_set(bdevs.partitions[0].part_offset, bdevs.partitions[0].part_size); @@ -426,17 +426,17 @@ try disk_write_finished(); } catch (CopyError& e) { - LOG_DISK("CopyError (from write): %1 %2 %3", e.message(), e.ext4_number().get_value_or(0), e.platform_number().get_value_or(0)); + LOG_DISK("CopyError (from write): {} {} %3", e.message(), e.ext4_number().get_value_or(0), e.platform_number().get_value_or(0)); if (nanomsg) { DiskWriterBackEndResponse::error(e.message(), e.ext4_number().get_value_or(0), e.platform_number().get_value_or(0)).write_to_nanomsg(*nanomsg, LONG_TIMEOUT); } } catch (VerifyError& e) { - LOG_DISK("VerifyError (from write): %1 %2", e.message(), e.number()); + LOG_DISK("VerifyError (from write): {} {}", e.message(), e.number()); if (nanomsg) { DiskWriterBackEndResponse::error(e.message(), e.number(), 0).write_to_nanomsg(*nanomsg, LONG_TIMEOUT); } } catch (exception& e) { - LOG_DISK("Exception (from write): %1", e.what()); + LOG_DISK("Exception (from write): {}", e.what()); if (nanomsg) { DiskWriterBackEndResponse::error(e.what(), 0, 0).write_to_nanomsg(*nanomsg, LONG_TIMEOUT); } diff --git a/src/lib/fcpxml.cc b/src/lib/fcpxml.cc index 49798381c..a52385571 100644 --- a/src/lib/fcpxml.cc +++ b/src/lib/fcpxml.cc @@ -22,6 +22,7 @@ #include "fcpxml.h" #include <dcp/raw_convert.h> #include <libcxml/cxml.h> +#include <fmt/format.h> #include <boost/algorithm/string.hpp> #include <boost/filesystem.hpp> @@ -41,7 +42,7 @@ convert_time(string const& time) boost::algorithm::split(parts, time, boost::is_any_of("/")); if (parts.size() != 2 || parts[1].empty() || parts[1][parts[1].length() - 1] != 's') { - throw FCPXMLError(String::compose("Unexpected time format %1", time)); + throw FCPXMLError(fmt::format("Unexpected time format {}", time)); } return dcpomatic::ContentTime{dcp::raw_convert<int64_t>(parts[0]) * dcpomatic::ContentTime::HZ / dcp::raw_convert<int64_t>(parts[1])}; @@ -66,7 +67,7 @@ dcpomatic::fcpxml::load(boost::filesystem::path xml_file) auto name = video->string_attribute("name"); auto iter = assets.find(name); if (iter == assets.end()) { - throw FCPXMLError(String::compose(_("Video refers to missing asset %1"), name)); + throw FCPXMLError(fmt::format(_("Video refers to missing asset {}"), name)); } auto start = convert_time(video->string_attribute("offset")); diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index c6867c081..696527379 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -218,7 +218,7 @@ FFmpeg::setup_decoders () throw DecodeError (N_("avcodec_open2"), N_("FFmpeg::setup_decoders"), r); } } else { - dcpomatic_log->log (String::compose ("No codec found for stream %1", i), LogEntry::TYPE_WARNING); + dcpomatic_log->log(fmt::format("No codec found for stream {}", i), LogEntry::TYPE_WARNING); } } } diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 95aa63ba4..ddf880b03 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -380,8 +380,8 @@ FFmpegContent::technical_summary () const s += " - " + audio->technical_summary (); } - return s + String::compose ( - "ffmpeg: audio %1 subtitle %2 filters %3", as, ss, filt + return s + fmt::format( + "ffmpeg: audio {} subtitle {} filters {}", as, ss, filt ); } diff --git a/src/lib/file_group.cc b/src/lib/file_group.cc index 56a5c2c59..6c4a768e8 100644 --- a/src/lib/file_group.cc +++ b/src/lib/file_group.cc @@ -24,12 +24,12 @@ */ -#include "compose.hpp" #include "cross.h" #include "dcpomatic_assert.h" #include "exceptions.h" #include "file_group.h" #include <dcp/filesystem.h> +#include <fmt/format.h> #include <sndfile.h> #include <cstdio> @@ -169,7 +169,7 @@ FileGroup::read (uint8_t* buffer, int amount) const } if (_current_file->error()) { - throw FileError (String::compose("fread error %1", errno), _paths[_current_path]); + throw FileError(fmt::format("fread error {}", errno), _paths[_current_path]); } if (eof) { diff --git a/src/lib/image_png.cc b/src/lib/image_png.cc index e56b68d9a..0909dd2f2 100644 --- a/src/lib/image_png.cc +++ b/src/lib/image_png.cc @@ -22,6 +22,7 @@ #include "dcpomatic_assert.h" #include "exceptions.h" #include "image.h" +#include <fmt/format.h> #include <png.h> #include "i18n.h" @@ -78,7 +79,7 @@ png_flush (png_structp) static void png_error_fn (png_structp, char const * message) { - throw EncodeError (String::compose("Error during PNG write: %1", message)); + throw EncodeError(fmt::format("Error during PNG write: {}", message)); } diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index 50452fbad..f1a2f2337 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -24,7 +24,6 @@ */ -#include "compose.hpp" #include "config.h" #include "cross.h" #include "dcp_video.h" diff --git a/src/lib/job.cc b/src/lib/job.cc index ee6ad4e70..885df5645 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -105,7 +105,7 @@ Job::start () void Job::run_wrapper () { - start_of_thread (String::compose("Job-%1", json_name())); + start_of_thread(fmt::format("Job-{}", json_name())); try { diff --git a/src/lib/kdm_cli.cc b/src/lib/kdm_cli.cc index 50bf9ea51..64b467e22 100644 --- a/src/lib/kdm_cli.cc +++ b/src/lib/kdm_cli.cc @@ -39,6 +39,7 @@ #include <dcp/decrypted_kdm.h> #include <dcp/encrypted_kdm.h> #include <dcp/filesystem.h> +#include <fmt/format.h> #include <boost/algorithm/string.hpp> #include <getopt.h> @@ -62,13 +63,13 @@ using namespace dcpomatic; static void help(std::function<void (string)> out) { - out(String::compose("Syntax: %1 [OPTION] [COMMAND] <FILM|CPL-ID|DKDM>", program_name)); + out(fmt::format("Syntax: {} [OPTION] [COMMAND] <FILM|CPL-ID|DKDM>", program_name)); out("Commands:"); out("create create KDMs; default if no other command is specified"); - out(variant::insert_dcpomatic("list-cinemas list known cinemas from %1 settings")); - out(variant::insert_dcpomatic("list-dkdm-cpls list CPLs for which %1 has DKDMs")); - out(variant::insert_dcpomatic("add-dkdm add DKDM to %1's list")); - out(variant::insert_dcpomatic("dump-decryption-certificate write the %1 KDM decryption certificate to the console")); + out(variant::insert_dcpomatic("list-cinemas list known cinemas from {} settings")); + out(variant::insert_dcpomatic("list-dkdm-cpls list CPLs for which {} has DKDMs")); + out(variant::insert_dcpomatic("add-dkdm add DKDM to {}'s list")); + out(variant::insert_dcpomatic("dump-decryption-certificate write the {} KDM decryption certificate to the console")); out(" -h, --help show this help"); out(" -o, --output <path> output file or directory"); out(" -K, --filename-format <format> filename format for KDMs"); @@ -87,17 +88,17 @@ help(std::function<void (string)> out) out(" -C, --projector-certificate <file> file containing projector certificate"); out(" -T, --trusted-device-certificate <file> file containing a trusted device's certificate"); out(" --decryption-key <file> file containing the private key which can decrypt the given DKDM"); - out(variant::insert_dcpomatic(" (%1's configured private key will be used otherwise)")); + out(variant::insert_dcpomatic(" ({}'s configured private key will be used otherwise)")); out(" --cinemas-file <file> use the given file as a list of cinemas instead of the current configuration"); out(""); - out(variant::insert_dcpomatic("CPL-ID must be the ID of a CPL that is mentioned in %1's DKDM list.")); + out(variant::insert_dcpomatic("CPL-ID must be the ID of a CPL that is mentioned in {}'s DKDM list.")); out(""); out("For example:"); out(""); out("Create KDMs for my_great_movie to play in all of Fred's Cinema's screens for the next two weeks and zip them up."); - out(variant::insert_dcpomatic("(Fred's Cinema must have been set up in %1's KDM window)")); + out(variant::insert_dcpomatic("(Fred's Cinema must have been set up in {}'s KDM window)")); out(""); - out(String::compose("\t%1 -c \"Fred's Cinema\" -f now -d \"2 weeks\" -z my_great_movie", program_name)); + out(fmt::format("\t{} -c \"Fred's Cinema\" -f now -d \"2 weeks\" -z my_great_movie", program_name)); } @@ -105,7 +106,7 @@ class KDMCLIError : public std::runtime_error { public: KDMCLIError(std::string message) - : std::runtime_error(String::compose("%1: %2", program_name, message).c_str()) + : std::runtime_error(fmt::format("{}: {}", program_name, message).c_str()) {} }; @@ -130,7 +131,7 @@ duration_from_string(string d) string const unit(unit_buf); if (N == 0) { - throw KDMCLIError(String::compose("could not understand duration \"%1\"", d)); + throw KDMCLIError(fmt::format("could not understand duration \"{}\"", d)); } if (unit == "year" || unit == "years") { @@ -143,7 +144,7 @@ duration_from_string(string d) return boost::posix_time::time_duration(N, 0, 0, 0); } - throw KDMCLIError(String::compose("could not understand duration \"%1\"", d)); + throw KDMCLIError(fmt::format("could not understand duration \"{}\"", d)); } @@ -176,7 +177,7 @@ write_files( ); if (verbose) { - out(String::compose("Wrote %1 ZIP files to %2", N, output)); + out(fmt::format("Wrote {} ZIP files to {}", N, output.string())); } } else { int const N = write_files( @@ -185,7 +186,7 @@ write_files( ); if (verbose) { - out(String::compose("Wrote %1 KDM files to %2", N, output)); + out(fmt::format("Wrote {} KDM files to {}", N, output.string())); } } } @@ -230,10 +231,10 @@ from_film( film = make_shared<Film>(film_dir); film->read_metadata(); if (verbose) { - out(String::compose("Read film %1", film->name())); + out(fmt::format("Read film {}", film->name())); } } catch (std::exception& e) { - throw KDMCLIError(String::compose("error reading film \"%1\" (%2)", film_dir.string(), e.what())); + throw KDMCLIError(fmt::format("error reading film \"{}\" ({})", film_dir.string(), e.what())); } /* XXX: allow specification of this */ @@ -294,7 +295,7 @@ from_film( send_emails({kdms}, container_name_format, filename_format, film->dcp_name(), {}); } } catch (FileError& e) { - throw KDMCLIError(String::compose("%1 (%2)", e.what(), e.file().string())); + throw KDMCLIError(fmt::format("{} ({})", e.what(), e.file().string())); } } @@ -424,7 +425,7 @@ from_dkdm( send_emails({kdms}, container_name_format, filename_format, dkdm.annotation_text().get_value_or(""), {}); } } catch (FileError& e) { - throw KDMCLIError(String::compose("%1 (%2)", e.what(), e.file().string())); + throw KDMCLIError(fmt::format("{} ({})", e.what(), e.file().string())); } } @@ -623,7 +624,7 @@ try } if (std::find(commands.begin(), commands.end(), command) == commands.end()) { - throw KDMCLIError(String::compose("Unrecognised command %1", command)); + throw KDMCLIError(fmt::format("Unrecognised command {}", command)); } if (cinemas_file) { @@ -644,7 +645,7 @@ try if (command == "list-cinemas") { CinemaList cinemas; for (auto const& cinema: cinemas.cinemas()) { - out(String::compose("%1 (%2)", cinema.second.name, Email::address_list(cinema.second.emails))); + out(fmt::format("{} ({})", cinema.second.name, Email::address_list(cinema.second.emails))); } return {}; } @@ -711,7 +712,7 @@ try } if (verbose) { - out(String::compose("Making KDMs valid from %1 to %2", boost::posix_time::to_simple_string(valid_from.get()), boost::posix_time::to_simple_string(valid_to.get()))); + out(fmt::format("Making KDMs valid from {} to {}", boost::posix_time::to_simple_string(valid_from.get()), boost::posix_time::to_simple_string(valid_to.get()))); } string const thing = argv[optind]; diff --git a/src/lib/map_cli.cc b/src/lib/map_cli.cc index 20d5ce6af..43023a440 100644 --- a/src/lib/map_cli.cc +++ b/src/lib/map_cli.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "config.h" #include "util.h" #include <dcp/cpl.h> @@ -55,7 +54,7 @@ using boost::optional; static void help(std::function<void (string)> out) { - out(String::compose("Syntax: %1 [OPTION} <cpl-file|ID> [<cpl-file|ID> ... ]", program_name)); + out(fmt::format("Syntax: {} [OPTION} <cpl-file|ID> [<cpl-file|ID> ... ]", program_name)); out(" -V, --version show libdcp version"); out(" -h, --help show this help"); out(" -o, --output output directory"); @@ -151,7 +150,7 @@ map_cli(int argc, char* argv[], std::function<void (string)> out) } if (dcp::filesystem::exists(*output_dir)) { - return String::compose("Output directory %1 already exists.", *output_dir); + return fmt::format("Output directory {} already exists.", output_dir->string()); } if (hard_link && soft_link) { @@ -161,7 +160,7 @@ map_cli(int argc, char* argv[], std::function<void (string)> out) boost::system::error_code ec; dcp::filesystem::create_directory(*output_dir, ec); if (ec) { - return String::compose("Could not create output directory %1: %2", *output_dir, ec.message()); + return fmt::format("Could not create output directory {}: {}", output_dir->string(), ec.message()); } /* Find all the assets in the asset directories. This assumes that the asset directories are in fact @@ -187,20 +186,20 @@ map_cli(int argc, char* argv[], std::function<void (string)> out) cpl->resolve_refs(assets); cpls.push_back(cpl); } catch (std::exception& e) { - return String::compose("Could not read CPL %1: %2", filename_or_id, e.what()); + return fmt::format("Could not read CPL {}: {}", filename_or_id, e.what()); } } else { auto cpl_iter = std::find_if(assets.begin(), assets.end(), [filename_or_id](shared_ptr<dcp::Asset> asset) { return asset->id() == filename_or_id; }); if (cpl_iter == assets.end()) { - return String::compose("Could not find CPL with ID %1", filename_or_id); + return fmt::format("Could not find CPL with ID {}", filename_or_id); } if (auto cpl = dynamic_pointer_cast<dcp::CPL>(*cpl_iter)) { cpl->resolve_refs(assets); cpls.push_back(cpl); } else { - return String::compose("Could not find CPL with ID %1", filename_or_id); + return fmt::format("Could not find CPL with ID {}", filename_or_id); } } } @@ -225,17 +224,17 @@ map_cli(int argc, char* argv[], std::function<void (string)> out) if (hard_link) { dcp::filesystem::create_hard_link(input_path, output_path, ec); if (ec) { - throw CopyError(String::compose("Could not hard-link asset %1: %2", input_path.string(), ec.message())); + throw CopyError(fmt::format("Could not hard-link asset {}: {}", input_path.string(), ec.message())); } } else if (soft_link) { dcp::filesystem::create_symlink(input_path, output_path, ec); if (ec) { - throw CopyError(String::compose("Could not soft-link asset %1: %2", input_path.string(), ec.message())); + throw CopyError(fmt::format("Could not soft-link asset {}: {}", input_path.string(), ec.message())); } } else { dcp::filesystem::copy_file(input_path, output_path, ec); if (ec) { - throw CopyError(String::compose("Could not copy asset %1: %2", input_path.string(), ec.message())); + throw CopyError(fmt::format("Could not copy asset {}: {}", input_path.string(), ec.message())); } } }; @@ -263,7 +262,7 @@ map_cli(int argc, char* argv[], std::function<void (string)> out) } if (rename) { - output_path /= String::compose("%1%2", (*iter)->id(), dcp::filesystem::extension((*iter)->file().get())); + output_path /= fmt::format("{}{}", (*iter)->id(), dcp::filesystem::extension((*iter)->file().get())); (*iter)->rename_file(output_path); } else { output_path /= (*iter)->file()->filename(); @@ -275,7 +274,7 @@ map_cli(int argc, char* argv[], std::function<void (string)> out) } else { boost::system::error_code ec; dcp::filesystem::remove_all(*output_dir, ec); - throw CopyError(String::compose("Could not find required asset %1", asset_id)); + throw CopyError(fmt::format("Could not find required asset {}", asset_id)); } }; @@ -339,7 +338,7 @@ map_cli(int argc, char* argv[], std::function<void (string)> out) dcp.set_issuer(Config::instance()->dcp_issuer()); dcp.write_xml(Config::instance()->signer_chain()); } catch (dcp::UnresolvedRefError& e) { - return String::compose("%1\nPerhaps you need to give a -d parameter to say where this asset is located.", e.what()); + return fmt::format("{}\nPerhaps you need to give a -d parameter to say where this asset is located.", e.what()); } return {}; diff --git a/src/lib/nanomsg.cc b/src/lib/nanomsg.cc index 8061e2f84..6252b40d1 100644 --- a/src/lib/nanomsg.cc +++ b/src/lib/nanomsg.cc @@ -24,6 +24,7 @@ #include "nanomsg.h" #include <nanomsg/nn.h> #include <nanomsg/pair.h> +#include <fmt/format.h> #include <cerrno> #include <stdexcept> @@ -44,11 +45,11 @@ Nanomsg::Nanomsg (bool server) } if (server) { if ((_endpoint = nn_bind(_socket, NANOMSG_URL)) < 0) { - throw runtime_error(String::compose("Could not bind nanomsg socket (%1)", errno)); + throw runtime_error(fmt::format("Could not bind nanomsg socket ({})", errno)); } } else { if ((_endpoint = nn_connect(_socket, NANOMSG_URL)) < 0) { - throw runtime_error(String::compose("Could not connect nanomsg socket (%1)", errno)); + throw runtime_error(fmt::format("Could not connect nanomsg socket ({})", errno)); } } } @@ -73,7 +74,7 @@ Nanomsg::send (string s, int timeout) if (errno == ETIMEDOUT || errno == EAGAIN) { return false; } - throw runtime_error(String::compose("Could not send to nanomsg socket (%1)", errno)); + throw runtime_error(fmt::format("Could not send to nanomsg socket ({})", errno)); } else if (r != int(s.length())) { throw runtime_error("Could not send to nanomsg socket (message too big)"); } diff --git a/src/lib/player.cc b/src/lib/player.cc index 516a66ee2..bb22067a6 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -24,7 +24,6 @@ #include "audio_content.h" #include "audio_decoder.h" #include "audio_processor.h" -#include "compose.hpp" #include "config.h" #include "content_audio.h" #include "content_video.h" @@ -57,6 +56,7 @@ #include <dcp/reel_picture_asset.h> #include <dcp/reel_sound_asset.h> #include <dcp/reel_text_asset.h> +#include <fmt/format.h> #include <algorithm> #include <iostream> #include <stdint.h> @@ -801,7 +801,7 @@ Player::pass() /* Let's not worry about less than a frame at 24fps */ int64_t const too_much_error = DCPTime::from_frames(1, 24).get(); if (error >= too_much_error) { - film->log()->log(String::compose("Silence starting before or after last audio by %1", error), LogEntry::TYPE_ERROR); + film->log()->log(fmt::format("Silence starting before or after last audio by {}", error), LogEntry::TYPE_ERROR); } DCPOMATIC_ASSERT(error < too_much_error); period.from = *_next_audio_time; @@ -1469,7 +1469,7 @@ Player::emit_audio(shared_ptr<AudioBuffers> data, DCPTime time) /* Log if the assert below is about to fail */ if (_next_audio_time && labs(time.get() - _next_audio_time->get()) > 1) { - film->log()->log(String::compose("Out-of-sequence emit %1 vs %2", to_string(time), to_string(*_next_audio_time)), LogEntry::TYPE_WARNING); + film->log()->log(fmt::format("Out-of-sequence emit {} vs {}", to_string(time), to_string(*_next_audio_time)), LogEntry::TYPE_WARNING); } /* This audio must follow on from the previous, allowing for half a sample (at 48kHz) leeway */ diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index bd326e853..a9566b5c7 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -483,7 +483,7 @@ maybe_add_text( if (!text_only && reel_asset->actual_duration() != period_duration) { throw ProgrammingError( __FILE__, __LINE__, - String::compose("%1 vs %2", reel_asset->actual_duration(), period_duration) + fmt::format("{} vs {}", reel_asset->actual_duration(), period_duration) ); } reel->add(reel_asset); @@ -529,7 +529,7 @@ ReelWriter::create_reel_picture(shared_ptr<dcp::Reel> reel, list<ReferencedReelA if (reel_asset->duration() != period_duration) { throw ProgrammingError( __FILE__, __LINE__, - String::compose("%1 vs %2", reel_asset->actual_duration(), period_duration) + fmt::format("{} vs {}", reel_asset->actual_duration(), period_duration) ); } reel->add(reel_asset); @@ -581,7 +581,7 @@ ReelWriter::create_reel_sound(shared_ptr<dcp::Reel> reel, list<ReferencedReelAss if (reel_asset->actual_duration() != period_duration) { throw ProgrammingError( __FILE__, __LINE__, - String::compose("%1 vs %2", reel_asset->actual_duration(), period_duration) + fmt::format("{} vs {}", reel_asset->actual_duration(), period_duration) ); } diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc index 52d6c58d3..c159c00ca 100644 --- a/src/lib/text_decoder.cc +++ b/src/lib/text_decoder.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "dcpomatic_log.h" #include "log.h" #include "text_content.h" diff --git a/src/lib/timer.cc b/src/lib/timer.cc index caef89e0e..0c823de2f 100644 --- a/src/lib/timer.cc +++ b/src/lib/timer.cc @@ -24,9 +24,9 @@ */ -#include "compose.hpp" #include "timer.h" #include "util.h" +#include <fmt/format.h> #include <sys/time.h> #include <iostream> @@ -130,7 +130,7 @@ StateTimer::~StateTimer () char buffer[64]; snprintf (buffer, 64, "%.4f", i.second.total_time); string total_time (buffer); - sorted.push_back (make_pair(i.second.total_time, String::compose("\t%1%2 %3 %4", name, total_time, i.second.number, (i.second.total_time / i.second.number)))); + sorted.push_back(make_pair(i.second.total_time, fmt::format("\t{}{} {} {}", name, total_time, i.second.number, (i.second.total_time / i.second.number)))); } sorted.sort ([](pair<double, string> const& a, pair<double, string> const& b) { diff --git a/src/lib/types.cc b/src/lib/types.cc index 28d58f36b..7247a726a 100644 --- a/src/lib/types.cc +++ b/src/lib/types.cc @@ -19,7 +19,6 @@ */ #include "types.h" -#include "compose.hpp" #include "dcpomatic_assert.h" #include <dcp/cpl.h> #include <dcp/dcp.h> diff --git a/src/lib/unzipper.cc b/src/lib/unzipper.cc index 8d468f24f..00431ff1b 100644 --- a/src/lib/unzipper.cc +++ b/src/lib/unzipper.cc @@ -19,6 +19,7 @@ */ +#include "compose.hpp" #include "dcpomatic_assert.h" #include "exceptions.h" #include "unzipper.h" diff --git a/src/lib/upload_job.cc b/src/lib/upload_job.cc index 3019b7662..1cb778667 100644 --- a/src/lib/upload_job.cc +++ b/src/lib/upload_job.cc @@ -24,7 +24,6 @@ */ -#include "compose.hpp" #include "config.h" #include "curl_uploader.h" #include "dcpomatic_log.h" diff --git a/src/lib/util.cc b/src/lib/util.cc index eeab9f2d6..89f8b79d5 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -410,7 +410,7 @@ ffmpeg_log_callback(void* ptr, int level, const char* fmt, va_list vl) av_log_format_line(ptr, level, fmt, vl, line, sizeof(line), &prefix); string str(line); boost::algorithm::trim(str); - dcpomatic_log->log(String::compose("FFmpeg: %1", str), LogEntry::TYPE_GENERAL); + dcpomatic_log->log(fmt::format("FFmpeg: {}", str), LogEntry::TYPE_GENERAL); } @@ -462,7 +462,7 @@ LIBDCP_ENABLE_WARNINGS if (running_tests) { putenv("FONTCONFIG_PATH=fonts"); } else { - putenv(String::compose("FONTCONFIG_PATH=%1", resources_path().string()).c_str()); + putenv(fmt::format("FONTCONFIG_PATH={}", resources_path().string()).c_str()); } #endif @@ -1029,7 +1029,7 @@ start_of_thread(string) string error_details(boost::system::error_code ec) { - return String::compose("%1:%2:%3", ec.category().name(), ec.value(), ec.message()); + return fmt::format("{}:{}:{}", ec.category().name(), ec.value(), ec.message()); } diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 3f2819082..408524551 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -362,16 +362,16 @@ VideoContent::identifier() const string VideoContent::technical_summary() const { - string const size_string = size() ? String::compose("%1x%2", size()->width, size()->height) : _("unknown"); + string const size_string = size() ? fmt::format("{}x{}", size()->width, size()->height) : _("unknown"); - string s = String::compose( - N_("video: length %1 frames, size %2"), + string s = fmt::format( + N_("video: length {} frames, size {}"), length_after_3d_combine(), size_string ); if (sample_aspect_ratio()) { - s += String::compose(N_(", sample aspect ratio %1"), sample_aspect_ratio().get()); + s += fmt::format(N_(", sample aspect ratio {}"), sample_aspect_ratio().get()); } return s; @@ -526,7 +526,7 @@ VideoContent::add_properties(list<UserProperty>& p) const { p.push_back(UserProperty(UserProperty::VIDEO, _("Length"), length(), _("video frames"))); if (auto s = size()) { - p.push_back(UserProperty(UserProperty::VIDEO, _("Size"), String::compose("%1x%2", s->width, s->height))); + p.push_back(UserProperty(UserProperty::VIDEO, _("Size"), fmt::format("{}x{}", s->width, s->height))); } } diff --git a/src/lib/video_ring_buffers.cc b/src/lib/video_ring_buffers.cc index 5f355c1ab..e78a60df7 100644 --- a/src/lib/video_ring_buffers.cc +++ b/src/lib/video_ring_buffers.cc @@ -19,19 +19,19 @@ */ -#include "video_ring_buffers.h" #include "player_video.h" -#include "compose.hpp" +#include "video_ring_buffers.h" +#include <fmt/format.h> #include <list> #include <iostream> +using std::cout; using std::list; using std::make_pair; -using std::cout; using std::pair; -using std::string; using std::shared_ptr; +using std::string; using boost::optional; using namespace dcpomatic; @@ -89,7 +89,7 @@ VideoRingBuffers::memory_used() const for (auto const& i: _data) { m += i.first->memory_used(); } - return make_pair(m, String::compose("%1 frames", _data.size())); + return make_pair(m, fmt::format("{} frames", _data.size())); } diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 72a6eaf8b..5681a5a6d 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -21,7 +21,6 @@ #include "audio_buffers.h" #include "audio_mapping.h" -#include "compose.hpp" #include "config.h" #include "constants.h" #include "cross.h" @@ -44,6 +43,7 @@ #include <dcp/locale_convert.h> #include <dcp/reel_file_asset.h> #include <dcp/reel_text_asset.h> +#include <fmt/format.h> #include <cerrno> #include <cfloat> #include <set> @@ -393,9 +393,9 @@ try } /* Nothing to do: wait until something happens which may indicate that we do */ - LOG_TIMING (N_("writer-sleep queue=%1"), _queue.size()); + LOG_TIMING (N_("writer-sleep queue={}"), _queue.size()); _empty_condition.wait (lock); - LOG_TIMING (N_("writer-wake queue=%1"), _queue.size()); + LOG_TIMING (N_("writer-wake queue={}"), _queue.size()); } /* We stop here if we have been asked to finish, and if either the queue @@ -406,12 +406,12 @@ try if (_finish && (!have_sequenced_image_at_queue_head() || _queue.empty())) { /* (Hopefully temporarily) log anything that was not written */ if (!_queue.empty() && !have_sequenced_image_at_queue_head()) { - LOG_WARNING (N_("Finishing writer with a left-over queue of %1:"), _queue.size()); + LOG_WARNING (N_("Finishing writer with a left-over queue of {}:"), _queue.size()); for (auto const& i: _queue) { if (i.type == QueueItem::Type::FULL) { - LOG_WARNING (N_("- type FULL, frame %1, eyes %2"), i.frame, (int) i.eyes); + LOG_WARNING (N_("- type FULL, frame {}, eyes {}"), i.frame, (int) i.eyes); } else { - LOG_WARNING(N_("- type FAKE, frame %1, eyes %2"), i.frame, static_cast<int>(i.eyes)); + LOG_WARNING(N_("- type FAKE, frame {}, eyes {}"), i.frame, static_cast<int>(i.eyes)); } } } @@ -433,7 +433,7 @@ try switch (qi.type) { case QueueItem::Type::FULL: - LOG_DEBUG_ENCODE (N_("Writer FULL-writes %1 (%2)"), qi.frame, (int) qi.eyes); + LOG_DEBUG_ENCODE (N_("Writer FULL-writes {} ({})"), qi.frame, (int) qi.eyes); if (!qi.encoded) { /* Get the data back from disk where we stored it temporarily */ qi.encoded = make_shared<ArrayData>(film()->j2c_path(qi.reel, qi.frame, qi.eyes, false)); @@ -442,12 +442,12 @@ try ++_full_written; break; case QueueItem::Type::FAKE: - LOG_DEBUG_ENCODE (N_("Writer FAKE-writes %1"), qi.frame); + LOG_DEBUG_ENCODE (N_("Writer FAKE-writes {}"), qi.frame); reel.fake_write(qi.frame, qi.eyes); ++_fake_written; break; case QueueItem::Type::REPEAT: - LOG_DEBUG_ENCODE (N_("Writer REPEAT-writes %1"), qi.frame); + LOG_DEBUG_ENCODE (N_("Writer REPEAT-writes {}"), qi.frame); reel.repeat_write (qi.frame, qi.eyes); ++_repeat_written; break; @@ -472,7 +472,7 @@ try DCPOMATIC_ASSERT(item != _queue.rend()); ++_pushed_to_disk; - LOG_GENERAL("Writer full; pushes %1 to disk while awaiting %2", item->frame, _last_written[_queue.front().reel].frame() + 1); + LOG_GENERAL("Writer full; pushes {} to disk while awaiting {}", item->frame, _last_written[_queue.front().reel].frame() + 1); item->encoded->write_via_temp( film()->j2c_path(item->reel, item->frame, item->eyes, true), @@ -613,12 +613,12 @@ Writer::finish() auto creator = Config::instance()->dcp_creator(); if (creator.empty()) { - creator = String::compose("DCP-o-matic %1 %2", dcpomatic_version, dcpomatic_git_commit); + creator = fmt::format("DCP-o-matic {} {}", dcpomatic_version, dcpomatic_git_commit); } auto issuer = Config::instance()->dcp_issuer(); if (issuer.empty()) { - issuer = String::compose("DCP-o-matic %1 %2", dcpomatic_version, dcpomatic_git_commit); + issuer = fmt::format("DCP-o-matic {} {}", dcpomatic_version, dcpomatic_git_commit); } cpl->set_creator (creator); @@ -709,7 +709,7 @@ Writer::finish() dcp.write_xml(signer, Config::instance()->dcp_metadata_filename_format(), group_id); LOG_GENERAL ( - N_("Wrote %1 FULL, %2 FAKE, %3 REPEAT, %4 pushed to disk"), _full_written, _fake_written, _repeat_written, _pushed_to_disk + N_("Wrote {} FULL, {} FAKE, {} REPEAT, %4 pushed to disk"), _full_written, _fake_written, _repeat_written, _pushed_to_disk ); write_cover_sheet(); @@ -759,13 +759,13 @@ Writer::write_cover_sheet() } if (size > (1000000000L)) { - boost::algorithm::replace_all (text, "$SIZE", String::compose("%1GB", dcp::locale_convert<string>(size / 1000000000.0, 1, true))); + boost::algorithm::replace_all(text, "$SIZE", fmt::format("{}GB", dcp::locale_convert<string>(size / 1000000000.0, 1, true))); } else { - boost::algorithm::replace_all (text, "$SIZE", String::compose("%1MB", dcp::locale_convert<string>(size / 1000000.0, 1, true))); + boost::algorithm::replace_all(text, "$SIZE", fmt::format("{}MB", dcp::locale_convert<string>(size / 1000000.0, 1, true))); } auto ch = audio_channel_types (film()->mapped_audio_channels(), film()->audio_channels()); - auto description = String::compose("%1.%2", ch.first, ch.second); + auto description = fmt::format("{}.{}", ch.first, ch.second); if (description == "0.0") { description = _("None"); @@ -779,11 +779,11 @@ Writer::write_cover_sheet() auto const hmsf = film()->length().split(film()->video_frame_rate()); string length; if (hmsf.h == 0 && hmsf.m == 0) { - length = String::compose("%1s", hmsf.s); + length = fmt::format("{}s", hmsf.s); } else if (hmsf.h == 0 && hmsf.m > 0) { - length = String::compose("%1m%2s", hmsf.m, hmsf.s); + length = fmt::format("{}m{}s", hmsf.m, hmsf.s); } else if (hmsf.h > 0 && hmsf.m > 0) { - length = String::compose("%1h%2m%3s", hmsf.h, hmsf.m, hmsf.s); + length = fmt::format("{}h{}m{}s", hmsf.h, hmsf.m, hmsf.s); } boost::algorithm::replace_all (text, "$LENGTH", length); diff --git a/src/lib/zipper.cc b/src/lib/zipper.cc index 7b9d55ef4..b2c3673ad 100644 --- a/src/lib/zipper.cc +++ b/src/lib/zipper.cc @@ -24,6 +24,7 @@ #include "zipper.h" #include <dcp/filesystem.h> #include <zip.h> +#include <fmt/format.h> #include <boost/filesystem.hpp> #include <stdexcept> @@ -62,7 +63,7 @@ Zipper::add(string name, string content) #else if (zip_add(_zip, name.c_str(), source) == -1) { #endif - throw runtime_error(String::compose("failed to add data to ZIP archive (%1)", zip_strerror(_zip))); + throw runtime_error(fmt::format("failed to add data to ZIP archive ({})", zip_strerror(_zip))); } } diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index d8e79d667..af1738888 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -1488,7 +1488,7 @@ private: for (size_t i = 0; i < history.size(); ++i) { string s; if (i < 9) { - s = String::compose ("&%1 %2", i + 1, history[i].string()); + s = fmt::format("&{} {}", i + 1, history[i].string()); } else { s = history[i].string(); } diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc index 56b30590f..f726412f1 100644 --- a/src/tools/dcpomatic_disk.cc +++ b/src/tools/dcpomatic_disk.cc @@ -49,6 +49,7 @@ LIBDCP_DISABLE_WARNINGS #include <boost/process.hpp> LIBDCP_ENABLE_WARNINGS +#include <fmt/format.h> #ifdef DCPOMATIC_WINDOWS #include <boost/process/windows.hpp> #endif @@ -252,7 +253,7 @@ private: #ifdef DCPOMATIC_OSX void uninstall() { - system(String::compose("osascript \"%1/uninstall_disk.applescript\"", resources_path().string()).c_str()); + system(fmt::format("osascript \"{}/uninstall_disk.applescript\"", resources_path().string()).c_str()); } #endif diff --git a/src/tools/dcpomatic_disk_writer.cc b/src/tools/dcpomatic_disk_writer.cc index 3bb6fcd3f..c7dc69e1d 100644 --- a/src/tools/dcpomatic_disk_writer.cc +++ b/src/tools/dcpomatic_disk_writer.cc @@ -19,7 +19,6 @@ */ -#include "lib/compose.hpp" #include "lib/cross.h" #include "lib/dcpomatic_log.h" #include "lib/digester.h" diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index d596f8ca2..eb5d90893 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -42,7 +42,6 @@ #include "wx/wx_variant.h" #include "lib/cinema.h" #include "lib/collator.h" -#include "lib/compose.hpp" #include "lib/constants.h" #include "lib/config.h" #include "lib/cross.h" diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 9fb4a049b..2c0acb13c 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -38,7 +38,6 @@ #include "wx/wx_signal_manager.h" #include "wx/wx_util.h" #include "wx/wx_variant.h" -#include "lib/compose.hpp" #include "lib/config.h" #include "lib/constants.h" #include "lib/cross.h" @@ -90,6 +89,7 @@ LIBDCP_ENABLE_WARNINGS #ifdef __WXGTK__ #include <X11/Xlib.h> #endif +#include <fmt/format.h> #include <boost/algorithm/string.hpp> #include <boost/bind/bind.hpp> #include <iostream> @@ -1181,7 +1181,7 @@ private: for (size_t i = 0; i < history.size(); ++i) { string s; if (i < 9) { - s = String::compose ("&%1 %2", i + 1, history[i].string()); + s = fmt::format("&{} {}", i + 1, history[i].string()); } else { s = history[i].string(); } diff --git a/src/tools/dcpomatic_server.cc b/src/tools/dcpomatic_server.cc index e5d8b0a90..effa3a885 100644 --- a/src/tools/dcpomatic_server.cc +++ b/src/tools/dcpomatic_server.cc @@ -44,6 +44,7 @@ LIBDCP_DISABLE_WARNINGS #include <wx/splash.h> #include <wx/taskbar.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/format.h> #include <boost/optional.hpp> #include <boost/thread.hpp> #include <iostream> @@ -253,7 +254,7 @@ public: #else string const colour = gui_is_dark() ? "white" : "black"; wxBitmap bitmap ( - bitmap_path(String::compose("dcpomatic_small_%1.png", colour)), + bitmap_path(fmt::format("dcpomatic_small_{}.png", colour)), wxBITMAP_TYPE_PNG ); wxIcon icon; diff --git a/src/wx/about_dialog.cc b/src/wx/about_dialog.cc index 2abf0ef17..c4cbde70a 100644 --- a/src/wx/about_dialog.cc +++ b/src/wx/about_dialog.cc @@ -61,9 +61,9 @@ AboutDialog::AboutDialog(wxWindow* parent) wxString s; if (strcmp(dcpomatic_git_commit, "release") == 0) { - t = new StaticText(this, std_to_wx(String::compose("Version %1", dcpomatic_version))); + t = new StaticText(this, std_to_wx(fmt::format("Version {}", dcpomatic_version))); } else { - t = new StaticText(this, std_to_wx(String::compose("Version %1 git %2", dcpomatic_version, dcpomatic_git_commit))); + t = new StaticText(this, std_to_wx(fmt::format("Version {} git {}", dcpomatic_version, dcpomatic_git_commit))); } t->SetFont(version_font); sizer->Add(t, wxSizerFlags().Centre().Border(wxALL, 2)); diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc index ad478ddd0..6c5b7a26d 100644 --- a/src/wx/audio_plot.cc +++ b/src/wx/audio_plot.cc @@ -24,13 +24,13 @@ #include "wx_util.h" #include "lib/audio_decoder.h" #include "lib/audio_analysis.h" -#include "lib/compose.hpp" #include "lib/constants.h" #include "lib/maths_util.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/graphics.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/format.h> #include <boost/bind/bind.hpp> #include <cfloat> @@ -197,7 +197,7 @@ AudioPlot::paint () int const y = (metrics.height - (i - _minimum) * metrics.y_scale) - metrics.y_origin; h_grid.MoveToPoint (metrics.db_label_width - 4, y); h_grid.AddLineToPoint (metrics.db_label_width + data_width, y); - gc->DrawText (std_to_wx (String::compose ("%1dB", i)), 0, y - (db_label_height / 2)); + gc->DrawText(std_to_wx(fmt::format("{}dB", i)), 0, y - (db_label_height / 2)); } wxColour const grid_colour = gui_is_dark() ? wxColour(80, 80, 80) : wxColour(200, 200, 200); diff --git a/src/wx/christie_certificate_panel.cc b/src/wx/christie_certificate_panel.cc index 3536f5045..360691335 100644 --- a/src/wx/christie_certificate_panel.cc +++ b/src/wx/christie_certificate_panel.cc @@ -22,12 +22,13 @@ #include "download_certificate_dialog.h" #include "wx_util.h" #include "lib/internet.h" -#include "lib/compose.hpp" #include "lib/config.h" +#include <fmt/format.h> + using std::string; -using boost::optional; using boost::bind; +using boost::optional; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif @@ -50,8 +51,8 @@ ChristieCertificatePanel::ChristieCertificatePanel (DownloadCertificateDialog* d void ChristieCertificatePanel::do_download () { - string const prefix = String::compose( - "ftp://%1:%2@certificates.christiedigital.com/Certificates/", + auto const prefix = fmt::format( + "ftp://{}:{}@certificates.christiedigital.com/Certificates/", Config::instance()->christie_username().get(), Config::instance()->christie_password().get() ); @@ -59,7 +60,7 @@ ChristieCertificatePanel::do_download () string serial = wx_to_std (_serial->GetValue()); serial.insert (0, 12 - serial.length(), '0'); - string const url = String::compose ("%1F-IMB/F-IMB_%2_sha256.pem", prefix, serial); + auto const url = fmt::format("{}F-IMB/F-IMB_{}_sha256.pem", prefix, serial); optional<string> all_errors; bool ok = true; @@ -68,7 +69,7 @@ ChristieCertificatePanel::do_download () if (error) { all_errors = *error; - auto const url = String::compose ("%1IMB-S2/IMB-S2_%2_sha256.pem", prefix, serial); + auto const url = fmt::format("{}IMB-S2/IMB-S2_{}_sha256.pem", prefix, serial); error = get_from_url (url, true, false, boost::bind(&DownloadCertificatePanel::load_certificate_from_chain, this, _1, _2)); if (error) { diff --git a/src/wx/content_sub_panel.cc b/src/wx/content_sub_panel.cc index 10fdfa232..8b60c740e 100644 --- a/src/wx/content_sub_panel.cc +++ b/src/wx/content_sub_panel.cc @@ -23,7 +23,6 @@ #include "content_panel.h" #include "wx_util.h" #include "lib/dcp_content.h" -#include "lib/compose.hpp" #include "lib/log.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS diff --git a/src/wx/content_timeline_dialog.cc b/src/wx/content_timeline_dialog.cc index 697e6561f..4d1bbb1d4 100644 --- a/src/wx/content_timeline_dialog.cc +++ b/src/wx/content_timeline_dialog.cc @@ -23,7 +23,6 @@ #include "content_timeline_dialog.h" #include "film_editor.h" #include "wx_util.h" -#include "lib/compose.hpp" #include "lib/cross.h" #include "lib/film.h" #include "lib/playlist.h" diff --git a/src/wx/dolby_doremi_certificate_panel.cc b/src/wx/dolby_doremi_certificate_panel.cc index 24d8eb31a..95bdfc8bd 100644 --- a/src/wx/dolby_doremi_certificate_panel.cc +++ b/src/wx/dolby_doremi_certificate_panel.cc @@ -22,13 +22,13 @@ #include "dolby_doremi_certificate_panel.h" #include "download_certificate_dialog.h" #include "wx_util.h" -#include "lib/compose.hpp" #include "lib/internet.h" #include "lib/signal_manager.h" #include "lib/util.h" #include <dcp/raw_convert.h> #include <curl/curl.h> #include <zip.h> +#include <fmt/format.h> #include <boost/algorithm/string.hpp> @@ -66,28 +66,28 @@ DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (DownloadCertificateDia static void try_common(vector<Location>& locations, string prefix, string serial) { - auto files = ls_url(String::compose("%1%2xxx/", prefix, serial.substr(0, 3))); + auto files = ls_url(fmt::format("{}{}xxx/", prefix, serial.substr(0, 3))); auto check = [&locations, prefix, files, serial](string format, string file) { - auto const zip = String::compose(format, serial); + auto const zip = fmt::format(format, serial); if (find(files.begin(), files.end(), zip) != files.end()) { locations.push_back({ - String::compose("%1%2xxx/%3", prefix, serial.substr(0, 3), zip), - String::compose(file, serial) + fmt::format("{}{}xxx/{}", prefix, serial.substr(0, 3), zip), + fmt::format(file, serial) }); } }; - check("Dolby-DCP2000-%1.dcicerts.zip", "Dolby-DCP2000-%1.cert.sha256.pem"); - check("Dolby-DCP2000-%1.certs.zip", "Dolby-DCP2000-%1.cert.sha256.pem"); - check("dcp2000-%1.dcicerts.zip", "dcp2000-%1.cert.sha256.pem"); - check("dcp2000-%1.certs.zip", "dcp2000-%1.cert.sha256.pem"); - check("Dolby-IMB-%1.dcicerts.zip", "Dolby-IMB-%1.cert.sha256.pem"); - check("imb-%1.dcicerts.zip", "imb-%1.cert.sha256.pem"); - check("Dolby-IMS1000-%1.dcicerts.zip", "Dolby-IMS1000-%1.cert.sha256.pem"); - check("Dolby-IMS2000-%1.dcicerts.zip", "Dolby-IMS2000-%1.cert.sha256.pem"); - check("cert_Dolby-IMS3000-%1-SMPTE.zip", "cert_Dolby-IMS3000-%1-SMPTE.pem"); - check("ims-%1.dcicerts.zip", "ims-%1.cert.sha256.pem"); + check("Dolby-DCP2000-{}.dcicerts.zip", "Dolby-DCP2000-{}.cert.sha256.pem"); + check("Dolby-DCP2000-{}.certs.zip", "Dolby-DCP2000-{}.cert.sha256.pem"); + check("dcp2000-{}.dcicerts.zip", "dcp2000-{}.cert.sha256.pem"); + check("dcp2000-{}.certs.zip", "dcp2000-{}.cert.sha256.pem"); + check("Dolby-IMB-{}.dcicerts.zip", "Dolby-IMB-{}.cert.sha256.pem"); + check("imb-{}.dcicerts.zip", "imb-{}.cert.sha256.pem"); + check("Dolby-IMS1000-{}.dcicerts.zip", "Dolby-IMS1000-{}.cert.sha256.pem"); + check("Dolby-IMS2000-{}.dcicerts.zip", "Dolby-IMS2000-{}.cert.sha256.pem"); + check("cert_Dolby-IMS3000-{}-SMPTE.zip", "cert_Dolby-IMS3000-{}-SMPTE.pem"); + check("ims-{}.dcicerts.zip", "ims-{}.cert.sha256.pem"); } @@ -103,12 +103,12 @@ try_cat862(vector<Location>& locations, string prefix, string serial) cat862 = "CAT862_617000_and_higher"; } else { int const lower = serial_int - (serial_int % 1000); - cat862 = String::compose ("CAT862_%1-%2", lower, lower + 999); + cat862 = fmt::format("CAT862_{}-{}", lower, lower + 999); } locations.push_back({ - String::compose("%1%2/cert_Dolby256-CAT862-%3.zip", prefix, cat862, serial_int), - String::compose("cert_Dolby256-CAT862-%1.pem.crt", serial_int) + fmt::format("{}{}/cert_Dolby256-CAT862-{}.zip", prefix, cat862, serial_int), + fmt::format("cert_Dolby256-CAT862-{}.pem.crt", serial_int) }); } @@ -125,12 +125,12 @@ try_dsp100(vector<Location>& locations, string prefix, string serial) dsp100 = "DSP100_3000_and_higher"; } else { int const lower = serial_int - (serial_int % 1000); - dsp100 = String::compose ("DSP100_%1_thru_%2", lower, lower + 999); + dsp100 = fmt::format("DSP100_{}_thru_{}", lower, lower + 999); } locations.push_back({ - String::compose("%1%2/cert_Dolby256-DSP100-%3.zip", prefix, dsp100, serial_int), - String::compose("cert_Dolby256-DSP100-%1.pem.crt", serial_int) + fmt::format("{}{}/cert_Dolby256-DSP100-{}.zip", prefix, dsp100, serial_int), + fmt::format("cert_Dolby256-DSP100-{}.pem.crt", serial_int) }); } @@ -147,12 +147,12 @@ try_cat745(vector<Location>& locations, string prefix, string serial) cat745 = "CAT745_6000_and_higher"; } else { int const lower = serial_int - (serial_int % 1000); - cat745 = String::compose("CAT745_%1_thru_%2", lower, lower + 999); + cat745 = fmt::format("CAT745_{}_thru_{}", lower, lower + 999); } locations.push_back({ - String::compose("%1%2/cert_Dolby-CAT745-%3.zip", prefix, cat745, serial_int), - String::compose("cert_Dolby-CAT745-%1.pem.crt", serial_int) + fmt::format("{}{}/cert_Dolby-CAT745-{}.zip", prefix, cat745, serial_int), + fmt::format("cert_Dolby-CAT745-{}.pem.crt", serial_int) }); } @@ -164,8 +164,8 @@ try_cp850(vector<Location>& locations, string prefix, string serial) int const lower = serial_int - (serial_int % 1000); locations.push_back({ - String::compose ("%1CP850_CAT1600_F%2-F%3/cert_RMB_SPB_MDE_FMA.Dolby-CP850-F%4.zip", prefix, lower, lower + 999, serial_int), - String::compose ("cert_RMB_SPB_MDE_FMA.Dolby-CP850-F%1.pem.crt", serial_int) + fmt::format("{}CP850_CAT1600_F{}-F{}/cert_RMB_SPB_MDE_FMA.Dolby-CP850-F{}.zip", prefix, lower, lower + 999, serial_int), + fmt::format("cert_RMB_SPB_MDE_FMA.Dolby-CP850-F{}.pem.crt", serial_int) }); } diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 7b22999b0..45476c75d 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -34,7 +34,6 @@ #include "simple_video_view.h" #include "wx_util.h" #include "lib/butler.h" -#include "lib/compose.hpp" #include "lib/config.h" #include "lib/dcp_content.h" #include "lib/dcpomatic_log.h" diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index 4ca5af21a..08e1e2521 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -443,7 +443,7 @@ GLVideoView::setup_shaders() log = string(log_char.data()); } glDeleteShader(shader); - throw GLError(String::compose("Could not compile shader (%1)", log).c_str(), -1); + throw GLError(fmt::format("Could not compile shader (%1)", log).c_str(), -1); } return shader; }; @@ -471,7 +471,7 @@ GLVideoView::setup_shaders() log = string(log_char.data()); } glDeleteProgram(program); - throw GLError(String::compose("Could not link shader (%1)", log).c_str(), -1); + throw GLError(fmt::format("Could not link shader (%1)", log).c_str(), -1); } glDeleteShader(vertex_shader); glDeleteShader(fragment_shader); diff --git a/src/wx/job_view.cc b/src/wx/job_view.cc index aa175816d..7ed44ee1e 100644 --- a/src/wx/job_view.cc +++ b/src/wx/job_view.cc @@ -27,7 +27,6 @@ #include "wx_util.h" #include "wx_variant.h" #include "lib/analyse_audio_job.h" -#include "lib/compose.hpp" #include "lib/config.h" #include "lib/job.h" #include "lib/job_manager.h" diff --git a/src/wx/playlist_controls.cc b/src/wx/playlist_controls.cc index 87a0e9a4a..c7dad4139 100644 --- a/src/wx/playlist_controls.cc +++ b/src/wx/playlist_controls.cc @@ -26,7 +26,6 @@ #include "static_text.h" #include "wx_util.h" #include "wx_variant.h" -#include "lib/compose.hpp" #include "lib/constants.h" #include "lib/cross.h" #include "lib/dcp_content.h" diff --git a/src/wx/qube_certificate_panel.cc b/src/wx/qube_certificate_panel.cc index de8fa8a49..696355d29 100644 --- a/src/wx/qube_certificate_panel.cc +++ b/src/wx/qube_certificate_panel.cc @@ -22,9 +22,9 @@ #include "download_certificate_dialog.h" #include "qube_certificate_panel.h" #include "wx_util.h" -#include "lib/compose.hpp" #include "lib/config.h" #include "lib/internet.h" +#include <fmt/format.h> #include <boost/algorithm/string.hpp> @@ -51,7 +51,7 @@ QubeCertificatePanel::QubeCertificatePanel (DownloadCertificateDialog* dialog, s void QubeCertificatePanel::do_download () { - auto files = ls_url(String::compose("%1SMPTE-%2/", base, _type)); + auto files = ls_url(fmt::format("{}SMPTE-{}/", base, _type)); if (files.empty()) { error_dialog (this, _("Could not read certificates from Qube server.")); return; @@ -62,7 +62,7 @@ QubeCertificatePanel::do_download () optional<string> name; for (auto i: files) { - if (boost::algorithm::starts_with(i, String::compose("%1-%2-", _type, serial))) { + if (boost::algorithm::starts_with(i, fmt::format("{}-{}-", _type, serial))) { name = i; break; } @@ -74,7 +74,7 @@ QubeCertificatePanel::do_download () return; } - auto error = get_from_url (String::compose("%1SMPTE-%2/%3", base, _type, *name), true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1, _2)); + auto error = get_from_url(fmt::format("{}SMPTE-{}/{}", base, _type, *name), true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1, _2)); if (error) { _dialog->message()->SetLabel({}); diff --git a/src/wx/screen_dialog.cc b/src/wx/screen_dialog.cc index 21786b8a2..84d798065 100644 --- a/src/wx/screen_dialog.cc +++ b/src/wx/screen_dialog.cc @@ -26,7 +26,6 @@ #include "static_text.h" #include "table_dialog.h" #include "wx_util.h" -#include "lib/compose.hpp" #include "lib/util.h" #include <dcp/warnings.h> #include <dcp/exceptions.h> diff --git a/test/audio_mapping_test.cc b/test/audio_mapping_test.cc index 22412b260..c67ad64e5 100644 --- a/test/audio_mapping_test.cc +++ b/test/audio_mapping_test.cc @@ -25,10 +25,10 @@ */ -#include <boost/test/unit_test.hpp> #include "lib/audio_mapping.h" #include "lib/constants.h" -#include "lib/compose.hpp" +#include <fmt/format.h> +#include <boost/test/unit_test.hpp> using std::list; @@ -72,7 +72,7 @@ guess_check (boost::filesystem::path filename, int output_channel) AudioMapping m (1, 8); m.make_default (0, filename); for (int i = 0; i < 8; ++i) { - BOOST_TEST_INFO (String::compose("%1 channel %2", filename, i)); + BOOST_TEST_INFO(fmt::format("{} channel {}", filename.string(), i)); BOOST_CHECK_CLOSE (m.get(0, i), i == output_channel ? 1 : 0, 0.01); } } diff --git a/test/burnt_subtitle_test.cc b/test/burnt_subtitle_test.cc index 6b2e64d6a..9010d7983 100644 --- a/test/burnt_subtitle_test.cc +++ b/test/burnt_subtitle_test.cc @@ -46,6 +46,7 @@ #include <dcp/reel_picture_asset.h> #include <dcp/reel_mono_picture_asset.h> #include <pango/pango-utils.h> +#include <fmt/format.h> #include <boost/test/unit_test.hpp> @@ -153,8 +154,8 @@ BOOST_AUTO_TEST_CASE(burnt_subtitle_test_position) { auto check = [](string alignment) { - auto const name = String::compose("burnt_subtitle_test_position_%1", alignment); - auto subs = content_factory(String::compose("test/data/burn_%1.xml", alignment)); + auto const name = fmt::format("burnt_subtitle_test_position_{}", alignment); + auto subs = content_factory(fmt::format("test/data/burn_{}.xml", alignment)); auto film = new_test_film(name, subs); subs[0]->text[0]->set_use(true); subs[0]->text[0]->set_burn(true); @@ -167,11 +168,11 @@ BOOST_AUTO_TEST_CASE(burnt_subtitle_test_position) }); #if defined(DCPOMATIC_WINDOWS) - check_dcp(String::compose("test/data/windows/%1", name), film); + check_dcp(fmt::format("test/data/windows/{}", name), film); #elif defined(DCPOMATIC_OSX) - check_dcp(String::compose("test/data/mac/%1", name), film); + check_dcp(fmt::format("test/data/mac/{}", name), film); #else - check_dcp(String::compose("test/data/%1", name), film); + check_dcp(fmt::format("test/data/{}", name), film); #endif }; diff --git a/test/cpl_hash_test.cc b/test/cpl_hash_test.cc index 603fa4b8d..33d1ae0c5 100644 --- a/test/cpl_hash_test.cc +++ b/test/cpl_hash_test.cc @@ -30,6 +30,7 @@ #include "lib/dcp_content.h" #include "lib/film.h" #include "test.h" +#include <fmt/format.h> #include <boost/algorithm/string.hpp> #include <boost/test/unit_test.hpp> @@ -50,7 +51,7 @@ BOOST_AUTO_TEST_CASE (hash_added_to_imported_dcp_test) make_and_verify_dcp (ov); /* Remove <Hash> tags from the CPL */ - for (auto i: directory_iterator(String::compose("build/test/%1/%2", ov_name, ov->dcp_name()))) { + for (auto i: directory_iterator(fmt::format("build/test/{}/{}", ov_name, ov->dcp_name()))) { if (boost::algorithm::starts_with(i.path().filename().string(), "cpl_")) { dcp::File in(i.path(), "r"); BOOST_REQUIRE (in); @@ -69,7 +70,7 @@ BOOST_AUTO_TEST_CASE (hash_added_to_imported_dcp_test) } string const vf_name = "hash_added_to_imported_dcp_test_vf"; - auto ov_content = make_shared<DCPContent>(String::compose("build/test/%1/%2", ov_name, ov->dcp_name())); + auto ov_content = make_shared<DCPContent>(fmt::format("build/test/{}/{}", ov_name, ov->dcp_name())); auto vf = new_test_film( vf_name, { ov_content } ); @@ -79,7 +80,7 @@ BOOST_AUTO_TEST_CASE (hash_added_to_imported_dcp_test) /* Check for Hash tags in the VF DCP */ int hashes = 0; - for (auto i: directory_iterator(String::compose("build/test/%1/%2", vf_name, vf->dcp_name()))) { + for (auto i: directory_iterator(fmt::format("build/test/{}/{}", vf_name, vf->dcp_name()))) { if (boost::algorithm::starts_with(i.path().filename().string(), "cpl_")) { dcp::File in(i.path(), "r"); BOOST_REQUIRE (in); diff --git a/test/digest_test.cc b/test/digest_test.cc index 39737b7f5..c65ddacdd 100644 --- a/test/digest_test.cc +++ b/test/digest_test.cc @@ -25,7 +25,6 @@ */ -#include "lib/compose.hpp" #include "lib/config.h" #include "lib/dcp_content_type.h" #include "lib/film.h" @@ -34,6 +33,7 @@ #include <dcp/cpl.h> #include <dcp/reel.h> #include <dcp/reel_picture_asset.h> +#include <fmt/format.h> #include <boost/test/unit_test.hpp> @@ -45,7 +45,7 @@ using std::string; static string openssl_hash (boost::filesystem::path file) { - auto pipe = popen (String::compose ("openssl sha1 -binary %1 | openssl base64 -e", file.string()).c_str (), "r"); + auto pipe = popen(fmt::format("openssl sha1 -binary {} | openssl base64 -e", file.string()).c_str (), "r"); BOOST_REQUIRE (pipe); char buffer[128]; string output; diff --git a/test/ffmpeg_encoder_test.cc b/test/ffmpeg_encoder_test.cc index 0a48cd745..4e5ef924e 100644 --- a/test/ffmpeg_encoder_test.cc +++ b/test/ffmpeg_encoder_test.cc @@ -20,7 +20,6 @@ #include "lib/audio_content.h" -#include "lib/compose.hpp" #include "lib/config.h" #include "lib/constants.h" #include "lib/content_factory.h" @@ -40,6 +39,7 @@ #include "test.h" #include <dcp/file.h> #include <dcp/raw_convert.h> +#include <fmt/format.h> #include <boost/test/unit_test.hpp> @@ -77,7 +77,7 @@ ffmpeg_content_test (int number, boost::filesystem::path content, ExportFormat f BOOST_REQUIRE (false); } - name = String::compose("%1_test%2", name, number); + name = fmt::format("{}_test{}", name, number); auto c = make_shared<FFmpegContent>(content); auto film = new_test_film(name, {c}, &cl); @@ -86,7 +86,7 @@ ffmpeg_content_test (int number, boost::filesystem::path content, ExportFormat f film->write_metadata (); auto job = make_shared<TranscodeJob>(film, TranscodeJob::ChangedBehaviour::IGNORE); - auto file = boost::filesystem::path("build") / "test" / String::compose("%1.%2", name, extension); + auto file = boost::filesystem::path("build") / "test" / fmt::format("{}.{}", name, extension); cl.add (file); FFmpegFilmEncoder encoder(film, job, file, format, false, false, false, 23); encoder.go (); diff --git a/test/ffmpeg_properties_test.cc b/test/ffmpeg_properties_test.cc index 1e0cdc42f..b60b465bb 100644 --- a/test/ffmpeg_properties_test.cc +++ b/test/ffmpeg_properties_test.cc @@ -19,11 +19,11 @@ */ -#include "lib/compose.hpp" #include "lib/content.h" #include "lib/content_factory.h" #include "lib/user_property.h" #include "test.h" +#include <fmt/format.h> #include <boost/test/unit_test.hpp> @@ -37,7 +37,7 @@ colour_range_test(string name, boost::filesystem::path file, string ref) { auto content = content_factory(file); BOOST_REQUIRE(!content.empty()); - auto film = new_test_film(String::compose("ffmpeg_properties_test_%1", name), { content.front() }); + auto film = new_test_film(fmt::format("ffmpeg_properties_test_{}", name), { content.front() }); auto properties = content.front()->user_properties(film); auto iter = std::find_if(properties.begin(), properties.end(), [](UserProperty const& property) { return property.key == "Colour range"; }); diff --git a/test/file_naming_test.cc b/test/file_naming_test.cc index 2953046b5..482119542 100644 --- a/test/file_naming_test.cc +++ b/test/file_naming_test.cc @@ -48,9 +48,9 @@ string mxf_regex(string part) { #ifdef DCPOMATIC_WINDOWS /* Windows replaces . in filenames with _ */ - return String::compose(".*flat_%1_png_.*\\.mxf", part); + return fmt::format(".*flat_{}_png_.*\\.mxf", part); #else - return String::compose(".*flat_%1\\.png_.*\\.mxf", part); + return fmt::format(".*flat_{}\\.png_.*\\.mxf", part); #endif }; diff --git a/test/hints_test.cc b/test/hints_test.cc index 1b510f9e7..5c444903a 100644 --- a/test/hints_test.cc +++ b/test/hints_test.cc @@ -30,6 +30,7 @@ #include "lib/hints.h" #include "lib/text_content.h" #include "test.h" +#include <fmt/format.h> #include <boost/test/unit_test.hpp> @@ -98,7 +99,7 @@ BOOST_AUTO_TEST_CASE (hint_closed_caption_too_long) check ( TextType::CLOSED_CAPTION, "hint_closed_caption_too_long", - String::compose("At least one of your closed caption lines has more than %1 characters. It is advisable to make each line %1 characters at most in length.", MAX_CLOSED_CAPTION_LENGTH, MAX_CLOSED_CAPTION_LENGTH) + fmt::format("At least one of your closed caption lines has more than {} characters. It is advisable to make each line {} characters at most in length.", MAX_CLOSED_CAPTION_LENGTH, MAX_CLOSED_CAPTION_LENGTH) ); } @@ -108,7 +109,7 @@ BOOST_AUTO_TEST_CASE (hint_many_closed_caption_lines) check ( TextType::CLOSED_CAPTION, "hint_many_closed_caption_lines", - String::compose("Some of your closed captions span more than %1 lines, so they will be truncated.", MAX_CLOSED_CAPTION_LINES) + fmt::format("Some of your closed captions span more than {} lines, so they will be truncated.", MAX_CLOSED_CAPTION_LINES) ); } @@ -193,12 +194,12 @@ BOOST_AUTO_TEST_CASE (hint_subtitle_mxf_too_big) } fake_font.close(); - auto content = content_factory(String::compose("test/data/%1%2.xml", name, i))[0]; + auto content = content_factory(fmt::format("test/data/{}{}.xml", name, i))[0]; content->text[0]->set_type(TextType::OPEN_SUBTITLE); content->text[0]->set_language(dcp::LanguageTag("en-US")); film->examine_and_add_content(content); BOOST_REQUIRE (!wait_for_jobs()); - auto const font = content->text[0]->get_font(String::compose("font_%1", i)); + auto const font = content->text[0]->get_font(fmt::format("font_{}", i)); BOOST_REQUIRE(font); font->set_file("build/test/hint_subtitle_mxf_too_big.ttf"); } @@ -220,7 +221,7 @@ BOOST_AUTO_TEST_CASE (hint_closed_caption_xml_too_big) auto film = new_test_film(name); - dcp::File ccap(String::compose("build/test/%1.srt", name), "w"); + dcp::File ccap(fmt::format("build/test/{}.srt", name), "w"); BOOST_REQUIRE (ccap); for (int i = 0; i < 2048; ++i) { fprintf(ccap.get(), "%d\n", i + 1); diff --git a/test/image_filename_sorter_test.cc b/test/image_filename_sorter_test.cc index 29b550753..aed8d7721 100644 --- a/test/image_filename_sorter_test.cc +++ b/test/image_filename_sorter_test.cc @@ -26,7 +26,7 @@ #include "lib/image_filename_sorter.h" -#include "lib/compose.hpp" +#include <fmt/format.h> #include <boost/test/unit_test.hpp> #include <algorithm> #include <random> @@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE (image_filename_sorter_test2) { vector<boost::filesystem::path> paths; for (int i = 0; i < 100000; ++i) { - paths.push_back(String::compose("some.filename.with.%1.number.tiff", i)); + paths.push_back(fmt::format("some.filename.with.{}.number.tiff", i)); } std::random_device rd; @@ -77,6 +77,6 @@ BOOST_AUTO_TEST_CASE (image_filename_sorter_test2) sort (paths.begin(), paths.end(), ImageFilenameSorter()); for (int i = 0; i < 100000; ++i) { - BOOST_CHECK_EQUAL(paths[i].string(), String::compose("some.filename.with.%1.number.tiff", i)); + BOOST_CHECK_EQUAL(paths[i].string(), fmt::format("some.filename.with.{}.number.tiff", i)); } } diff --git a/test/image_test.cc b/test/image_test.cc index 4df4f9125..d69a8a909 100644 --- a/test/image_test.cc +++ b/test/image_test.cc @@ -26,7 +26,6 @@ */ -#include "lib/compose.hpp" #include "lib/image.h" #include "lib/image_content.h" #include "lib/image_decoder.h" @@ -34,6 +33,7 @@ #include "lib/image_png.h" #include "lib/ffmpeg_image_proxy.h" #include "test.h" +#include <fmt/format.h> #include <boost/test/unit_test.hpp> #include <iostream> @@ -512,7 +512,7 @@ BOOST_AUTO_TEST_CASE (crop_scale_window_test7) Image::Alignment::PADDED, false ); - path file = String::compose("crop_scale_window_test7-%1.png", left_crop); + path file = fmt::format("crop_scale_window_test7-{}.png", left_crop); write_image(cropped, path("build") / "test" / file); check_image(path("test") / "data" / file, path("build") / "test" / file, 10); } diff --git a/test/kdm_naming_test.cc b/test/kdm_naming_test.cc index 4735ef75e..71a8c3e56 100644 --- a/test/kdm_naming_test.cc +++ b/test/kdm_naming_test.cc @@ -27,6 +27,7 @@ #include "lib/kdm_with_metadata.h" #include "lib/screen.h" #include "test.h" +#include <fmt/format.h> #include <boost/test/unit_test.hpp> @@ -136,7 +137,7 @@ BOOST_AUTO_TEST_CASE (single_kdm_naming_test) boost::algorithm::replace_all (until_time, ":", "-"); auto const dcp_date = boost::gregorian::to_iso_string(film->isdcf_date()); - auto const ref = String::compose("KDM_Cinema_A_-_Screen_1_-_MyGreatFilm_TST-1_F_XX-XX_MOS_2K_%1_SMPTE_OV_-_%2_%3_-_%4_%5.xml", dcp_date, from.date(), from_time, until.date(), until_time); + auto const ref = fmt::format("KDM_Cinema_A_-_Screen_1_-_MyGreatFilm_TST-1_F_XX-XX_MOS_2K_{}_SMPTE_OV_-_{}_{}_-_{}_{}.xml", dcp_date, from.date(), from_time, until.date(), until_time); BOOST_CHECK_MESSAGE (boost::filesystem::exists("build/test/single_kdm_naming_test/" + ref), "File " << ref << " not found"); } @@ -224,41 +225,41 @@ BOOST_AUTO_TEST_CASE(directory_kdm_naming_test) boost::algorithm::replace_all (until_time, ":", "-"); auto const dcp_date = boost::gregorian::to_iso_string(film->isdcf_date()); - auto const dcp_name = String::compose("MyGreatFilm_TST-1_F_XX-XX_MOS_2K_%1_SMPTE_OV", dcp_date); - auto const common = String::compose("%1_-_%2_%3_-_%4_%5", dcp_name, from.date(), from_time, until.date(), until_time); + auto const dcp_name = fmt::format("MyGreatFilm_TST-1_F_XX-XX_MOS_2K_{}_SMPTE_OV", dcp_date); + auto const common = fmt::format("{}_-_{}_{}_-_{}_{}", dcp_name, from.date(), from_time, until.date(), until_time); path const base = "build/test/directory_kdm_naming_test"; - path dir_a = String::compose("Cinema_A_-_%s_-_%1", common); + path dir_a = fmt::format("Cinema_A_-_%s_-_{}", common); BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_a), "Directory " << dir_a << " not found"); - path dir_b = String::compose("Cinema_B_-_%s_-_%1", common); + path dir_b = fmt::format("Cinema_B_-_%s_-_{}", common); BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_b), "Directory " << dir_b << " not found"); #ifdef DCPOMATIC_WINDOWS - path ref = String::compose("KDM_%1.xml", dcp_name); + path ref = fmt::format("KDM_{}.xml", dcp_name); #else - path ref = String::compose("KDM_Cinema_A_-_Screen_2_-_%1_-_%2.xml", common, cpl_id); + path ref = fmt::format("KDM_Cinema_A_-_Screen_2_-_{}_-_{}.xml", common, cpl_id); #endif BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_a / ref), "File " << ref << " not found"); #ifdef DCPOMATIC_WINDOWS - ref = String::compose("KDM_%1.xml", dcp_name); + ref = fmt::format("KDM_{}.xml", dcp_name); #else - ref = String::compose("KDM_Cinema_B_-_Screen_X_-_%1_-_%2.xml", common, cpl_id); + ref = fmt::format("KDM_Cinema_B_-_Screen_X_-_{}_-_{}.xml", common, cpl_id); #endif BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_b / ref), "File " << ref << " not found"); #ifdef DCPOMATIC_WINDOWS - ref = String::compose("KDM_%1.xml", dcp_name); + ref = fmt::format("KDM_{}.xml", dcp_name); #else - ref = String::compose("KDM_Cinema_A_-_Screen_1_-_%1_-_%2.xml", common, cpl_id); + ref = fmt::format("KDM_Cinema_A_-_Screen_1_-_{}_-_{}.xml", common, cpl_id); #endif BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_a / ref), "File " << ref << " not found"); #ifdef DCPOMATIC_WINDOWS - ref = String::compose("KDM_%1.xml", dcp_name); + ref = fmt::format("KDM_{}.xml", dcp_name); #else - ref = String::compose("KDM_Cinema_B_-_Screen_Z_-_%1_-_%2.xml", common, cpl_id); + ref = fmt::format("KDM_Cinema_B_-_Screen_Z_-_{}_-_{}.xml", common, cpl_id); #endif BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_b / ref), "File " << ref << " not found"); } diff --git a/test/map_cli_test.cc b/test/map_cli_test.cc index aaf5b944f..0cea9ae9e 100644 --- a/test/map_cli_test.cc +++ b/test/map_cli_test.cc @@ -32,6 +32,7 @@ #include <dcp/reel.h> #include <dcp/reel_picture_asset.h> #include <dcp/reel_sound_asset.h> +#include <fmt/format.h> #include <boost/algorithm/string.hpp> #include <boost/filesystem.hpp> #include <boost/optional.hpp> @@ -90,7 +91,7 @@ find_cpl(boost::filesystem::path dir) BOOST_AUTO_TEST_CASE(map_simple_dcp_copy) { string const name = "map_simple_dcp_copy"; - string const out = String::compose("build/test/%1_out", name); + string const out = fmt::format("build/test/{}_out", name); auto content = content_factory("test/data/flat_red.png"); auto film = new_test_film(name + "_in", content); @@ -120,7 +121,7 @@ BOOST_AUTO_TEST_CASE(map_simple_dcp_copy) BOOST_AUTO_TEST_CASE(map_simple_dcp_copy_by_id) { string const name = "map_simple_dcp_copy_by_id"; - string const out = String::compose("build/test/%1_out", name); + string const out = fmt::format("build/test/{}_out", name); auto content = content_factory("test/data/flat_red.png"); auto film = new_test_film(name + "_in", content); @@ -152,7 +153,7 @@ BOOST_AUTO_TEST_CASE(map_simple_dcp_copy_by_id) BOOST_AUTO_TEST_CASE(map_simple_dcp_copy_with_symlinks) { string const name = "map_simple_dcp_copy_with_symlinks"; - string const out = String::compose("build/test/%1_out", name); + string const out = fmt::format("build/test/{}_out", name); auto content = content_factory("test/data/flat_red.png"); auto film = new_test_film(name + "_in", content); @@ -185,7 +186,7 @@ BOOST_AUTO_TEST_CASE(map_simple_dcp_copy_with_symlinks) BOOST_AUTO_TEST_CASE(map_simple_dcp_copy_with_hardlinks) { string const name = "map_simple_dcp_copy_with_hardlinks"; - string const out = String::compose("build/test/%1_out", name); + string const out = fmt::format("build/test/{}_out", name); auto content = content_factory("test/data/flat_red.png"); auto film = new_test_film(name + "_in", content); @@ -216,7 +217,7 @@ BOOST_AUTO_TEST_CASE(map_simple_dcp_copy_with_hardlinks) BOOST_AUTO_TEST_CASE(map_simple_interop_dcp_with_subs) { string const name = "map_simple_interop_dcp_with_subs"; - string const out = String::compose("build/test/%1_out", name); + string const out = fmt::format("build/test/{}_out", name); auto picture = content_factory("test/data/flat_red.png").front(); auto subs = content_factory("test/data/15s.srt").front(); @@ -247,7 +248,7 @@ void test_map_ov_vf_copy(vector<string> extra_args = {}) { string const name = "map_ov_vf_copy"; - string const out = String::compose("build/test/%1_out", name); + string const out = fmt::format("build/test/{}_out", name); auto ov_content = content_factory("test/data/flat_red.png"); auto ov_film = new_test_film(name + "_ov", ov_content); @@ -298,7 +299,7 @@ BOOST_AUTO_TEST_CASE(map_ov_vf_copy) BOOST_AUTO_TEST_CASE(map_ov_vf_copy_multiple_reference) { string const name = "map_ov_vf_copy_multiple_reference"; - string const out = String::compose("build/test/%1_out", name); + string const out = fmt::format("build/test/{}_out", name); auto ov_content = content_factory("test/data/flat_red.png"); auto ov_film = new_test_film(name + "_ov", ov_content); @@ -346,7 +347,7 @@ BOOST_AUTO_TEST_CASE(map_simple_dcp_copy_with_rename) ConfigRestorer cr; Config::instance()->set_dcp_asset_filename_format(dcp::NameFormat("hello%c")); string const name = "map_simple_dcp_copy_with_rename"; - string const out = String::compose("build/test/%1_out", name); + string const out = fmt::format("build/test/{}_out", name); auto content = content_factory("test/data/flat_red.png"); auto film = new_test_film(name + "_in", content); @@ -394,7 +395,7 @@ static void test_two_cpls_each_with_subs(string name, bool interop) { - string const out = String::compose("build/test/%1_out", name); + string const out = fmt::format("build/test/{}_out", name); vector<dcp::VerificationNote::Code> acceptable_errors; if (interop) { @@ -408,7 +409,7 @@ test_two_cpls_each_with_subs(string name, bool interop) for (auto i = 0; i < 2; ++i) { auto picture = content_factory("test/data/flat_red.png").front(); auto subs = content_factory("test/data/15s.srt").front(); - films[i] = new_test_film(String::compose("%1_%2_in", name, i), { picture, subs }); + films[i] = new_test_film(fmt::format("{}_{}_in", name, i), { picture, subs }); films[i]->set_interop(interop); subs->only_text()->set_language(dcp::LanguageTag("de")); make_and_verify_dcp(films[i], acceptable_errors); @@ -450,7 +451,7 @@ BOOST_AUTO_TEST_CASE(map_with_given_config) ConfigRestorer cr; string const name = "map_with_given_config"; - string const out = String::compose("build/test/%1_out", name); + string const out = fmt::format("build/test/{}_out", name); auto content = content_factory("test/data/flat_red.png"); auto film = new_test_film(name + "_in", content); @@ -480,7 +481,7 @@ BOOST_AUTO_TEST_CASE(map_with_given_config) BOOST_AUTO_TEST_CASE(map_multireel_interop_ov_and_vf_adding_ccaps) { string const name = "map_multireel_interop_ov_and_vf_adding_ccaps"; - string const out = String::compose("build/test/%1_out", name); + string const out = fmt::format("build/test/{}_out", name); vector<shared_ptr<Content>> video = { content_factory("test/data/flat_red.png")[0], @@ -545,7 +546,7 @@ BOOST_AUTO_TEST_CASE(map_uses_config_for_issuer_and_creator) Config::instance()->set_dcp_creator("Fred"); string const name = "map_uses_config_for_issuer_and_creator"; - string const out = String::compose("build/test/%1_out", name); + string const out = fmt::format("build/test/{}_out", name); auto content = content_factory("test/data/flat_red.png"); auto film = new_test_film(name + "_in", content); diff --git a/test/markers_test.cc b/test/markers_test.cc index f7ff3a6b5..37ba3c999 100644 --- a/test/markers_test.cc +++ b/test/markers_test.cc @@ -32,6 +32,7 @@ #include <dcp/dcp.h> #include <dcp/reel_markers_asset.h> #include <dcp/reel.h> +#include <fmt/format.h> #include <boost/test/unit_test.hpp> @@ -50,7 +51,7 @@ BOOST_AUTO_TEST_CASE (automatic_ffoc_lfoc_markers_test1) film->set_interop (false); make_and_verify_dcp (film); - dcp::DCP dcp (String::compose("build/test/%1/%2", name, film->dcp_name())); + dcp::DCP dcp(fmt::format("build/test/{}/{}", name, film->dcp_name())); dcp.read (); BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U); auto cpl = dcp.cpls().front(); @@ -86,7 +87,7 @@ BOOST_AUTO_TEST_CASE (automatic_ffoc_lfoc_markers_test2) dcp::VerificationNote::Code::INCORRECT_LFOC }); - dcp::DCP dcp (String::compose("build/test/%1/%2", name, film->dcp_name())); + dcp::DCP dcp(fmt::format("build/test/{}/{}", name, film->dcp_name())); dcp.read (); BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U); auto cpl = dcp.cpls().front(); @@ -116,7 +117,7 @@ BOOST_AUTO_TEST_CASE(markers_correct_with_reels) film->set_reel_type(ReelType::BY_VIDEO_CONTENT); make_and_verify_dcp(film); - dcp::DCP dcp(String::compose("build/test/%1/%2", name, film->dcp_name())); + dcp::DCP dcp(fmt::format("build/test/{}/{}", name, film->dcp_name())); dcp.read (); BOOST_REQUIRE_EQUAL(dcp.cpls().size(), 1U); auto cpl = dcp.cpls()[0]; diff --git a/test/player_test.cc b/test/player_test.cc index 384a73ebc..3d98e6f42 100644 --- a/test/player_test.cc +++ b/test/player_test.cc @@ -28,7 +28,6 @@ #include "lib/audio_buffers.h" #include "lib/audio_content.h" #include "lib/butler.h" -#include "lib/compose.hpp" #include "lib/config.h" #include "lib/constants.h" #include "lib/content_factory.h" @@ -46,6 +45,7 @@ #include "lib/text_content.h" #include "lib/video_content.h" #include "test.h" +#include <fmt/format.h> #include <boost/test/unit_test.hpp> #include <boost/algorithm/string.hpp> #include <iostream> @@ -225,12 +225,12 @@ BOOST_AUTO_TEST_CASE (player_seek_test) butler->seek (t, true); auto video = butler->get_video(Butler::Behaviour::BLOCKING, 0); BOOST_CHECK_EQUAL(video.second.get(), t.get()); - write_image(video.first->image(AV_PIX_FMT_RGB24, VideoRange::FULL, true), String::compose("build/test/player_seek_test_%1.png", i)); + write_image(video.first->image(AV_PIX_FMT_RGB24, VideoRange::FULL, true), fmt::format("build/test/player_seek_test_{}.png", i)); /* This 14.08 is empirically chosen (hopefully) to accept changes in rendering between the reference and a test machine (17.10 and 16.04 seem to anti-alias a little differently) but to reject gross errors e.g. missing fonts or missing text altogether. */ - check_image(TestPaths::private_data() / String::compose("player_seek_test_%1.png", i), String::compose("build/test/player_seek_test_%1.png", i), 14.08); + check_image(TestPaths::private_data() / fmt::format("player_seek_test_{}.png", i), fmt::format("build/test/player_seek_test_{}.png", i), 14.08); } } @@ -261,9 +261,9 @@ BOOST_AUTO_TEST_CASE (player_seek_test2) auto video = butler->get_video(Butler::Behaviour::BLOCKING, 0); BOOST_CHECK_EQUAL(video.second.get(), t.get()); write_image( - video.first->image(AV_PIX_FMT_RGB24, VideoRange::FULL, true), String::compose("build/test/player_seek_test2_%1.png", i) + video.first->image(AV_PIX_FMT_RGB24, VideoRange::FULL, true), fmt::format("build/test/player_seek_test2_{}.png", i) ); - check_image(TestPaths::private_data() / String::compose("player_seek_test2_%1.png", i), String::compose("build/test/player_seek_test2_%1.png", i), 14.08); + check_image(TestPaths::private_data() / fmt::format("player_seek_test2_{}.png", i), fmt::format("build/test/player_seek_test2_{}.png", i), 14.08); } } diff --git a/test/subtitle_language_test.cc b/test/subtitle_language_test.cc index 789412912..06eb32d94 100644 --- a/test/subtitle_language_test.cc +++ b/test/subtitle_language_test.cc @@ -30,6 +30,7 @@ #include "lib/text_content.h" #include "test.h" #include <dcp/language_tag.h> +#include <fmt/format.h> #include <boost/test/unit_test.hpp> #include <vector> @@ -60,7 +61,7 @@ BOOST_AUTO_TEST_CASE (subtitle_language_interop_test) false ); - check_dcp(String::compose("test/data/%1", name), String::compose("build/test/%1/%2", name, film->dcp_name())); + check_dcp(fmt::format("test/data/{}", name), fmt::format("build/test/{}/{}", name, film->dcp_name())); } @@ -87,7 +88,7 @@ BOOST_AUTO_TEST_CASE (subtitle_language_smpte_test) * differences in sound between the DCP and the reference to avoid test * failures for unrelated reasons. */ - check_dcp(String::compose("test/data/%1", name), String::compose("build/test/%1/%2", name, film->dcp_name()), true); + check_dcp(fmt::format("test/data/{}", name), fmt::format("build/test/{}/{}", name, film->dcp_name()), true); } diff --git a/test/subtitle_position_test.cc b/test/subtitle_position_test.cc index 05e305478..55288a6ca 100644 --- a/test/subtitle_position_test.cc +++ b/test/subtitle_position_test.cc @@ -28,6 +28,7 @@ #include <dcp/interop_text_asset.h> #include <dcp/language_tag.h> #include <dcp/smpte_text_asset.h> +#include <fmt/format.h> #include <boost/test/unit_test.hpp> #include <vector> @@ -112,8 +113,8 @@ vpos_test(dcp::VAlign reference, float position, dcp::SubtitleStandard from, dcp break; } - auto name = String::compose("vpos_test_%1_%2", standard, valign_to_string(reference)); - auto in = content_factory(String::compose("test/data/%1.xml", name)); + auto name = fmt::format("vpos_test_{}_{}", standard, valign_to_string(reference)); + auto in = content_factory(fmt::format("test/data/{}.xml", name)); auto film = new_test_film(name, in); film->set_interop(to == dcp::Standard::INTEROP); diff --git a/test/test.cc b/test/test.cc index 553c4587a..124c43ba5 100644 --- a/test/test.cc +++ b/test/test.cc @@ -25,7 +25,6 @@ */ -#include "lib/compose.hpp" #include "lib/config.h" #include "lib/cross.h" #include "lib/dcp_content_type.h" @@ -61,6 +60,7 @@ extern "C" { #include <libavformat/avformat.h> } +#include <fmt/format.h> #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE dcpomatic_test #include <boost/algorithm/string.hpp> @@ -594,7 +594,7 @@ check_xml( auto test_children = test->get_children (); string context; if (ref_file && test_file) { - context = String::compose(" comparing %1 and %2", ref_file->string(), test_file->string()); + context = fmt::format(" comparing {} and {}", ref_file->string(), test_file->string()); } BOOST_REQUIRE_MESSAGE ( ref_children.size() == test_children.size(), @@ -739,7 +739,7 @@ png_flush (png_structp) static void png_error_fn (png_structp, char const * message) { - throw EncodeError (String::compose("Error during PNG write: %1", message)); + throw EncodeError(fmt::format("Error during PNG write: {}", message)); } @@ -822,7 +822,7 @@ write_image (shared_ptr<const Image> image, boost::filesystem::path file) void check_ffmpeg (boost::filesystem::path ref, boost::filesystem::path check, int audio_tolerance) { - int const r = system (String::compose("ffcmp -t %1 %2 %3", audio_tolerance, ref.string(), check.string()).c_str()); + int const r = system(fmt::format("ffcmp -t {} {} {}", audio_tolerance, ref.string(), check.string()).c_str()); BOOST_REQUIRE_EQUAL (WEXITSTATUS(r), 0); } @@ -1015,13 +1015,13 @@ make_and_verify_dcp(shared_ptr<Film> film, vector<dcp::VerificationNote::Code> i auto dcp_inspect_env = getenv("DCPOMATIC_DCP_INSPECT"); if (dcp_inspect && dcp_inspect_env) { boost::filesystem::path dcp_inspect(dcp_inspect_env); - auto cmd = String::compose("%1 %2 > %3 2>&1", dcp_inspect, film->dir(film->dcp_name()), film->file("dcp_inspect.log")); + auto cmd = fmt::format("{} {} > {} 2>&1", dcp_inspect.string(), film->dir(film->dcp_name()).string(), film->file("dcp_inspect.log").string()); auto result = system(cmd.c_str()); BOOST_CHECK_EQUAL(WEXITSTATUS(result), 0); } if (clairmeta && getenv("DCPOMATIC_CLAIRMETA")) { - auto cmd = String::compose("python3 -m clairmeta.cli check -type dcp %1 > %2 2>&1", film->dir(film->dcp_name()), film->file("clairmeta.log")); + auto cmd = fmt::format("python3 -m clairmeta.cli check -type dcp {} > {} 2>&1", film->dir(film->dcp_name()).string(), film->file("clairmeta.log").string()); auto result = system(cmd.c_str()); BOOST_CHECK_EQUAL(WEXITSTATUS(result), 0); } diff --git a/test/threed_test.cc b/test/threed_test.cc index 5508eb735..6e666bcf6 100644 --- a/test/threed_test.cc +++ b/test/threed_test.cc @@ -44,6 +44,7 @@ #include "test.h" #include <dcp/mono_j2k_picture_asset.h> #include <dcp/stereo_j2k_picture_asset.h> +#include <fmt/format.h> #include <boost/test/unit_test.hpp> #include <iostream> @@ -209,7 +210,7 @@ BOOST_AUTO_TEST_CASE (threed_test7) } } BOOST_REQUIRE (failed); - BOOST_CHECK_EQUAL (failed->error_summary(), String::compose("The content file %1 is set as 3D but does not appear to contain 3D images. Please set it to 2D. You can still make a 3D DCP from this content by ticking the 3D option in the DCP video tab.", boost::filesystem::canonical(content_path).string())); + BOOST_CHECK_EQUAL (failed->error_summary(), fmt::format("The content file {} is set as 3D but does not appear to contain 3D images. Please set it to 2D. You can still make a 3D DCP from this content by ticking the 3D option in the DCP video tab.", boost::filesystem::canonical(content_path).string())); while (signal_manager->ui_idle ()) {} |
