diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-12-23 21:53:32 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-12-26 00:27:08 +0100 |
| commit | 8caf013a9b8d709ed7c3d5e9febee0067e6fcf1f (patch) | |
| tree | 40da87cb357e8b1c54a1464bdbac2d014640e30c | |
| parent | cec6ff92aef45c687085ecfc1059004407c18c57 (diff) | |
Replace String::compose with fmt::format().
143 files changed, 808 insertions, 1206 deletions
diff --git a/src/lib/analytics.cc b/src/lib/analytics.cc index b3c44202a..efb737a8e 100644 --- a/src/lib/analytics.cc +++ b/src/lib/analytics.cc @@ -20,7 +20,6 @@ #include "analytics.h" -#include "compose.hpp" #include "exceptions.h" #include "variant.h" #include <dcp/filesystem.h> @@ -61,18 +60,18 @@ Analytics::successful_dcp_encode () boost::bind( boost::ref(Message), _("Congratulations!"), - String::compose(_( - "<h2>You have made %1 DCPs with %2!</h2>" + fmt::format(_( + "<h2>You have made {} DCPs with {}!</h2>" "<img width=\"20%%\" src=\"memory:me.jpg\" align=\"center\">" "<font size=\"+1\">" "<p>Hello. I'm Carl and I'm the " - "developer of %3. I work on it in my spare time (with the help " + "developer of {}. I work on it in my spare time (with the help " "of a fine volunteer team of testers and translators) and I release it " "as free software." - "<p>If you find %4 useful, please consider a donation to the " + "<p>If you find {} useful, please consider a donation to the " "project. Financial support will help me to spend more " - "time developing %5 and making it better!" + "time developing {} and making it better!" "<p><ul>" "<li><a href=\"https://dcpomatic.com/donate_amount?amount=40\">Go to Paypal to donate €40</a>" diff --git a/src/lib/atmos_mxf_content.cc b/src/lib/atmos_mxf_content.cc index 6b2a64d68..dffebd9b0 100644 --- a/src/lib/atmos_mxf_content.cc +++ b/src/lib/atmos_mxf_content.cc @@ -21,12 +21,12 @@ #include "atmos_content.h" #include "atmos_mxf_content.h" -#include "compose.hpp" #include "film.h" #include "job.h" #include <asdcp/KM_log.h> #include <dcp/atmos_asset.h> #include <dcp/exceptions.h> +#include <fmt/format.h> #include <libxml++/libxml++.h> #include "i18n.h" @@ -93,7 +93,7 @@ AtmosMXFContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job) string AtmosMXFContent::summary () const { - return String::compose (_("%1 [Atmos]"), path_summary()); + return fmt::format(_("{} [Atmos]"), path_summary()); } diff --git a/src/lib/audio_analyser.cc b/src/lib/audio_analyser.cc index 6e7b9fa86..7d4ee6ace 100644 --- a/src/lib/audio_analyser.cc +++ b/src/lib/audio_analyser.cc @@ -135,7 +135,7 @@ AudioAnalyser::AudioAnalyser(shared_ptr<const Film> film, shared_ptr<const Playl void AudioAnalyser::analyse (shared_ptr<AudioBuffers> b, DCPTime time) { - LOG_DEBUG_AUDIO_ANALYSIS("AudioAnalyser received %1 frames at %2", b->frames(), to_string(time)); + LOG_DEBUG_AUDIO_ANALYSIS("AudioAnalyser received {} frames at {}", b->frames(), to_string(time)); DCPOMATIC_ASSERT (time >= _start); /* In bug #2364 we had a lot of frames arriving here (~47s worth) which * caused an OOM error on Windows. Check for the number of frames being diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index bda0230ca..20024b0ec 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -20,7 +20,6 @@ #include "audio_content.h" -#include "compose.hpp" #include "config.h" #include "constants.h" #include "exceptions.h" @@ -153,7 +152,7 @@ AudioContent::technical_summary () const { string s = "audio: "; for (auto i: streams()) { - s += String::compose ("stream channels %1 rate %2 ", i->channels(), i->frame_rate()); + s += fmt::format("stream channels {} rate {} ", i->channels(), i->frame_rate()); } return s; @@ -266,14 +265,14 @@ AudioContent::processing_description (shared_ptr<const Film> film) const } if (not_resampled && resampled) { - return String::compose (_("Some audio will be resampled to %1Hz"), resampled_frame_rate(film)); + return fmt::format(_("Some audio will be resampled to {}Hz"), resampled_frame_rate(film)); } if (!not_resampled && resampled) { if (same) { - return String::compose (_("Audio will be resampled from %1Hz to %2Hz"), common_frame_rate.get(), resampled_frame_rate(film)); + return fmt::format(_("Audio will be resampled from {}Hz to {}Hz"), common_frame_rate.get(), resampled_frame_rate(film)); } else { - return String::compose (_("Audio will be resampled to %1Hz"), resampled_frame_rate(film)); + return fmt::format(_("Audio will be resampled to {}Hz"), resampled_frame_rate(film)); } } @@ -291,7 +290,7 @@ AudioContent::channel_names () const int stream = 1; for (auto i: streams()) { for (int j = 0; j < i->channels(); ++j) { - n.push_back (NamedChannel(String::compose ("%1:%2", stream, j + 1), index++)); + n.push_back (NamedChannel(fmt::format("{}:{}", stream, j + 1), index++)); } ++stream; } diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index 60b0f07ad..9dd57f32a 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" @@ -84,7 +83,7 @@ AudioDecoder::emit(shared_ptr<const Film> film, AudioStreamPtr stream, shared_pt if (need_reset) { LOG_GENERAL ( - "Reset audio position: was %1, new data at %2, slack: %3 frames (more than threshold %4)", + "Reset audio position: was {}, new data at {}, slack: {} frames (more than threshold {})", _positions[stream], time.frames_round(resampled_rate), std::abs(_positions[stream] - time.frames_round(resampled_rate)), @@ -107,7 +106,7 @@ AudioDecoder::emit(shared_ptr<const Film> film, AudioStreamPtr stream, shared_pt } else { if (stream->frame_rate() != resampled_rate) { LOG_GENERAL ( - "Creating new resampler from %1 to %2 with %3 channels", + "Creating new resampler from {} to {} with {} channels", stream->frame_rate(), resampled_rate, stream->channels() @@ -128,7 +127,7 @@ AudioDecoder::emit(shared_ptr<const Film> film, AudioStreamPtr stream, shared_pt * here. */ if (resampler->channels() != data->channels()) { - LOG_WARNING("Received audio data with an unexpected channel count of %1 instead of %2", data->channels(), resampler->channels()); + LOG_WARNING("Received audio data with an unexpected channel count of {} instead of {}", data->channels(), resampler->channels()); auto data_copy = data->clone(); data_copy->set_channels(resampler->channels()); data = resampler->run(data_copy); diff --git a/src/lib/audio_filter_graph.cc b/src/lib/audio_filter_graph.cc index 55a26cdb2..7f7e87888 100644 --- a/src/lib/audio_filter_graph.cc +++ b/src/lib/audio_filter_graph.cc @@ -21,7 +21,6 @@ #include "audio_buffers.h" #include "audio_filter_graph.h" -#include "compose.hpp" #include "dcpomatic_assert.h" #include "exceptions.h" extern "C" { @@ -30,6 +29,7 @@ extern "C" { #include <libavutil/channel_layout.h> #include <libavutil/opt.h> } +#include <fmt/format.h> #include <iostream> #include "i18n.h" @@ -154,7 +154,7 @@ AudioFilterGraph::process (shared_ptr<AudioBuffers> buffers) if (r < 0) { char buffer[256]; av_strerror (r, buffer, sizeof(buffer)); - throw DecodeError (String::compose (N_("could not push buffer into filter chain (%1)"), &buffer[0])); + throw DecodeError(fmt::format(N_("could not push buffer into filter chain ({})"), &buffer[0])); } while (true) { diff --git a/src/lib/butler.cc b/src/lib/butler.cc index dd9874587..a684ec77c 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" @@ -105,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 (&boost::asio::io_service::run, &_prepare_service)); @@ -141,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())); } } @@ -153,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) { @@ -325,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) @@ -473,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 41b9dbab3..e6ec6b34f 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> @@ -153,7 +154,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 8de1857ab..08d5bb2ae 100644 --- a/src/lib/collator.cc +++ b/src/lib/collator.cc @@ -27,6 +27,7 @@ #include <unicode/utypes.h> #include <unicode/usearch.h> #include <unicode/ustring.h> +#include <boost/algorithm/string.hpp> #include <boost/scoped_array.hpp> #include <cstring> #include <vector> diff --git a/src/lib/combine_dcp_job.cc b/src/lib/combine_dcp_job.cc index 5c299492b..5afcb04b4 100644 --- a/src/lib/combine_dcp_job.cc +++ b/src/lib/combine_dcp_job.cc @@ -20,10 +20,10 @@ #include "combine_dcp_job.h" -#include "compose.hpp" #include "config.h" #include <dcp/combine.h> #include <dcp/exceptions.h> +#include <fmt/format.h> #include "i18n.h" @@ -64,8 +64,8 @@ CombineDCPJob::run () dcp::combine ( _inputs, _output, - String::compose("libdcp %1", dcp::version), - String::compose("libdcp %1", dcp::version), + fmt::format("libdcp {}", dcp::version), + fmt::format("libdcp {}", dcp::version), dcp::LocalTime().as_string(), _annotation_text, Config::instance()->signer_chain() diff --git a/src/lib/compose.hpp b/src/lib/compose.hpp deleted file mode 100644 index 479493f14..000000000 --- a/src/lib/compose.hpp +++ /dev/null @@ -1,392 +0,0 @@ -/* -*- c-basic-offset: 2 -*- - * Defines String::compose(fmt, arg...) for easy, i18n-friendly - * composition of strings. - * - * Version 1.0. - * - * Copyright (c) 2002 Ole Laursen <olau@hardworking.dk>. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - -// -// Basic usage is like -// -// std::cout << String::compose("This is a %1x%2 matrix.", rows, cols); -// -// See http://www.cs.aau.dk/~olau/compose/ or the included README.compose for -// more details. -// - -#ifndef DCPOMATIC_STRING_COMPOSE_H -#define DCPOMATIC_STRING_COMPOSE_H - -#include <dcp/locale_convert.h> -#include <boost/filesystem.hpp> -#include <string> -#include <list> -#include <map> -#include <inttypes.h> -#include <cstdio> - -namespace StringPrivate -{ - // the actual composition class - using string::compose is cleaner, so we - // hide it here - class Composition - { - public: - // initialize and prepare format string on the form "text %1 text %2 etc." - explicit Composition(std::string fmt); - - // supply an replacement argument starting from %1 - template <typename T> - Composition &arg(const T &obj); - - // compose and return string - std::string str() const; - - private: - std::string os; - int arg_no; - - // we store the output as a list - when the output string is requested, the - // list is concatenated to a string; this way we can keep iterators into - // the list instead of into a string where they're possibly invalidated on - // inserting a specification string - typedef std::list<std::string> output_list; - output_list output; - - // the initial parse of the format string fills in the specification map - // with positions for each of the various %?s - typedef std::multimap<int, output_list::iterator> specification_map; - specification_map specs; - }; - - // helper for converting spec string numbers - inline int char_to_int(char c) - { - switch (c) { - case '0': return 0; - case '1': return 1; - case '2': return 2; - case '3': return 3; - case '4': return 4; - case '5': return 5; - case '6': return 6; - case '7': return 7; - case '8': return 8; - case '9': return 9; - default: return -1000; - } - } - - inline bool is_number(int n) - { - switch (n) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return true; - - default: - return false; - } - } - - // implementation of class Composition - template <typename T> - inline Composition &Composition::arg(const T &obj) - { - os += dcp::locale_convert<std::string>(obj); - - if (!os.empty()) { // manipulators don't produce output - for (specification_map::const_iterator i = specs.lower_bound(arg_no), end = specs.upper_bound(arg_no); i != end; ++i) { - output_list::iterator pos = i->second; - ++pos; - - output.insert(pos, os); - } - - os = ""; - ++arg_no; - } - - return *this; - } - - inline Composition::Composition(std::string fmt) - : arg_no(1) - { - std::string::size_type b = 0, i = 0; - - // fill in output with the strings between the %1 %2 %3 etc. and - // fill in specs with the positions - while (i < fmt.length()) { - if (fmt[i] == '%' && i + 1 < fmt.length()) { - if (fmt[i + 1] == '%') { // catch %% - fmt.replace(i, 2, "%"); - ++i; - } - else if (is_number(fmt[i + 1])) { // aha! a spec! - // save string - output.push_back(fmt.substr(b, i - b)); - - int n = 1; // number of digits - int spec_no = 0; - - do { - spec_no += char_to_int(fmt[i + n]); - spec_no *= 10; - ++n; - } while (i + n < fmt.length() && is_number(fmt[i + n])); - - spec_no /= 10; - output_list::iterator pos = output.end(); - --pos; // safe since we have just inserted a string> - - specs.insert(specification_map::value_type(spec_no, pos)); - - // jump over spec string - i += n; - b = i; - } - else - ++i; - } - else - ++i; - } - - if (i - b > 0) // add the rest of the string - output.push_back(fmt.substr(b, i - b)); - } - - inline std::string Composition::str() const - { - // assemble string - std::string str; - - for (output_list::const_iterator i = output.begin(), end = output.end(); - i != end; ++i) - str += *i; - - return str; - } -} - -// now for the real thing(s) -namespace String -{ - // a series of functions which accept a format string on the form "text %1 - // more %2 less %3" and a number of templated parameters and spits out the - // composited string - template <typename T1> - inline std::string compose(const std::string &fmt, const T1 &o1) - { - StringPrivate::Composition c(fmt); - c.arg(o1); - return c.str(); - } - - template <typename T1, typename T2> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2); - return c.str(); - } - - template <typename T1, typename T2, typename T3> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9, - const T10 &o10) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) - .arg(o10); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10, - typename T11> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9, - const T10 &o10, const T11 &o11) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) - .arg(o10).arg(o11); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10, - typename T11, typename T12> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9, - const T10 &o10, const T11 &o11, const T12 &o12) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) - .arg(o10).arg(o11).arg(o12); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10, - typename T11, typename T12, typename T13> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9, - const T10 &o10, const T11 &o11, const T12 &o12, - const T13 &o13) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) - .arg(o10).arg(o11).arg(o12).arg(o13); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10, - typename T11, typename T12, typename T13, typename T14> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9, - const T10 &o10, const T11 &o11, const T12 &o12, - const T13 &o13, const T14 &o14) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) - .arg(o10).arg(o11).arg(o12).arg(o13).arg(o14); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10, - typename T11, typename T12, typename T13, typename T14, - typename T15> - inline std::string compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9, - const T10 &o10, const T11 &o11, const T12 &o12, - const T13 &o13, const T14 &o14, const T15 &o15) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) - .arg(o10).arg(o11).arg(o12).arg(o13).arg(o14).arg(o15); - return c.str(); - } -} - - -#endif // STRING_COMPOSE_H diff --git a/src/lib/config.cc b/src/lib/config.cc index 1c6e50a28..e4b01b872 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" @@ -41,6 +40,7 @@ #include <libcxml/cxml.h> #include <glib.h> #include <libxml++/libxml++.h> +#include <fmt/format.h> #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> #include <boost/thread.hpp> @@ -273,7 +273,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; @@ -435,7 +435,7 @@ try _kdm_bcc = f.optional_string_child ("KDMBCC").get_value_or (""); _kdm_email = f.string_child ("KDMEmail"); - _notification_subject = f.optional_string_child("NotificationSubject").get_value_or(variant::insert_dcpomatic(_("%1 notification"))); + _notification_subject = f.optional_string_child("NotificationSubject").get_value_or(variant::insert_dcpomatic(_("{} notification"))); _notification_from = f.optional_string_child("NotificationFrom").get_value_or(""); _notification_to = f.optional_string_child("NotificationTo").get_value_or(""); for (auto i: f.node_children("NotificationCC")) { @@ -1244,14 +1244,14 @@ Config::set_kdm_email_to_default () "Cinema: $CINEMA_NAME\n" "Screen(s): $SCREENS\n\n" "The KDMs are valid from $START_TIME until $END_TIME.\n\n" - "Best regards,\n%1" + "Best regards,\n{}" )); } void Config::set_notification_email_to_default () { - _notification_subject = variant::insert_dcpomatic(_("%1 notification")); + _notification_subject = variant::insert_dcpomatic(_("{} notification")); _notification_email = _( "$JOB_NAME: $JOB_STATUS" diff --git a/src/lib/content.cc b/src/lib/content.cc index 5c44cb47a..0abb061c8 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" @@ -309,9 +308,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; } @@ -478,7 +477,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 5d36c2aea..012aa2fb4 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -38,7 +38,6 @@ #include "log_entry.h" #include "dcpomatic_log.h" #include "log.h" -#include "compose.hpp" #include <libcxml/cxml.h> #include <dcp/filesystem.h> #include <dcp/smpte_text_asset.h> @@ -114,7 +113,7 @@ content_factory (boost::filesystem::path path) if (dcp::filesystem::is_directory(path)) { - LOG_GENERAL ("Look in directory %1", path); + LOG_GENERAL("Look in directory {}", path.string()); if (dcp::filesystem::is_empty(path)) { return content; @@ -127,17 +126,17 @@ content_factory (boost::filesystem::path path) int read = 0; for (dcp::filesystem::directory_iterator i(path); i != dcp::filesystem::directory_iterator() && read < 10; ++i) { - LOG_GENERAL ("Checking file %1", i->path()); + LOG_GENERAL("Checking file {}", i->path().string()); if (boost::starts_with(i->path().filename().string(), ".")) { /* We ignore hidden files */ - LOG_GENERAL ("Ignored %1 (starts with .)", i->path()); + LOG_GENERAL("Ignored {} (starts with .)", i->path().string()); continue; } if (!dcp::filesystem::is_regular_file(i->path())) { /* Ignore things which aren't files (probably directories) */ - LOG_GENERAL ("Ignored %1 (not a regular file)", i->path()); + LOG_GENERAL("Ignored {} (not a regular file)", i->path().string()); continue; } diff --git a/src/lib/copy_to_drive_job.cc b/src/lib/copy_to_drive_job.cc index 4ed9421d6..b04c273ee 100644 --- a/src/lib/copy_to_drive_job.cc +++ b/src/lib/copy_to_drive_job.cc @@ -19,12 +19,12 @@ */ -#include "compose.hpp" #include "copy_to_drive_job.h" #include "dcpomatic_log.h" #include "disk_writer_messages.h" #include "exceptions.h" #include <nanomsg/nn.h> +#include <fmt/format.h> #include <fcntl.h> #include <unistd.h> #include <iostream> @@ -56,10 +56,10 @@ string CopyToDriveJob::name () const { if (_dcps.size() == 1) { - return String::compose(_("Copying %1\nto %2"), _dcps[0].filename().string(), _drive.description()); + return fmt::format(_("Copying {}\nto {}"), _dcps[0].filename().string(), _drive.description()); } - return String::compose(_("Copying DCPs to %1"), _drive.description()); + return fmt::format(_("Copying DCPs to {}"), _drive.description()); } @@ -72,14 +72,14 @@ CopyToDriveJob::json_name () const void CopyToDriveJob::run () { - LOG_DISK("Sending write requests to disk %1 for:", _drive.device()); + LOG_DISK("Sending write requests to disk {} for:", _drive.device()); for (auto dcp: _dcps) { - LOG_DISK("%1", dcp.string()); + LOG_DISK("{}", 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/cpu_j2k_encoder_thread.cc b/src/lib/cpu_j2k_encoder_thread.cc index 580facae9..6ff38e5da 100644 --- a/src/lib/cpu_j2k_encoder_thread.cc +++ b/src/lib/cpu_j2k_encoder_thread.cc @@ -44,7 +44,7 @@ void CPUJ2KEncoderThread::log_thread_start() const { start_of_thread("CPUJ2KEncoder"); - LOG_TIMING("start-encoder-thread thread=%1 server=localhost", thread_id()); + LOG_TIMING("start-encoder-thread thread={} server=localhost", thread_id()); } @@ -54,7 +54,7 @@ CPUJ2KEncoderThread::encode(DCPVideo const& frame) try { return make_shared<dcp::ArrayData>(frame.encode_locally()); } catch (std::exception& e) { - LOG_ERROR(N_("Local encode failed (%1)"), e.what()); + LOG_ERROR(N_("Local encode failed ({})"), e.what()); } return {}; diff --git a/src/lib/create_cli.cc b/src/lib/create_cli.cc index 3fb978f7c..a007fe078 100644 --- a/src/lib/create_cli.cc +++ b/src/lib/create_cli.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "config.h" #include "create_cli.h" #include "dcp_content_type.h" @@ -28,6 +27,7 @@ #include "ratio.h" #include "variant.h" #include <dcp/raw_convert.h> +#include <fmt/format.h> #include <iostream> #include <string> @@ -41,8 +41,8 @@ using boost::optional; string CreateCLI::_help = - string("\nSyntax: %1 [OPTION] <CONTENT> [OPTION] [<CONTENT> ...]\n") + - variant::insert_dcpomatic(" -v, --version show %1 version\n") + + 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" @@ -79,7 +79,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; } @@ -108,14 +108,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; } @@ -151,7 +151,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; } @@ -246,7 +246,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 { Content c; @@ -281,7 +281,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; } } @@ -289,7 +289,7 @@ CreateCLI::CreateCLI (int argc, char* argv[]) if (!container_ratio_string.empty()) { _container_ratio = Ratio::from_id (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; } } @@ -300,21 +300,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; } @@ -323,7 +323,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_common.cc b/src/lib/cross_common.cc index 2e6f5c414..1aabef75e 100644 --- a/src/lib/cross_common.cc +++ b/src/lib/cross_common.cc @@ -20,7 +20,6 @@ #include "cross.h" -#include "compose.hpp" #include "dcpomatic_assert.h" #include "dcpomatic_log.h" #include <dcp/warnings.h> @@ -96,7 +95,7 @@ Drive::description () const name = _("Unknown"); } - return String::compose(_("%1 (%2 GB) [%3]"), name, gb, _device); + return fmt::format(_("{} ({} GB) [{}]"), name, gb, _device); } @@ -113,8 +112,8 @@ Drive::log_summary () const mp = mp.substr (0, mp.length() - 1); } - return String::compose( - "Device %1 mounted on %2 size %3 vendor %4 model %5", + return fmt::format( + "Device {} mounted on {} size {} vendor {} model {}", _device, mp, _size, _vendor.get_value_or("[none]"), _model.get_value_or("[none]") ); } diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc index be3233b32..b27d1a636 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" @@ -30,6 +29,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> @@ -108,11 +108,11 @@ 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()); - LOG_GENERAL (N_("Probing with %1"), ffprobe); + auto const ffprobe = fmt::format("ffprobe {} \"{}\" {} \"{}\"", args.empty() ? " " : args, content.string(), redirect, out.string()); + LOG_GENERAL (N_("Probing with {}"), ffprobe); int const r = system (ffprobe.c_str()); if (r == -1 || (WIFEXITED(r) && WEXITSTATUS(r) != 0)) { - LOG_GENERAL (N_("Could not run ffprobe (system returned %1"), r); + LOG_GENERAL (N_("Could not run ffprobe (system returned {}"), r); } } @@ -237,7 +237,7 @@ get_mounts (string prefix) if (bits.size() > 1 && boost::algorithm::starts_with(bits[0], prefix)) { boost::algorithm::replace_all (bits[1], "\\040", " "); mounts.push_back(make_pair(bits[0], bits[1])); - LOG_DISK("Found mounted device %1 from prefix %2", bits[0], prefix); + LOG_DISK("Found mounted device {} from prefix {}", bits[0], prefix); } } @@ -297,7 +297,7 @@ Drive::unmount () { for (auto i: _mount_points) { int const r = umount(i.string().c_str()); - LOG_DISK("Tried to unmount %1 and got %2 and %3", i.string(), r, errno); + LOG_DISK("Tried to unmount {} and got {} and {}", i.string(), r, errno); if (r == -1) { return false; } @@ -330,12 +330,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/cross_osx.cc b/src/lib/cross_osx.cc index a201cc5f9..3d2407c89 100644 --- a/src/lib/cross_osx.cc +++ b/src/lib/cross_osx.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "config.h" #include "cross.h" #include "dcpomatic_log.h" @@ -28,6 +27,7 @@ #include "variant.h" #include <dcp/filesystem.h> #include <glib.h> +#include <fmt/format.h> #include <boost/algorithm/string.hpp> #include <boost/regex.hpp> #if BOOST_VERSION >= 106100 @@ -113,8 +113,8 @@ run_ffprobe(boost::filesystem::path content, boost::filesystem::path out, bool e } string const redirect = err ? "2>" : ">"; - auto const ffprobe = String::compose("\"%1\" %2 \"%3\" %4 \"%5\"", path, args.empty() ? " " : args, content.string(), redirect, out.string()); - LOG_GENERAL (N_("Probing with %1"), ffprobe); + auto const ffprobe = fmt::format("\"{}\" {} \"{}\" {} \"{}\"", path, args.empty() ? " " : args, content.string(), redirect, out.string()); + LOG_GENERAL(N_("Probing with {}"), ffprobe); system (ffprobe.c_str()); } @@ -181,7 +181,7 @@ start_tool (string executable, string app) pid_t pid = fork (); if (pid == 0) { - LOG_GENERAL ("start_tool %1 %2 with path %3", executable, app, exe_path.string()); + LOG_GENERAL("start_tool {} {} with path {}", executable, app, exe_path.string()); int const r = system (exe_path.string().c_str()); exit (WEXITSTATUS (r)); } else if (pid == -1) { @@ -278,18 +278,18 @@ disk_appeared (DADiskRef disk, void* context) LOG_DISK_NC("Disk with no BSDName appeared"); return; } - LOG_DISK("%1 appeared", bsd_name); + LOG_DISK("{} appeared", bsd_name); OSXDisk this_disk; this_disk.device = string("/dev/") + bsd_name; - LOG_DISK("Device is %1", this_disk.device); + LOG_DISK("Device is {}", this_disk.device); CFDictionaryRef description = DADiskCopyDescription (disk); this_disk.vendor = get_vendor (description); this_disk.model = get_model (description); - LOG_DISK("Vendor/model: %1 %2", this_disk.vendor.get_value_or("[none]"), this_disk.model.get_value_or("[none]")); + LOG_DISK("Vendor/model: {} {}", this_disk.vendor.get_value_or("[none]"), this_disk.model.get_value_or("[none]")); auto mp = mount_point (description); if (mp) { @@ -307,7 +307,7 @@ disk_appeared (DADiskRef disk, void* context) this_disk.partition = string(bsd_name).find("s", 5) != std::string::npos; LOG_DISK( - "%1 %2 %3 %4 mounted at %5", + "{} {} {} {} mounted at {}", bsd_name, this_disk.system ? "system" : "non-system", this_disk.writeable ? "writeable" : "read-only", @@ -352,9 +352,9 @@ Drive::get () } } - LOG_DISK("Drive::get() found %1 drives:", drives.size()); + LOG_DISK("Drive::get() found {} drives:", drives.size()); for (auto const& drive: drives) { - LOG_DISK("%1 %2 mounted=%3", drive.description(), drive.device(), drive.mounted() ? "yes" : "no"); + LOG_DISK("{} {} mounted={}", drive.description(), drive.device(), drive.mounted() ? "yes" : "no"); } return drives; @@ -390,7 +390,7 @@ void done_callback(DADiskRef, DADissenterRef dissenter, void* context) auto state = reinterpret_cast<UnmountState*>(context); state->callback = true; if (dissenter) { - LOG_DISK("Error: %1", DADissenterGetStatus(dissenter)); + LOG_DISK("Error: {}", DADissenterGetStatus(dissenter)); } else { LOG_DISK_NC("Successful"); state->success = true; @@ -412,7 +412,7 @@ Drive::unmount () if (!disk) { return false; } - LOG_DISK("Requesting unmount of %1 from %2", _device, thread_id()); + LOG_DISK("Requesting unmount of {} from {}", _device, thread_id()); UnmountState state; DADiskUnmount(disk, kDADiskUnmountOptionWhole, &done_callback, &state); CFRelease (disk); @@ -426,7 +426,7 @@ Drive::unmount () if (!state.callback) { LOG_DISK_NC("End of unmount: timeout"); } else { - LOG_DISK("End of unmount: %1", state.success ? "success" : "failure"); + LOG_DISK("End of unmount: {}", state.success ? "success" : "failure"); } return state.success; } @@ -453,7 +453,7 @@ LIBDCP_ENABLE_WARNINGS bool show_in_file_manager (boost::filesystem::path, boost::filesystem::path select) { - int r = system (String::compose("open -R \"%1\"", select.string()).c_str()); + int r = system(fmt::format("open -R \"{}\"", select.string()).c_str()); return static_cast<bool>(WEXITSTATUS(r)); } diff --git a/src/lib/cross_windows.cc b/src/lib/cross_windows.cc index 56ff73ec9..d4b8fe461 100644 --- a/src/lib/cross_windows.cc +++ b/src/lib/cross_windows.cc @@ -22,7 +22,6 @@ #define UNICODE 1 #include "cross.h" -#include "compose.hpp" #include "log.h" #include "dcpomatic_log.h" #include "config.h" @@ -404,7 +403,7 @@ get_device_number (HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data) auto r = SetupDiEnumDeviceInterfaces (device_info, device_info_data, &GUID_DEVICE_INTERFACE_DISK, 0, &device_interface_data); if (!r) { - LOG_DISK("SetupDiEnumDeviceInterfaces failed (%1)", GetLastError()); + LOG_DISK("SetupDiEnumDeviceInterfaces failed ({})", GetLastError()); return optional<int>(); } @@ -439,7 +438,7 @@ get_device_number (HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data) free (device_detail_data); if (device == INVALID_HANDLE_VALUE) { - LOG_DISK("CreateFileW failed with %1", GetLastError()); + LOG_DISK("CreateFileW failed with {}", GetLastError()); return optional<int>(); } @@ -469,7 +468,7 @@ typedef map<int, vector<boost::filesystem::path>> MountPoints; static void add_volume_mount_points (wchar_t* volume, MountPoints& mount_points) { - LOG_DISK("Looking at %1", wchar_to_utf8(volume)); + LOG_DISK("Looking at {}", wchar_to_utf8(volume)); wchar_t volume_path_names[512]; vector<boost::filesystem::path> mp; @@ -478,7 +477,7 @@ add_volume_mount_points (wchar_t* volume, MountPoints& mount_points) wchar_t* p = volume_path_names; while (*p != L'\0') { mp.push_back (wchar_to_utf8(p)); - LOG_DISK ("Found mount point %1", wchar_to_utf8(p)); + LOG_DISK ("Found mount point {}", wchar_to_utf8(p)); p += wcslen(p) + 1; } } @@ -555,7 +554,7 @@ Drive::get () if (!SetupDiEnumDeviceInfo(device_info, i, &device_info_data)) { DWORD e = GetLastError(); if (e != ERROR_NO_MORE_ITEMS) { - LOG_DISK ("SetupDiEnumDeviceInfo failed (%1)", GetLastError()); + LOG_DISK ("SetupDiEnumDeviceInfo failed ({})", GetLastError()); } break; } @@ -567,7 +566,7 @@ Drive::get () continue; } - string const physical_drive = String::compose("\\\\.\\PHYSICALDRIVE%1", *device_number); + string const physical_drive = fmt::format("\\\\.\\PHYSICALDRIVE{}", *device_number); HANDLE device = CreateFileA ( physical_drive.c_str(), 0, @@ -587,7 +586,7 @@ Drive::get () &geom, sizeof(geom), &returned, 0 ); - LOG_DISK("Having a look through %1 locked volumes", locked_volumes.size()); + LOG_DISK("Having a look through {} locked volumes", locked_volumes.size()); bool locked = false; for (auto const& i: locked_volumes) { if (i.second == physical_drive) { @@ -598,7 +597,7 @@ Drive::get () if (r) { uint64_t const disk_size = geom.Cylinders.QuadPart * geom.TracksPerCylinder * geom.SectorsPerTrack * geom.BytesPerSector; drives.push_back (Drive(physical_drive, locked ? vector<boost::filesystem::path>() : mount_points[*device_number], disk_size, friendly_name, optional<string>())); - LOG_DISK("Added drive %1%2", drives.back().log_summary(), locked ? "(locked by us)" : ""); + LOG_DISK("Added drive {}{}", drives.back().log_summary(), locked ? "(locked by us)" : ""); } CloseHandle (device); @@ -611,24 +610,24 @@ Drive::get () bool Drive::unmount () { - LOG_DISK("Unmounting %1 with %2 mount points", _device, _mount_points.size()); + LOG_DISK("Unmounting {} with {} mount points", _device, _mount_points.size()); DCPOMATIC_ASSERT (_mount_points.size() == 1); - string const device_name = String::compose ("\\\\.\\%1", _mount_points.front()); - string const truncated = device_name.substr (0, device_name.length() - 1); - LOG_DISK("Actually opening %1", truncated); + auto const device_name = fmt::format("\\\\.\\{}", _mount_points.front()); + auto const truncated = device_name.substr(0, device_name.length() - 1); + LOG_DISK("Actually opening {}", truncated); HANDLE device = CreateFileA (truncated.c_str(), (GENERIC_READ | GENERIC_WRITE), FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); if (device == INVALID_HANDLE_VALUE) { - LOG_DISK("Could not open %1 for unmount (%2)", truncated, GetLastError()); + LOG_DISK("Could not open {} for unmount ({})", truncated, GetLastError()); return false; } DWORD returned; BOOL r = DeviceIoControl (device, FSCTL_LOCK_VOLUME, 0, 0, 0, 0, &returned, 0); if (!r) { - LOG_DISK("Unmount of %1 failed (%2)", truncated, GetLastError()); + LOG_DISK("Unmount of {} failed ({})", truncated, GetLastError()); return false; } - LOG_DISK("Unmount of %1 succeeded", _device); + LOG_DISK("Unmount of {} succeeded", _device); locked_volumes.push_back (make_pair(device, _device)); return true; @@ -660,7 +659,7 @@ disk_write_finished () string dcpomatic::get_process_id () { - return dcp::fmt::to_string(GetCurrentProcessId()); + return fmt::to_string(GetCurrentProcessId()); } diff --git a/src/lib/curl_uploader.cc b/src/lib/curl_uploader.cc index 389a5d6de..04a7e9273 100644 --- a/src/lib/curl_uploader.cc +++ b/src/lib/curl_uploader.cc @@ -24,7 +24,6 @@ #include "exceptions.h" #include "config.h" #include "cross.h" -#include "compose.hpp" #include "dcpomatic_assert.h" #include <iostream> @@ -94,12 +93,12 @@ 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"); if (!file) { - throw NetworkError (String::compose (_("Could not open %1 to send"), from)); + throw NetworkError(fmt::format(_("Could not open {} to send"), from.string())); } _file = file.get(); _transferred = &transferred; @@ -107,7 +106,7 @@ CurlUploader::upload_file (boost::filesystem::path from, boost::filesystem::path auto const r = curl_easy_perform (_curl); if (r != CURLE_OK) { - throw NetworkError (String::compose (_("Could not write to remote file (%1)"), curl_easy_strerror (r))); + throw NetworkError(fmt::format(_("Could not write to remote file ({})"), curl_easy_strerror(r))); } _file = nullptr; @@ -133,7 +132,7 @@ int CurlUploader::debug(CURL *, curl_infotype type, char* data, size_t size) { if (type == CURLINFO_TEXT && size > 0) { - LOG_GENERAL("CurlUploader: %1", string(data, size - 1)); + LOG_GENERAL("CurlUploader: {}", string(data, size - 1)); } return 0; } diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 5e30dfc18..1400f8361 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -21,7 +21,6 @@ #include "atmos_content.h" #include "audio_content.h" -#include "compose.hpp" #include "config.h" #include "dcp_content.h" #include "dcp_decoder.h" @@ -84,7 +83,7 @@ DCPContent::DCPContent (boost::filesystem::path p) , _reference_audio (false) , _three_d (false) { - LOG_GENERAL ("Creating DCP content from %1", p.string()); + LOG_GENERAL ("Creating DCP content from {}", p.string()); read_directory (p); set_default_colour_conversion (); @@ -209,21 +208,21 @@ DCPContent::read_sub_directory (boost::filesystem::path p) { using namespace boost::filesystem; - LOG_GENERAL ("DCPContent::read_sub_directory reads %1", p.string()); + LOG_GENERAL ("DCPContent::read_sub_directory reads {}", p.string()); try { for (auto i: directory_iterator(p)) { if (is_regular_file(i.path())) { - LOG_GENERAL ("Inside there's regular file %1", i.path().string()); + LOG_GENERAL ("Inside there's regular file {}", i.path().string()); add_path (i.path()); } else if (is_directory(i.path()) && i.path().filename() != ".AppleDouble") { - LOG_GENERAL ("Inside there's directory %1", i.path().string()); + LOG_GENERAL ("Inside there's directory {}", i.path().string()); read_sub_directory (i.path()); } else { - LOG_GENERAL("Ignoring %1 from inside: status is %2", i.path().string(), static_cast<int>(status(i.path()).type())); + LOG_GENERAL("Ignoring {} from inside: status is {}", i.path().string(), static_cast<int>(status(i.path()).type())); } } } catch (exception& e) { - LOG_GENERAL("Failed to iterate over %1: %2", p.string(), e.what()); + LOG_GENERAL("Failed to iterate over {}: {}", p.string(), e.what()); } } @@ -359,7 +358,7 @@ string DCPContent::summary () const { boost::mutex::scoped_lock lm (_mutex); - return String::compose (_("%1 [DCP]"), _name); + return fmt::format(_("{} [DCP]"), _name); } string @@ -751,7 +750,7 @@ DCPContent::can_reference_audio (shared_ptr<const Film> film, string& why_not) c if (audio && audio->stream()) { auto const channels = audio->stream()->channels(); if (channels != film->audio_channels()) { - why_not = String::compose(_("it has a different number of audio channels than the project; set the project to have %1 channels."), channels); + why_not = fmt::format(_("it has a different number of audio channels than the project; set the project to have {} channels."), channels); return false; } } diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index 3ee6dd99c..8b2d60f8e 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -122,7 +122,7 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant) _name = selected_cpl->content_title_text(); _content_kind = selected_cpl->content_kind(); - LOG_GENERAL ("Selected CPL %1", _cpl); + LOG_GENERAL("Selected CPL {}", _cpl); auto try_to_parse_language = [](optional<string> lang) -> boost::optional<dcp::LanguageTag> { try { @@ -133,11 +133,11 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant) return boost::none; }; - LOG_GENERAL("Looking at %1 reels", selected_cpl->reels().size()); + LOG_GENERAL("Looking at {} reels", selected_cpl->reels().size()); int reel_index = 0; for (auto reel: selected_cpl->reels()) { - LOG_GENERAL("Reel %1", reel->id()); + LOG_GENERAL("Reel {}", reel->id()); if (reel->main_picture()) { /* This will mean a VF can be displayed in the timeline even if its picture asset @@ -147,10 +147,10 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant) _video_length += reel->main_picture()->actual_duration(); if (!reel->main_picture()->asset_ref().resolved()) { - LOG_GENERAL("Main picture %1 of reel %2 is missing", reel->main_picture()->id(), reel->id()); + LOG_GENERAL("Main picture {} of reel {} is missing", reel->main_picture()->id(), reel->id()); _needs_assets = true; } else { - LOG_GENERAL("Main picture %1 of reel %2 found", reel->main_picture()->id(), reel->id()); + LOG_GENERAL("Main picture {} of reel {} found", reel->main_picture()->id(), reel->id()); auto const frac = reel->main_picture()->edit_rate(); float const fr = float(frac.numerator) / frac.denominator; @@ -178,10 +178,10 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant) auto const edit_rate = reel->main_sound()->edit_rate(); if (!reel->main_sound()->asset_ref().resolved()) { - LOG_GENERAL("Main sound %1 of reel %2 is missing", reel->main_sound()->id(), reel->id()); + LOG_GENERAL("Main sound {} of reel {} is missing", reel->main_sound()->id(), reel->id()); _needs_assets = true; } else { - LOG_GENERAL("Main sound %1 of reel %2 found", reel->main_sound()->id(), reel->id()); + LOG_GENERAL("Main sound {} of reel {} found", reel->main_sound()->id(), reel->id()); auto asset = reel->main_sound()->asset(); @@ -213,10 +213,10 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant) _has_non_zero_entry_point[type] = true; } if (!reel_asset->asset_ref().resolved()) { - LOG_GENERAL("Main %1 %2 of reel %3 is missing", name, reel_asset->id(), reel->id()); + LOG_GENERAL("Main {} {} of reel {} is missing", name, reel_asset->id(), reel->id()); _needs_assets = true; } else { - LOG_GENERAL("Main %1 %2 of reel %3 found", name, reel_asset->id(), reel->id()); + LOG_GENERAL("Main {} {} of reel {} found", name, reel_asset->id(), reel->id()); _text_count[type] = 1; language = try_to_parse_language(reel_asset->language()); @@ -255,10 +255,10 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant) _has_non_zero_entry_point[type] = true; } if (!text->asset_ref().resolved()) { - LOG_GENERAL("Closed %1 %2 of reel %3 is missing", name, text->id(), reel->id()); + LOG_GENERAL("Closed {} {} of reel {} is missing", name, text->id(), reel->id()); _needs_assets = true; } else { - LOG_GENERAL("Closed %1 %2 of reel %3 found", name, text->id(), reel->id()); + LOG_GENERAL("Closed {} {} of reel {} found", name, text->id(), reel->id()); auto asset = text->asset(); for (auto const& font: asset->font_data()) { @@ -316,7 +316,7 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant) */ try { for (auto i: selected_cpl->reels()) { - LOG_GENERAL ("Reel %1", i->id()); + LOG_GENERAL("Reel {}", i->id()); if (i->main_picture() && i->main_picture()->asset_ref().resolved()) { auto pic = i->main_picture()->asset(); if (pic->encrypted() && !pic->key()) { @@ -396,10 +396,10 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant) } } catch (dcp::ReadError& e) { _kdm_valid = false; - LOG_GENERAL ("KDM is invalid: %1", e.what()); + LOG_GENERAL("KDM is invalid: {}", e.what()); } catch (dcp::MiscError& e) { _kdm_valid = false; - LOG_GENERAL ("KDM is invalid: %1", e.what()); + LOG_GENERAL("KDM is invalid: {}", e.what()); } _standard = selected_cpl->standard(); diff --git a/src/lib/dcp_subtitle.cc b/src/lib/dcp_subtitle.cc index c2d390b55..f43208b5d 100644 --- a/src/lib/dcp_subtitle.cc +++ b/src/lib/dcp_subtitle.cc @@ -21,9 +21,9 @@ #include "dcp_subtitle.h" #include "exceptions.h" -#include "compose.hpp" #include <dcp/interop_text_asset.h> #include <dcp/smpte_text_asset.h> +#include <fmt/format.h> #include <memory> #include "i18n.h" @@ -57,7 +57,7 @@ DCPSubtitle::load (boost::filesystem::path file) const } if (!sc) { - throw FileError(String::compose(_("Could not read subtitles (%1 / %2)"), interop_error, smpte_error), file); + throw FileError(fmt::format(_("Could not read subtitles ({} / {})"), interop_error, smpte_error), file); } return sc; diff --git a/src/lib/dcp_text_track.cc b/src/lib/dcp_text_track.cc index 292932396..4f93c8e23 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->to_string() : _("Unknown")); + return fmt::format("{} ({})", name, language ? language->to_string() : _("Unknown")); } void diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index f250d4505..cfcb62216 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -30,7 +30,6 @@ */ -#include "compose.hpp" #include "config.h" #include "cross.h" #include "dcp_video.h" @@ -151,7 +150,7 @@ DCPVideo::encode_locally () const ArrayData enc = {}; /* This was empirically derived by a user: see #1902 */ int const minimum_size = 16384; - LOG_DEBUG_ENCODE("Using minimum frame size %1", minimum_size); + LOG_DEBUG_ENCODE("Using minimum frame size {}", minimum_size); auto xyz = convert_to_xyz(_frame); int noise_amount = 2; @@ -167,11 +166,11 @@ DCPVideo::encode_locally () const ); if (enc.size() >= minimum_size) { - LOG_DEBUG_ENCODE(N_("Frame %1 encoded size was OK (%2)"), _index, enc.size()); + LOG_DEBUG_ENCODE(N_("Frame {} encoded size was OK ({})"), _index, enc.size()); break; } - LOG_GENERAL (N_("Frame %1 encoded size was small (%2); adding noise at level %3 with pixel skip %4"), _index, enc.size(), noise_amount, pixel_skip); + LOG_GENERAL(N_("Frame {} encoded size was small ({}); adding noise at level {} with pixel skip {}"), _index, enc.size(), noise_amount, pixel_skip); /* The JPEG2000 is too low-bitrate for some decoders <cough>DSS200</cough> so add some noise * and try again. This is slow but hopefully won't happen too often. We have to do @@ -202,13 +201,13 @@ DCPVideo::encode_locally () const switch (_frame->eyes()) { case Eyes::BOTH: - LOG_DEBUG_ENCODE (N_("Finished locally-encoded frame %1 for mono"), _index); + LOG_DEBUG_ENCODE(N_("Finished locally-encoded frame {} for mono"), _index); break; case Eyes::LEFT: - LOG_DEBUG_ENCODE (N_("Finished locally-encoded frame %1 for L"), _index); + LOG_DEBUG_ENCODE(N_("Finished locally-encoded frame {} for L"), _index); break; case Eyes::RIGHT: - LOG_DEBUG_ENCODE (N_("Finished locally-encoded frame %1 for R"), _index); + LOG_DEBUG_ENCODE(N_("Finished locally-encoded frame {} for R"), _index); break; default: break; @@ -241,7 +240,7 @@ DCPVideo::encode_remotely (EncodeServerDescription serv, int timeout) const cxml::add_text_child(root, "Version", fmt::to_string(SERVER_LINK_VERSION)); add_metadata (root); - LOG_DEBUG_ENCODE (N_("Sending frame %1 to remote"), _index); + LOG_DEBUG_ENCODE(N_("Sending frame {} to remote"), _index); { Socket::WriteDigestScope ds (socket); @@ -252,7 +251,7 @@ DCPVideo::encode_remotely (EncodeServerDescription serv, int timeout) const socket->write ((uint8_t *) xml.c_str(), xml.bytes() + 1); /* Send binary data */ - LOG_TIMING("start-remote-send thread=%1", thread_id ()); + LOG_TIMING("start-remote-send thread={}", thread_id ()); _frame->write_to_socket (socket); } @@ -260,16 +259,16 @@ DCPVideo::encode_remotely (EncodeServerDescription serv, int timeout) const is ready and sent back. */ Socket::ReadDigestScope ds (socket); - LOG_TIMING("start-remote-encode thread=%1", thread_id ()); + LOG_TIMING("start-remote-encode thread={}", thread_id ()); ArrayData e (socket->read_uint32 ()); - LOG_TIMING("start-remote-receive thread=%1", thread_id ()); + LOG_TIMING("start-remote-receive thread={}", thread_id ()); socket->read (e.data(), e.size()); - LOG_TIMING("finish-remote-receive thread=%1", thread_id ()); + LOG_TIMING("finish-remote-receive thread={}", thread_id ()); if (!ds.check()) { throw NetworkError ("Checksums do not match"); } - LOG_DEBUG_ENCODE (N_("Finished remotely-encoded frame %1"), _index); + LOG_DEBUG_ENCODE(N_("Finished remotely-encoded frame {}"), _index); return e; } diff --git a/src/lib/dcpomatic_log.h b/src/lib/dcpomatic_log.h index 2372c8d01..237f5e5d0 100644 --- a/src/lib/dcpomatic_log.h +++ b/src/lib/dcpomatic_log.h @@ -20,30 +20,30 @@ #include "log.h" -#include "compose.hpp" +#include <fmt/format.h> /** The current log; set up by the front-ends when they have a Film to log into */ extern std::shared_ptr<Log> dcpomatic_log; -#define LOG_GENERAL(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_GENERAL); +#define LOG_GENERAL(...) dcpomatic_log->log(fmt::format(__VA_ARGS__), LogEntry::TYPE_GENERAL); #define LOG_GENERAL_NC(...) dcpomatic_log->log(__VA_ARGS__, LogEntry::TYPE_GENERAL); -#define LOG_ERROR(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_ERROR); +#define LOG_ERROR(...) dcpomatic_log->log(fmt::format(__VA_ARGS__), LogEntry::TYPE_ERROR); #define LOG_ERROR_NC(...) dcpomatic_log->log(__VA_ARGS__, LogEntry::TYPE_ERROR); -#define LOG_WARNING(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_WARNING); +#define LOG_WARNING(...) dcpomatic_log->log(fmt::format(__VA_ARGS__), LogEntry::TYPE_WARNING); #define LOG_WARNING_NC(...) dcpomatic_log->log(__VA_ARGS__, LogEntry::TYPE_WARNING); -#define LOG_TIMING(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_TIMING); -#define LOG_DEBUG_ENCODE(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_DEBUG_ENCODE); -#define LOG_DEBUG_VIDEO_VIEW(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_DEBUG_VIDEO_VIEW); -#define LOG_DEBUG_THREE_D(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_DEBUG_THREE_D); +#define LOG_TIMING(...) dcpomatic_log->log(fmt::format(__VA_ARGS__), LogEntry::TYPE_TIMING); +#define LOG_DEBUG_ENCODE(...) dcpomatic_log->log(fmt::format(__VA_ARGS__), LogEntry::TYPE_DEBUG_ENCODE); +#define LOG_DEBUG_VIDEO_VIEW(...) dcpomatic_log->log(fmt::format(__VA_ARGS__), LogEntry::TYPE_DEBUG_VIDEO_VIEW); +#define LOG_DEBUG_THREE_D(...) dcpomatic_log->log(fmt::format(__VA_ARGS__), LogEntry::TYPE_DEBUG_THREE_D); #define LOG_DEBUG_THREE_D_NC(...) dcpomatic_log->log(__VA_ARGS__, LogEntry::TYPE_DEBUG_THREE_D); -#define LOG_DISK(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_DISK); +#define LOG_DISK(...) dcpomatic_log->log(fmt::format(__VA_ARGS__), LogEntry::TYPE_DISK); #define LOG_DISK_NC(...) dcpomatic_log->log(__VA_ARGS__, LogEntry::TYPE_DISK); -#define LOG_DEBUG_PLAYER(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_DEBUG_PLAYER); +#define LOG_DEBUG_PLAYER(...) dcpomatic_log->log(fmt::format(__VA_ARGS__), LogEntry::TYPE_DEBUG_PLAYER); #define LOG_DEBUG_PLAYER_NC(...) dcpomatic_log->log(__VA_ARGS__, LogEntry::TYPE_DEBUG_PLAYER); -#define LOG_DEBUG_AUDIO_ANALYSIS(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_DEBUG_AUDIO_ANALYSIS); +#define LOG_DEBUG_AUDIO_ANALYSIS(...) dcpomatic_log->log(fmt::format(__VA_ARGS__), LogEntry::TYPE_DEBUG_AUDIO_ANALYSIS); #define LOG_DEBUG_AUDIO_ANALYSIS_NC(...) dcpomatic_log->log(__VA_ARGS__, LogEntry::TYPE_DEBUG_AUDIO_ANALYSIS); -#define LOG_HTTP(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_HTTP); +#define LOG_HTTP(...) dcpomatic_log->log(fmt::format(__VA_ARGS__), LogEntry::TYPE_HTTP); #define LOG_HTTP_NC(...) dcpomatic_log->log(__VA_ARGS__, LogEntry::TYPE_HTTP); diff --git a/src/lib/dcpomatic_socket.cc b/src/lib/dcpomatic_socket.cc index 83ab072d2..0d3879755 100644 --- a/src/lib/dcpomatic_socket.cc +++ b/src/lib/dcpomatic_socket.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "dcpomatic_assert.h" #include "dcpomatic_log.h" #include "dcpomatic_socket.h" @@ -71,7 +70,7 @@ Socket::connect (boost::asio::ip::tcp::endpoint endpoint) } while (ec == boost::asio::error::would_block); if (ec) { - throw NetworkError (String::compose (_("error during async_connect (%1)"), ec.value ())); + throw NetworkError(fmt::format(_("error during async_connect ({})"), ec.value ())); } if (!_socket.is_open ()) { @@ -105,7 +104,7 @@ Socket::write (uint8_t const * data, int size) } while (ec == boost::asio::error::would_block); if (ec) { - throw NetworkError (String::compose (_("error during async_write (%1)"), ec.value ())); + throw NetworkError(fmt::format(_("error during async_write ({})"), ec.value())); } if (_write_digester) { @@ -146,7 +145,7 @@ Socket::read (uint8_t* data, int size) } while (ec == boost::asio::error::would_block); if (ec) { - throw NetworkError (String::compose (_("error during async_read (%1)"), ec.value ())); + throw NetworkError(fmt::format(_("error during async_read ({})"), ec.value())); } if (_read_digester) { diff --git a/src/lib/disk_writer_messages.cc b/src/lib/disk_writer_messages.cc index d12207dbf..562e9e876 100644 --- a/src/lib/disk_writer_messages.cc +++ b/src/lib/disk_writer_messages.cc @@ -72,25 +72,25 @@ 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 += dcp::fmt::to_string(_progress) + "\n"; + 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 += dcp::fmt::to_string(_progress) + "\n"; + 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 += dcp::fmt::to_string(_progress) + "\n"; + message = fmt::format("{}\n", DISK_WRITER_VERIFY_PROGRESS); + message += fmt::to_string(_progress) + "\n"; break; } diff --git a/src/lib/dkdm_wrapper.cc b/src/lib/dkdm_wrapper.cc index 4c7838a8d..1effb6c4a 100644 --- a/src/lib/dkdm_wrapper.cc +++ b/src/lib/dkdm_wrapper.cc @@ -19,13 +19,13 @@ */ -#include "compose.hpp" #include "dkdm_wrapper.h" #include "dcpomatic_assert.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <libxml++/libxml++.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/format.h> using std::string; @@ -61,7 +61,7 @@ DKDMBase::read (cxml::ConstNodePtr node) string DKDM::name () const { - return String::compose ("%1 (%2)", _dkdm.content_title_text(), _dkdm.cpl_id()); + return fmt::format("{} ({})", _dkdm.content_title_text(), _dkdm.cpl_id()); } diff --git a/src/lib/email.cc b/src/lib/email.cc index 7a6e58d91..10393945f 100644 --- a/src/lib/email.cc +++ b/src/lib/email.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "config.h" #include "email.h" #include "exceptions.h" @@ -146,7 +145,7 @@ Email::send(string server, int port, EmailProtocol protocol, string user, string } _email += "Subject: " + encode_rfc1342(_subject) + "\r\n" + - variant::insert_dcpomatic("User-Agent: %1\r\n\r\n"); + variant::insert_dcpomatic("User-Agent: {}\r\n\r\n"); if (!_attachments.empty ()) { _email += "--" + boundary + "\r\n" @@ -195,9 +194,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 ()) { @@ -237,7 +236,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/encode_server.cc b/src/lib/encode_server.cc index 08e661eac..4862e62cc 100644 --- a/src/lib/encode_server.cc +++ b/src/lib/encode_server.cc @@ -25,7 +25,6 @@ */ -#include "compose.hpp" #include "config.h" #include "constants.h" #include "cross.h" @@ -167,7 +166,7 @@ EncodeServer::process (shared_ptr<Socket> socket, struct timeval& after_read, st socket->write (encoded.data(), encoded.size()); } catch (std::exception& e) { cerr << "Send failed; frame " << dcp_video_frame.index() << "\n"; - LOG_ERROR ("Send failed; frame %1", dcp_video_frame.index()); + LOG_ERROR("Send failed; frame {}", dcp_video_frame.index()); throw; } @@ -210,7 +209,7 @@ EncodeServer::worker_thread () ip = socket->socket().remote_endpoint().address().to_string(); } catch (std::exception& e) { cerr << "Error: " << e.what() << "\n"; - LOG_ERROR ("Error: %1", e.what()); + LOG_ERROR("Error: {}", e.what()); } gettimeofday (&end, 0); @@ -245,7 +244,7 @@ EncodeServer::worker_thread () void EncodeServer::run () { - LOG_GENERAL ("Server %1 (%2) starting with %3 threads", dcpomatic_version, dcpomatic_git_commit, _num_threads); + LOG_GENERAL("Server {} ({}) starting with {} threads", dcpomatic_version, dcpomatic_git_commit, _num_threads); if (_verbose) { cout << variant::dcpomatic_encode_server() << " starting with " << _num_threads << " threads.\n"; } diff --git a/src/lib/encode_server_finder.cc b/src/lib/encode_server_finder.cc index 22c1d37dd..2a20a61f1 100644 --- a/src/lib/encode_server_finder.cc +++ b/src/lib/encode_server_finder.cc @@ -189,7 +189,7 @@ try { new tcp::acceptor (_listen_io_service, tcp::endpoint(tcp::v4(), is_batch_converter ? BATCH_SERVER_PRESENCE_PORT : MAIN_SERVER_PRESENCE_PORT)) ); } catch (...) { - boost::throw_exception(NetworkError(variant::insert_dcpomatic(_("Could not listen for remote encode servers. Perhaps another instance of %1 is running.")))); + boost::throw_exception(NetworkError(variant::insert_dcpomatic(_("Could not listen for remote encode servers. Perhaps another instance of {} is running.")))); } start_accept (); 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 27496dcdc..ffdda2d6a 100644 --- a/src/lib/exceptions.cc +++ b/src/lib/exceptions.cc @@ -20,22 +20,22 @@ #include "exceptions.h" -#include "compose.hpp" +#include <fmt/format.h> #include "i18n.h" -using std::string; using std::runtime_error; +using std::string; using boost::optional; /** @param f File that we were trying to open */ OpenFileError::OpenFileError (boost::filesystem::path f, int error, Mode mode) : FileError ( - String::compose ( - mode == READ_WRITE ? _("could not open file %1 for read/write (%2)") : - (mode == READ ? _("could not open file %1 for read (%2)") : _("could not open file %1 for write (%2)")), + fmt::format( + mode == READ_WRITE ? _("could not open file {} for read/write ({})") : + (mode == READ ? _("could not open file {} for read ({})") : _("could not open file {} for write ({})")), f.string(), error), f @@ -46,7 +46,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) { @@ -54,35 +54,35 @@ FileNotFoundError::FileNotFoundError (boost::filesystem::path f) ReadFileError::ReadFileError (boost::filesystem::path f, int e) - : FileError (String::compose(_("could not read from file %1 (%2)"), f.string(), strerror(e)), f) + : FileError(fmt::format(_("could not read from file {} ({})"), f.string(), strerror(e)), f) { } WriteFileError::WriteFileError (boost::filesystem::path f, int e) - : FileError (String::compose(_("could not write to file %1 (%2)"), f.string(), strerror(e)), f) + : FileError(fmt::format(_("could not write to file {} ({})"), f.string(), strerror(e)), f) { } MissingSettingError::MissingSettingError (string s) - : SettingError (s, String::compose(_("Missing required setting %1"), s)) + : SettingError(s, fmt::format(_("Missing required setting {}"), s)) { } PixelFormatError::PixelFormatError (string o, AVPixelFormat f) - : runtime_error (String::compose(_("Cannot handle pixel format %1 during %2"), (int) f, o)) + : runtime_error(fmt::format(_("Cannot handle pixel format {} during {}"), (int) f, o)) { } TextSubtitleError::TextSubtitleError (string saw, string expecting, boost::filesystem::path f) - : FileError (String::compose(_("Error in subtitle file: saw %1 while expecting %2"), saw.empty() ? "[nothing]" : saw, expecting), f) + : FileError(fmt::format(_("Error in subtitle file: saw {} while expecting {}"), saw.empty() ? "[nothing]" : saw, expecting), f) { } @@ -96,14 +96,14 @@ InvalidSignerError::InvalidSignerError () InvalidSignerError::InvalidSignerError (string reason) - : runtime_error (String::compose(_("The certificate chain for signing is invalid (%1)"), reason)) + : runtime_error(fmt::format(_("The certificate chain for signing is invalid ({})"), reason)) { } ProgrammingError::ProgrammingError (string file, int line, string message) - : runtime_error (String::compose(_("Programming error at %1:%2 %3"), file, line, message)) + : runtime_error(fmt::format(_("Programming error at {}:{} {}"), file, line, message)) { } @@ -117,7 +117,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) { @@ -126,7 +126,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) { @@ -135,7 +135,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)) { } @@ -149,7 +149,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) @@ -166,7 +166,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) { @@ -175,7 +175,7 @@ VerifyError::VerifyError (string m, int n) DiskFullError::DiskFullError(boost::filesystem::path writing) - : std::runtime_error(String::compose(_("Disk full when writing %1"), writing.string())) + : std::runtime_error(fmt::format(_("Disk full when writing {}"), writing.string())) { } diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index f7e9c9dc5..406ef8443 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -31,6 +31,7 @@ extern "C" { #include <libavutil/pixfmt.h> } +#include <fmt/format.h> #include <boost/filesystem.hpp> #include <boost/optional.hpp> #include <sqlite3.h> @@ -50,19 +51,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())) {} }; @@ -86,12 +87,12 @@ public: : std::runtime_error (s) {} - explicit EncodeError (std::string function, std::string caller) - : std::runtime_error (String::compose("%1 failed [%2]", function, caller)) + EncodeError(std::string function, std::string 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)) + EncodeError(std::string function, std::string caller, int error) + : std::runtime_error(fmt::format("{} failed [{}] ({})", function, caller, error)) {} }; @@ -106,7 +107,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) {} @@ -339,7 +340,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)) {} }; @@ -517,17 +518,17 @@ private: std::string get_message(sqlite3* 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(sqlite3* 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(sqlite3* 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 25946df73..ce32e0556 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" @@ -114,13 +113,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 +133,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 +146,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 +170,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 +187,7 @@ read (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_ 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 +227,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 +237,7 @@ copy (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_ 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 +246,7 @@ copy (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_ } } 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 {}", from.string(), cr.generic_string(), write_digest); copied_files.push_back (CopiedFile(from, cr, write_digest)); } } @@ -260,7 +259,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 {} on write, now {}", 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 +347,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 {}", 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 +425,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): {} {} {}", 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/ffmpeg.cc b/src/lib/ffmpeg.cc index c6867c081..f9a5dc9b6 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "config.h" #include "dcpomatic_log.h" #include "digester.h" @@ -37,6 +36,7 @@ extern "C" { #include <libavformat/avformat.h> #include <libswscale/swscale.h> } +#include <fmt/format.h> #include <boost/algorithm/string.hpp> #include <iostream> @@ -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 49e4933a6..d28b7c073 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -20,7 +20,6 @@ */ #include "audio_content.h" -#include "compose.hpp" #include "config.h" #include "constants.h" #include "exceptions.h" @@ -118,7 +117,7 @@ FFmpegContent::FFmpegContent(cxml::ConstNodePtr node, boost::optional<boost::fil if (auto filter = Filter::from_id(i->content())) { _filters.push_back(*filter); } else { - notes.push_back(String::compose(_("%1 no longer supports the `%2' filter, so it has been turned off."), variant::dcpomatic(), i->content())); + notes.push_back(fmt::format(_("{} no longer supports the `{}' filter, so it has been turned off."), variant::dcpomatic(), i->content())); } } @@ -346,11 +345,11 @@ string FFmpegContent::summary () const { if (video && audio) { - return String::compose (_("%1 [movie]"), path_summary()); + return fmt::format(_("{} [movie]"), path_summary()); } else if (video) { - return String::compose (_("%1 [video]"), path_summary()); + return fmt::format(_("{} [video]"), path_summary()); } else if (audio) { - return String::compose (_("%1 [audio]"), path_summary()); + return fmt::format(_("{} [audio]"), path_summary()); } return path_summary (); @@ -386,8 +385,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 ); } @@ -560,14 +559,14 @@ FFmpegContent::add_properties (shared_ptr<const Film> film, list<UserProperty>& /// file is limited, so that not all possible values are valid. p.push_back ( UserProperty ( - UserProperty::VIDEO, _("Colour range"), String::compose(_("Limited / video (%1-%2)"), lim_start, lim_end) + UserProperty::VIDEO, _("Colour range"), fmt::format(_("Limited / video ({}-{})"), lim_start, lim_end) ) ); break; case AVCOL_RANGE_JPEG: /// TRANSLATORS: this means that the range of pixel values used in this /// file is full, so that all possible pixel values are valid. - p.push_back(UserProperty(UserProperty::VIDEO, _("Colour range"), String::compose(_("Full (0-%1)"), total - 1))); + p.push_back(UserProperty(UserProperty::VIDEO, _("Colour range"), fmt::format(_("Full (0-{})"), total - 1))); break; default: DCPOMATIC_ASSERT (false); diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 81ca14f7f..65bc148fa 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -27,7 +27,6 @@ #include "audio_buffers.h" #include "audio_content.h" #include "audio_decoder.h" -#include "compose.hpp" #include "dcpomatic_log.h" #include "exceptions.h" #include "ffmpeg_audio_stream.h" @@ -109,7 +108,7 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> film, shared_ptr<const FFmp FFmpegDecoder::FlushResult FFmpegDecoder::flush () { - LOG_DEBUG_PLAYER("Flush FFmpeg decoder: current state %1", static_cast<int>(_flush_state)); + LOG_DEBUG_PLAYER("Flush FFmpeg decoder: current state {}", static_cast<int>(_flush_state)); switch (_flush_state) { case FlushState::CODECS: @@ -193,7 +192,7 @@ FFmpegDecoder::flush_fill() here. I'm not sure if that's the right idea. */ if (a > ContentTime() && a < full_length) { - LOG_DEBUG_PLAYER("Flush inserts silence at %1", to_string(a)); + LOG_DEBUG_PLAYER("Flush inserts silence at {}", to_string(a)); auto to_do = min (full_length - a, ContentTime::from_seconds (0.1)); auto silence = make_shared<AudioBuffers>(i->channels(), to_do.frames_ceil (i->frame_rate())); silence->make_silent (); @@ -220,12 +219,12 @@ FFmpegDecoder::pass () Hence it makes sense to continue here in that case. */ if (r < 0 && r != AVERROR_INVALIDDATA) { - LOG_DEBUG_PLAYER("FFpmegDecoder::pass flushes because av_read_frame returned %1", r); + LOG_DEBUG_PLAYER("FFpmegDecoder::pass flushes because av_read_frame returned {}", r); if (r != AVERROR_EOF) { /* Maybe we should fail here, but for now we'll just finish off instead */ char buf[256]; av_strerror (r, buf, sizeof(buf)); - LOG_ERROR (N_("error on av_read_frame (%1) (%2)"), &buf[0], r); + LOG_ERROR(N_("error on av_read_frame ({}) ({})"), &buf[0], r); } av_packet_free (&packet); @@ -375,7 +374,7 @@ deinterleave_audio(AVFrame* frame) break; default: - throw DecodeError (String::compose(_("Unrecognised audio sample format (%1)"), static_cast<int>(format))); + throw DecodeError(fmt::format(_("Unrecognised audio sample format ({})"), static_cast<int>(format))); } return audio; @@ -505,7 +504,7 @@ FFmpegDecoder::process_audio_frame (shared_ptr<FFmpegAudioStream> stream) av_q2d(time_base)) + _pts_offset; LOG_DEBUG_PLAYER( - "Process audio with timestamp %1 (BET %2, timebase %3/%4, (PTS offset %5)", + "Process audio with timestamp {} (BET {}, timebase {}/{}, (PTS offset {})", to_string(ct), frame->best_effort_timestamp, time_base.num, @@ -526,7 +525,7 @@ FFmpegDecoder::process_audio_frame (shared_ptr<FFmpegAudioStream> stream) if (ct < ContentTime()) { LOG_WARNING ( - "Crazy timestamp %1 for %2 samples in stream %3 (ts=%4 tb=%5, off=%6)", + "Crazy timestamp {} for {} samples in stream {} (ts={} tb={}, off={})", to_string(ct), data->frames(), stream->id(), @@ -554,10 +553,10 @@ FFmpegDecoder::decode_and_process_audio_packet (AVPacket* packet) auto context = _codec_context[stream->index(_format_context)]; auto frame = audio_frame (stream); - LOG_DEBUG_PLAYER("Send audio packet on stream %1", stream->index(_format_context)); + LOG_DEBUG_PLAYER("Send audio packet on stream {}", stream->index(_format_context)); int r = avcodec_send_packet (context, packet); if (r < 0) { - LOG_WARNING("avcodec_send_packet returned %1 for an audio packet", r); + LOG_WARNING("avcodec_send_packet returned {} for an audio packet", r); } while (r >= 0) { r = avcodec_receive_frame (context, frame); @@ -587,7 +586,7 @@ FFmpegDecoder::decode_and_process_video_packet (AVPacket* packet) do { int r = avcodec_send_packet (context, packet); if (r < 0) { - LOG_WARNING("avcodec_send_packet returned %1 for a video packet", r); + LOG_WARNING("avcodec_send_packet returned {} for a video packet", r); } /* EAGAIN means we should call avcodec_receive_frame and then re-send the same packet */ diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index ca85ae3c5..de41e0390 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -196,7 +196,7 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo } } - LOG_GENERAL("Temporal reference was %1", temporal_reference); + LOG_GENERAL("Temporal reference was {}", temporal_reference); if (temporal_reference.find("T2T3B2B3T2T3B2B3") != string::npos || temporal_reference.find("B2B3T2T3B2B3T2T3") != string::npos) { /* The magical sequence (taken from mediainfo) suggests that 2:3 pull-down is in use */ _pulldown = true; @@ -223,7 +223,7 @@ FFmpegExaminer::video_packet (AVCodecContext* context, string& temporal_referenc do { int r = avcodec_send_packet (context, packet); if (r < 0) { - LOG_WARNING("avcodec_send_packet returned %1 for a video packet", r); + LOG_WARNING("avcodec_send_packet returned {} for a video packet", r); } /* EAGAIN means we should call avcodec_receive_frame and then re-send the same packet */ @@ -266,7 +266,7 @@ FFmpegExaminer::audio_packet (AVCodecContext* context, shared_ptr<FFmpegAudioStr int r = avcodec_send_packet (context, packet); if (r < 0) { - LOG_WARNING("avcodec_send_packet returned %1 for an audio packet", r); + LOG_WARNING("avcodec_send_packet returned {} for an audio packet", r); return false; } diff --git a/src/lib/ffmpeg_file_encoder.cc b/src/lib/ffmpeg_file_encoder.cc index 7f74ae4f6..3314d5d82 100644 --- a/src/lib/ffmpeg_file_encoder.cc +++ b/src/lib/ffmpeg_file_encoder.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "cross.h" #include "ffmpeg_file_encoder.h" #include "ffmpeg_wrapper.h" @@ -32,6 +31,7 @@ extern "C" { #include <libavutil/channel_layout.h> } +#include <fmt/format.h> #include <iostream> #include "i18n.h" @@ -61,7 +61,7 @@ public: { _codec = avcodec_find_encoder_by_name (codec_name.c_str()); if (!_codec) { - throw EncodeError (String::compose("avcodec_find_encoder_by_name failed for %1", codec_name)); + throw EncodeError(fmt::format("avcodec_find_encoder_by_name failed for {}", codec_name)); } _codec_context = avcodec_alloc_context3 (_codec); @@ -268,7 +268,7 @@ FFmpegFileEncoder::FFmpegFileEncoder ( r = avio_open_boost (&_format_context->pb, _output, AVIO_FLAG_WRITE); if (r < 0) { - throw EncodeError (String::compose(_("Could not open output file %1 (%2)"), _output.string(), r)); + throw EncodeError(fmt::format(_("Could not open output file {} ({})"), _output.string(), r)); } AVDictionary* options = nullptr; @@ -316,7 +316,7 @@ FFmpegFileEncoder::setup_video () { _video_codec = avcodec_find_encoder_by_name (_video_codec_name.c_str()); if (!_video_codec) { - throw EncodeError (String::compose("avcodec_find_encoder_by_name failed for %1", _video_codec_name)); + throw EncodeError(fmt::format("avcodec_find_encoder_by_name failed for {}", _video_codec_name)); } _video_codec_context = avcodec_alloc_context3 (_video_codec); diff --git a/src/lib/ffmpeg_film_encoder.cc b/src/lib/ffmpeg_film_encoder.cc index a2d26fd66..ed47d5b4d 100644 --- a/src/lib/ffmpeg_film_encoder.cc +++ b/src/lib/ffmpeg_film_encoder.cc @@ -28,7 +28,7 @@ #include "log.h" #include "player.h" #include "player_video.h" -#include "compose.hpp" +#include <fmt/format.h> #include <iostream> #include "i18n.h" @@ -147,9 +147,9 @@ FFmpegFilmEncoder::go() filename = dcp::filesystem::change_extension(filename, ""); if (files > 1) { - /// TRANSLATORS: _reel%1 here is to be added to an export filename to indicate - /// which reel it is. Preserve the %1; it will be replaced with the reel number. - filename = filename.string() + String::compose(_("_reel%1"), i + 1); + /// TRANSLATORS: _reel{} here is to be added to an export filename to indicate + /// which reel it is. Preserve the {}; it will be replaced with the reel number. + filename = filename.string() + fmt::format(_("_reel{}"), i + 1); } file_encoders.push_back ( @@ -198,7 +198,7 @@ FFmpegFilmEncoder::go() } } else { if (e.code != Butler::Error::Code::FINISHED) { - throw DecodeError(String::compose("Error during decoding: %1", e.summary())); + throw DecodeError(fmt::format("Error during decoding: {}", e.summary())); } } } @@ -263,17 +263,17 @@ FFmpegFilmEncoder::FileEncoderSet::FileEncoderSet( _encoders[Eyes::LEFT] = make_shared<FFmpegFileEncoder>( video_frame_size, video_frame_rate, audio_frame_rate, channels, format, // TRANSLATORS: L here is an abbreviation for "left", to indicate the left-eye part of a 3D export - audio_stream_per_channel, x264_crf, String::compose("%1_%2%3", output.string(), _("L"), extension) + audio_stream_per_channel, x264_crf, fmt::format("{}_{}{}", output.string(), _("L"), extension) ); _encoders[Eyes::RIGHT] = make_shared<FFmpegFileEncoder>( video_frame_size, video_frame_rate, audio_frame_rate, channels, format, // TRANSLATORS: R here is an abbreviation for "right", to indicate the right-eye part of a 3D export - audio_stream_per_channel, x264_crf, String::compose("%1_%2%3", output.string(), _("R"), extension) + audio_stream_per_channel, x264_crf, fmt::format("{}_{}{}", output.string(), _("R"), extension) ); } else { _encoders[Eyes::BOTH] = make_shared<FFmpegFileEncoder>( video_frame_size, video_frame_rate, audio_frame_rate, channels, format, - audio_stream_per_channel, x264_crf, String::compose("%1%2", output.string(), extension) + audio_stream_per_channel, x264_crf, fmt::format("{}{}", output.string(), extension) ); } } diff --git a/src/lib/ffmpeg_image_proxy.cc b/src/lib/ffmpeg_image_proxy.cc index c9fcd0413..9ba8f8bf5 100644 --- a/src/lib/ffmpeg_image_proxy.cc +++ b/src/lib/ffmpeg_image_proxy.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "cross.h" #include "dcpomatic_assert.h" #include "dcpomatic_socket.h" @@ -161,7 +160,7 @@ FFmpegImageProxy::image (Image::Alignment alignment, optional<dcp::Size>) const if (_path) { throw OpenFileError (_path->string(), e, OpenFileError::READ); } else { - boost::throw_exception(DecodeError(String::compose(_("Could not decode image (%1)"), e))); + boost::throw_exception(DecodeError(fmt::format(_("Could not decode image ({})"), e))); } } diff --git a/src/lib/file_group.cc b/src/lib/file_group.cc index 56a5c2c59..84893b790 100644 --- a/src/lib/file_group.cc +++ b/src/lib/file_group.cc @@ -24,13 +24,13 @@ */ -#include "compose.hpp" #include "cross.h" #include "dcpomatic_assert.h" #include "exceptions.h" #include "file_group.h" #include <dcp/filesystem.h> #include <sndfile.h> +#include <fmt/format.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/film.cc b/src/lib/film.cc index a1babd317..3254ac105 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -30,7 +30,6 @@ #include "audio_processor.h" #include "change_signaller.h" #include "cinema.h" -#include "compose.hpp" #include "config.h" #include "constants.h" #include "cross.h" @@ -502,7 +501,7 @@ Film::write_metadata () try { metadata()->write_to_file_formatted(filename.string()); } catch (xmlpp::exception& e) { - throw FileError(String::compose("Could not write metadata file (%1)", e.what()), filename); + throw FileError(fmt::format("Could not write metadata file ({})", e.what()), filename); } set_dirty (false); } @@ -526,7 +525,7 @@ Film::read_metadata (optional<boost::filesystem::path> path) if (dcp::filesystem::exists(file("metadata")) && !dcp::filesystem::exists(file(metadata_file))) { throw runtime_error( variant::insert_dcpomatic( - _("This film was created with an older version of %1, and unfortunately it cannot " + _("This film was created with an older version of {}, and unfortunately it cannot " "be loaded into this version. You will need to create a new Film, re-add your " "content and set it up again. Sorry!") ) @@ -545,10 +544,10 @@ Film::read_metadata (optional<boost::filesystem::path> path) _state_version = f.number_child<int> ("Version"); if (_state_version > current_state_version) { - throw runtime_error(variant::insert_dcpomatic(_("This film was created with a newer version of %1, and it cannot be loaded into this version. Sorry!"))); + throw runtime_error(variant::insert_dcpomatic(_("This film was created with a newer version of {}, and it cannot be loaded into this version. Sorry!"))); } else if (_state_version < current_state_version) { /* This is an older version; save a copy (if we haven't already) */ - auto const older = path->parent_path() / String::compose("metadata.%1.xml", _state_version); + auto const older = path->parent_path() / fmt::format("metadata.{}.xml", _state_version); if (!dcp::filesystem::is_regular_file(older)) { try { dcp::filesystem::copy_file(*path, older); @@ -933,7 +932,7 @@ Film::isdcf_name (bool if_created_now) const } } } else { - version = dcp::fmt::to_string(_version_number); + version = fmt::to_string(_version_number); } isdcf_name += "-" + version; } @@ -966,7 +965,7 @@ Film::isdcf_name (bool if_created_now) const auto fl = _luminance->value_in_foot_lamberts(); char buffer[64]; snprintf (buffer, sizeof(buffer), "%.1f", fl); - isdcf_name += String::compose("-%1fl", buffer); + isdcf_name += fmt::format("-{}fl", buffer); } if (video_frame_rate() != 24) { @@ -989,7 +988,7 @@ Film::isdcf_name (bool if_created_now) const auto first_ratio = lrintf(scaled_size->ratio() * 100); auto container_ratio = lrintf(container()->ratio() * 100); if (first_ratio != container_ratio) { - isdcf_name += "-" + dcp::fmt::to_string(first_ratio); + isdcf_name += "-" + fmt::to_string(first_ratio); } } } @@ -1052,7 +1051,7 @@ Film::isdcf_name (bool if_created_now) const if (!ch.first && !ch.second) { isdcf_name += "_MOS"; } else if (ch.first) { - isdcf_name += String::compose("_%1%2", ch.first, ch.second); + isdcf_name += fmt::format("_{}{}", ch.first, ch.second); } if (audio_channels() > static_cast<int>(dcp::Channel::HI) && find(mapped.begin(), mapped.end(), static_cast<int>(dcp::Channel::HI)) != mapped.end()) { @@ -1650,7 +1649,7 @@ Film::check_reel_boundaries_for_atmos() } else { set_reel_type(ReelType::SINGLE); } - Message(variant::insert_dcpomatic("%1 had to change your reel settings to accomodate the Atmos content")); + Message(variant::insert_dcpomatic("{} had to change your reel settings to accomodate the Atmos content")); } } @@ -1672,7 +1671,7 @@ Film::check_settings_consistency () Message(_("You have more than one piece of Atmos content, and they do not have the same frame rate. You must remove some Atmos content.")); } else if (atmos_rates.size() == 1 && *atmos_rates.begin() != video_frame_rate()) { set_video_frame_rate(*atmos_rates.begin(), false); - Message(variant::insert_dcpomatic(_("%1 had to change your settings so that the film's frame rate is the same as that of your Atmos content."))); + Message(variant::insert_dcpomatic(_("{} had to change your settings so that the film's frame rate is the same as that of your Atmos content."))); } if (!atmos_rates.empty()) { @@ -1706,7 +1705,7 @@ Film::check_settings_consistency () } if (change_made) { - Message(variant::insert_dcpomatic(_("%1 had to change your settings for referring to DCPs as OV. Please review those settings to make sure they are what you want."))); + Message(variant::insert_dcpomatic(_("{} had to change your settings for referring to DCPs as OV. Please review those settings to make sure they are what you want."))); } if (reel_type() == ReelType::CUSTOM) { @@ -1717,9 +1716,9 @@ Film::check_settings_consistency () if (too_late != boundaries.end()) { if (std::distance(too_late, boundaries.end()) > 1) { - Message(variant::insert_dcpomatic(_("%1 had to remove some of your custom reel boundaries as they no longer lie within the film."))); + Message(variant::insert_dcpomatic(_("{} had to remove some of your custom reel boundaries as they no longer lie within the film."))); } else { - Message(variant::insert_dcpomatic(_("%1 had to remove one of your custom reel boundaries as it no longer lies within the film."))); + Message(variant::insert_dcpomatic(_("{} had to remove one of your custom reel boundaries as it no longer lies within the film."))); } boundaries.erase(too_late, boundaries.end()); set_custom_reel_boundaries(boundaries); @@ -1842,7 +1841,7 @@ Film::make_kdm(boost::filesystem::path cpl_file, dcp::LocalTime from, dcp::Local bool done = false; for (auto const& k: imported_keys) { if (k.id() == asset->key_id().get()) { - LOG_GENERAL("Using imported key for %1", asset->key_id().get()); + LOG_GENERAL("Using imported key for {}", asset->key_id().get()); keys[asset] = k.key(); done = true; } @@ -1850,7 +1849,7 @@ Film::make_kdm(boost::filesystem::path cpl_file, dcp::LocalTime from, dcp::Local if (!done) { /* No imported key; it must be an asset that we encrypted */ - LOG_GENERAL("Using our own key for %1", asset->key_id().get()); + LOG_GENERAL("Using our own key for {}", asset->key_id().get()); keys[asset] = key(); } } @@ -2454,9 +2453,9 @@ Film::read_remembered_assets() const assets.push_back(RememberedAsset(node)); } } catch (std::exception& e) { - LOG_ERROR("Could not read assets file %1 (%2)", filename, e.what()); + LOG_ERROR("Could not read assets file {} ({})", filename.string(), e.what()); } catch (...) { - LOG_ERROR("Could not read assets file %1", filename); + LOG_ERROR("Could not read assets file {}", filename.string()); } return assets; @@ -2476,8 +2475,8 @@ Film::write_remembered_assets(vector<RememberedAsset> const& assets) const try { doc->write_to_file_formatted(dcp::filesystem::fix_long_path(file(assets_file)).string()); } catch (std::exception& e) { - LOG_ERROR("Could not write assets file %1 (%2)", file(assets_file), e.what()); + LOG_ERROR("Could not write assets file {} ({})", file(assets_file).string(), e.what()); } catch (...) { - LOG_ERROR("Could not write assets file %1", file(assets_file)); + LOG_ERROR("Could not write assets file {}", file(assets_file).string()); } } diff --git a/src/lib/filter_graph.cc b/src/lib/filter_graph.cc index 745d980a4..178c93a25 100644 --- a/src/lib/filter_graph.cc +++ b/src/lib/filter_graph.cc @@ -28,12 +28,12 @@ #include "filter.h" #include "exceptions.h" #include "image.h" -#include "compose.hpp" extern "C" { #include <libavfilter/buffersrc.h> #include <libavfilter/buffersink.h> #include <libavformat/avio.h> } +#include <fmt/format.h> #include <iostream> #include "i18n.h" @@ -105,7 +105,7 @@ FilterGraph::setup(vector<Filter> const& filters) int e = avfilter_graph_config (_graph, 0); if (e < 0) { - throw DecodeError (String::compose(N_("could not configure filter graph (%1)"), e)); + throw DecodeError(fmt::format(N_("could not configure filter graph ({})"), e)); } } diff --git a/src/lib/font_config.cc b/src/lib/font_config.cc index 653c9ba84..410f27541 100644 --- a/src/lib/font_config.cc +++ b/src/lib/font_config.cc @@ -125,18 +125,18 @@ FontConfig::system_font_with_name(string name) { optional<boost::filesystem::path> path; - LOG_GENERAL("Searching system for font %1", name); + LOG_GENERAL("Searching system for font {}", name); auto pattern = FcNameParse(reinterpret_cast<FcChar8 const*>(name.c_str())); auto object_set = FcObjectSetBuild(FC_FILE, nullptr); auto font_set = FcFontList(_config, pattern, object_set); if (font_set) { - LOG_GENERAL("%1 candidate fonts found", font_set->nfont); + LOG_GENERAL("{} candidate fonts found", font_set->nfont); for (int i = 0; i < font_set->nfont; ++i) { auto font = font_set->fonts[i]; FcChar8* file; if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) { path = boost::filesystem::path(reinterpret_cast<char*>(file)); - LOG_GENERAL("Found %1", *path); + LOG_GENERAL("Found {}", path->string()); break; } } @@ -149,9 +149,9 @@ FontConfig::system_font_with_name(string name) FcPatternDestroy(pattern); if (path) { - LOG_GENERAL("Searched system for font %1, found %2", name, *path); + LOG_GENERAL("Searched system for font {}, found {}", name, path->string()); } else { - LOG_GENERAL("Searched system for font %1; nothing found", name); + LOG_GENERAL("Searched system for font {}; nothing found", name); } return path; diff --git a/src/lib/font_id_allocator.cc b/src/lib/font_id_allocator.cc index b85fc90dc..59db72a09 100644 --- a/src/lib/font_id_allocator.cc +++ b/src/lib/font_id_allocator.cc @@ -19,13 +19,13 @@ */ -#include "compose.hpp" #include "constants.h" #include "dcpomatic_assert.h" #include "font_id_allocator.h" #include <dcp/reel.h> #include <dcp/reel_text_asset.h> #include <dcp/text_asset.h> +#include <fmt/format.h> #include <set> #include <string> #include <vector> @@ -88,7 +88,7 @@ FontIDAllocator::allocate() auto proposed = font.first.font_id; int prefix = 0; while (used_ids.find(proposed) != used_ids.end()) { - proposed = String::compose("%1_%2", prefix++, font.first.font_id); + proposed = fmt::format("{}_{}", prefix++, font.first.font_id); DCPOMATIC_ASSERT(prefix < 128); } font.second = proposed; diff --git a/src/lib/frame_rate_change.cc b/src/lib/frame_rate_change.cc index 8372493ef..a531ad319 100644 --- a/src/lib/frame_rate_change.cc +++ b/src/lib/frame_rate_change.cc @@ -19,10 +19,10 @@ */ -#include "compose.hpp" #include "content.h" #include "film.h" #include "frame_rate_change.h" +#include <fmt/format.h> #include <cmath> #include "i18n.h" @@ -93,7 +93,7 @@ FrameRateChange::description () const } else if (repeat == 2) { description = _("Each content frame will be doubled in the DCP.\n"); } else if (repeat > 2) { - description = String::compose (_("Each content frame will be repeated %1 more times in the DCP.\n"), repeat - 1); + description = fmt::format(_("Each content frame will be repeated {} more times in the DCP.\n"), repeat - 1); } if (change_speed) { diff --git a/src/lib/grok_j2k_encoder_thread.cc b/src/lib/grok_j2k_encoder_thread.cc index e6c256f11..f7476f920 100644 --- a/src/lib/grok_j2k_encoder_thread.cc +++ b/src/lib/grok_j2k_encoder_thread.cc @@ -51,16 +51,16 @@ try { while (true) { - LOG_TIMING("encoder-sleep thread=%1", thread_id()); + LOG_TIMING("encoder-sleep thread={}", thread_id()); auto frame = _encoder.pop(); dcp::ScopeGuard frame_guard([this, &frame]() { - LOG_ERROR("Failed to schedule encode of %1 using grok", frame.index()); + LOG_ERROR("Failed to schedule encode of {} using grok", frame.index()); _errors++; _encoder.retry(frame); }); - LOG_TIMING("encoder-pop thread=%1 frame=%2 eyes=%3", thread_id(), frame.index(), static_cast<int>(frame.eyes())); + LOG_TIMING("encoder-pop thread={} frame={} eyes={}", thread_id(), frame.index(), static_cast<int>(frame.eyes())); auto grok = Config::instance()->grok().get_value_or({}); diff --git a/src/lib/hints.cc b/src/lib/hints.cc index b929a3746..14fb5f023 100644 --- a/src/lib/hints.cc +++ b/src/lib/hints.cc @@ -22,7 +22,6 @@ #include "audio_analysis.h" #include "audio_content.h" #include "audio_processor.h" -#include "compose.hpp" #include "config.h" #include "constants.h" #include "content.h" @@ -110,7 +109,7 @@ Hints::check_few_audio_channels () variant::insert_dcpomatic( _("Your DCP has fewer than 6 audio channels. This may cause problems on some projectors. " "You may want to set the DCP to have 6 channels. It does not matter if your content has " - "fewer channels, as %1 will fill the extras with silence.") + "fewer channels, as {} will fill the extras with silence.") ) ); } @@ -123,7 +122,7 @@ Hints::check_upmixers () auto ap = film()->audio_processor(); if (ap && (ap->id() == "stereo-5.1-upmix-a" || ap->id() == "stereo-5.1-upmix-b")) { hint(variant::insert_dcpomatic( - _("You are using %1's stereo-to-5.1 upmixer. This is experimental and " + _("You are using {}'s stereo-to-5.1 upmixer. This is experimental and " "may result in poor-quality audio. If you continue, you should listen to the " "resulting DCP in a cinema to make sure that it sounds good.") ) @@ -190,7 +189,7 @@ Hints::check_frame_rate () case 25: { /* You might want to go to 24 */ - string base = String::compose(_("You are set up for a DCP at a frame rate of %1 fps. This frame rate is not supported by all projectors. You may want to consider changing your frame rate to %2 fps."), 25, 24); + string base = fmt::format(_("You are set up for a DCP at a frame rate of {} fps. This frame rate is not supported by all projectors. You may want to consider changing your frame rate to {} fps."), 25, 24); if (f->interop()) { base += " "; base += _("If you do use 25fps you should change your DCP standard to SMPTE."); @@ -206,7 +205,7 @@ Hints::check_frame_rate () case 50: case 60: /* You almost certainly want to go to half frame rate */ - hint (String::compose(_("You are set up for a DCP at a frame rate of %1 fps. This frame rate is not supported by all projectors. It is advisable to change the DCP frame rate to %2 fps."), f->video_frame_rate(), f->video_frame_rate() / 2)); + hint (fmt::format(_("You are set up for a DCP at a frame rate of {} fps. This frame rate is not supported by all projectors. It is advisable to change the DCP frame rate to {} fps."), f->video_frame_rate(), f->video_frame_rate() / 2)); break; } } @@ -304,7 +303,7 @@ Hints::check_vob () } if (vob > 1) { - hint (String::compose (_("You have %1 files that look like they are VOB files from DVD. You should join them to ensure smooth joins between the files."), vob)); + hint (fmt::format(_("You have {} files that look like they are VOB files from DVD. You should join them to ensure smooth joins between the files."), vob)); } } @@ -353,8 +352,8 @@ Hints::check_loudness () ch = ch.substr (0, ch.length() - 2); if (!ch.empty()) { - hint(String::compose( - _("Your audio level is very high (on %1). You should reduce the gain of your audio content."), + hint(fmt::format( + _("Your audio level is very high (on {}). You should reduce the gain of your audio content."), ch ) ); @@ -589,9 +588,9 @@ Hints::closed_caption (PlayerText text, DCPTimePeriod period) if (!_long_ccap) { _long_ccap = true; hint ( - 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.", + 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) ); @@ -600,7 +599,7 @@ Hints::closed_caption (PlayerText text, DCPTimePeriod period) } if (!_too_many_ccap_lines && lines > MAX_CLOSED_CAPTION_LINES) { - hint (String::compose(_("Some of your closed captions span more than %1 lines, so they will be truncated."), MAX_CLOSED_CAPTION_LINES)); + hint (fmt::format(_("Some of your closed captions span more than {} lines, so they will be truncated."), MAX_CLOSED_CAPTION_LINES)); _too_many_ccap_lines = true; } @@ -739,7 +738,7 @@ Hints::check_certificates () switch (*bad) { case Config::BAD_SIGNER_UTF8_STRINGS: hint(variant::insert_dcpomatic( - _("The certificate chain that %1 uses for signing DCPs and KDMs contains a small error " + _("The certificate chain that {} uses for signing DCPs and KDMs contains a small error " "which will prevent DCPs from being validated correctly on some systems. It is advisable to " "re-create the signing certificate chain by clicking the \"Re-make certificates and key...\" " "button in the Keys page of Preferences.") @@ -747,7 +746,7 @@ Hints::check_certificates () break; case Config::BAD_SIGNER_VALIDITY_TOO_LONG: hint(variant::insert_dcpomatic( - _("The certificate chain that %1 uses for signing DCPs and KDMs has a validity period " + _("The certificate chain that {} uses for signing DCPs and KDMs has a validity period " "that is too long. This will cause problems playing back DCPs on some systems. " "It is advisable to re-create the signing certificate chain by clicking the " "\"Re-make certificates and key...\" button in the Keys page of Preferences.") @@ -765,7 +764,7 @@ Hints::check_8_or_16_audio_channels() { auto const channels = film()->audio_channels(); if (film()->video_encoding() != VideoEncoding::MPEG2 && channels != 8 && channels != 16) { - hint(String::compose(_("Your DCP has %1 audio channels, rather than 8 or 16. This may cause some distributors to raise QC errors when they check your DCP. To avoid this, set the DCP audio channels to 8 or 16."), channels)); + hint(fmt::format(_("Your DCP has {} audio channels, rather than 8 or 16. This may cause some distributors to raise QC errors when they check your DCP. To avoid this, set the DCP audio channels to 8 or 16."), channels)); } } diff --git a/src/lib/http_server.cc b/src/lib/http_server.cc index 0ee62756a..90c54bcff 100644 --- a/src/lib/http_server.cc +++ b/src/lib/http_server.cc @@ -25,6 +25,7 @@ #include "http_server.h" #include "util.h" #include "variant.h" +#include <fmt/format.h> #include <boost/algorithm/string.hpp> #include <stdexcept> @@ -72,7 +73,7 @@ Response::add_header(string key, string value) void Response::send(shared_ptr<Socket> socket) { - socket->write(String::compose("HTTP/1.1 %1 OK\r\n", _code)); + socket->write(fmt::format("HTTP/1.1 {} OK\r\n", _code)); switch (_type) { case Type::HTML: socket->write("Content-Type: text/html; charset=utf-8\r\n"); @@ -81,9 +82,9 @@ Response::send(shared_ptr<Socket> socket) socket->write("Content-Type: text/json; charset=utf-8\r\n"); break; } - socket->write(String::compose("Content-Length: %1\r\n", _payload.length())); + socket->write(fmt::format("Content-Length: {}\r\n", _payload.length())); for (auto const& header: _headers) { - socket->write(String::compose("%1: %2\r\n", header.first, header.second)); + socket->write(fmt::format("{}: {}\r\n", header.first, header.second)); } socket->write("\r\n"); socket->write(_payload); @@ -94,21 +95,21 @@ Response HTTPServer::get(string const& url) { if (url == "/") { - return Response(200, String::compose(dcp::file_to_string(resources_path() / "web" / "index.html"), variant::dcpomatic_player())); + return Response(200, fmt::format(dcp::file_to_string(resources_path() / "web" / "index.html"), variant::dcpomatic_player())); } else if (url == "/api/v1/status") { auto json = string{"{ "}; { boost::mutex::scoped_lock lm(_mutex); - json += String::compose("\"playing\": %1, ", _playing ? "true" : "false"); - json += String::compose("\"position\": \"%1\", ", seconds_to_hms(_position.seconds())); - json += String::compose("\"dcp_name\": \"%1\"", _dcp_name); + json += fmt::format("\"playing\": {}, ", _playing ? "true" : "false"); + json += fmt::format("\"position\": \"{}\", ", seconds_to_hms(_position.seconds())); + json += fmt::format("\"dcp_name\": \"{}\"", _dcp_name); } json += " }"; auto response = Response(200, json); response.set_type(Response::Type::JSON); return response; } else { - LOG_HTTP("404 %1", url); + LOG_HTTP("404 {}", url); return Response::ERROR_404; } } @@ -144,19 +145,19 @@ HTTPServer::request(vector<string> const& request) try { if (parts[0] == "GET") { - LOG_HTTP("GET %1", parts[1]); + LOG_HTTP("GET {}", parts[1]); return get(parts[1]); } else if (parts[0] == "POST") { - LOG_HTTP("POST %1", parts[1]); + LOG_HTTP("POST {}", parts[1]); return post(parts[1]); } } catch (std::exception& e) { - LOG_ERROR("Error while handling HTTP request: %1", e.what()); + LOG_ERROR("Error while handling HTTP request: {}", e.what()); } catch (...) { LOG_ERROR_NC("Unknown exception while handling HTTP request"); } - LOG_HTTP("404 %1", parts[0]); + LOG_HTTP("404 {}", parts[0]); return Response::ERROR_404; } @@ -191,7 +192,7 @@ HTTPServer::handle(shared_ptr<Socket> socket) } else if (_line.size() >= 2) { _line = _line.substr(0, _line.length() - 2); } - LOG_HTTP("Receive: %1", _line); + LOG_HTTP("Receive: {}", _line); _request.push_back(_line); _line = ""; } diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc index 15a0b043d..02afd6ab5 100644 --- a/src/lib/image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "config.h" #include "cross.h" #include "exceptions.h" @@ -33,6 +32,7 @@ #include <dcp/exceptions.h> #include <dcp/filesystem.h> #include <dcp/j2k_transcode.h> +#include <fmt/format.h> #include <iostream> #include "i18n.h" @@ -62,7 +62,7 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag try { _video_size = dcp::decompress_j2k(buffer.data(), size, 0)->size(); } catch (dcp::ReadError& e) { - throw DecodeError (String::compose (_("Could not decode JPEG2000 file %1 (%2)"), path, e.what ())); + throw DecodeError(fmt::format(_("Could not decode JPEG2000 file {} ({})"), path.string(), e.what())); } } else { FFmpegImageProxy proxy(content->path(0)); diff --git a/src/lib/image_png.cc b/src/lib/image_png.cc index b97ef5aad..0817a6944 100644 --- a/src/lib/image_png.cc +++ b/src/lib/image_png.cc @@ -23,6 +23,7 @@ #include "exceptions.h" #include "image.h" #include <png.h> +#include <fmt/format.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/internet.cc b/src/lib/internet.cc index 8c5b99e61..b9ec753c7 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "cross.h" #include "exceptions.h" #include "scoped_temporary.h" @@ -121,7 +120,7 @@ get_from_url (string url, bool pasv, bool skip_pasv_ip, ScopedTemporary& temp) f.close(); curl_easy_cleanup (curl); if (cr != CURLE_OK) { - return String::compose (_("Download failed (%1 error %2)"), url, (int) cr); + return fmt::format(_("Download failed ({} error {})"), url, static_cast<int>(cr)); } return {}; @@ -176,7 +175,7 @@ get_from_zip_url (string url, string file, bool pasv, bool skip_pasv_ip, functio zip_error_init (&error); auto zip = zip_open_from_source (zip_source, ZIP_RDONLY, &error); if (!zip) { - return String::compose (_("Could not open downloaded ZIP file (%1:%2: %3)"), error.zip_err, error.sys_err, error.str ? error.str : ""); + return fmt::format(_("Could not open downloaded ZIP file ({}:{}: {})"), error.zip_err, error.sys_err, error.str ? error.str : ""); } #else diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index 309fce0b3..4b48bc220 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" @@ -198,7 +197,7 @@ J2KEncoder::end() { boost::mutex::scoped_lock lock (_queue_mutex); - LOG_GENERAL (N_("Clearing queue of %1"), _queue.size ()); + LOG_GENERAL(N_("Clearing queue of {}"), _queue.size ()); /* Keep waking workers until the queue is empty */ while (!_queue.empty ()) { @@ -214,7 +213,7 @@ J2KEncoder::end() /* Something might have been thrown during terminate_threads */ rethrow (); - LOG_GENERAL (N_("Mopping up %1"), _queue.size()); + LOG_GENERAL(N_("Mopping up {}"), _queue.size()); /* The following sequence of events can occur in the above code: 1. a remote worker takes the last image off the queue @@ -228,14 +227,14 @@ J2KEncoder::end() #ifdef DCPOMATIC_GROK if (Config::instance()->grok().get_value_or({}).enable) { if (!_context->scheduleCompress(i)){ - LOG_GENERAL (N_("[%1] J2KEncoder thread pushes frame %2 back onto queue after failure"), thread_id(), i.index()); + LOG_GENERAL(N_("[{}] J2KEncoder thread pushes frame {} back onto queue after failure"), thread_id(), i.index()); // handle error } } else { #else { #endif - LOG_GENERAL(N_("Encode left-over frame %1"), i.index()); + LOG_GENERAL(N_("Encode left-over frame {}"), i.index()); try { _writer.write( make_shared<dcp::ArrayData>(i.encode_locally()), @@ -244,7 +243,7 @@ J2KEncoder::end() ); frame_done (); } catch (std::exception& e) { - LOG_ERROR (N_("Local encode failed (%1)"), e.what ()); + LOG_ERROR(N_("Local encode failed ({})"), e.what ()); } } } @@ -297,9 +296,9 @@ J2KEncoder::encode (shared_ptr<PlayerVideo> pv, DCPTime time) when there are no threads. */ while (_queue.size() >= (threads * 2) + 1) { - LOG_TIMING ("decoder-sleep queue=%1 threads=%2", _queue.size(), threads); + LOG_TIMING("decoder-sleep queue={} threads={}", _queue.size(), threads); _full_condition.wait (queue_lock); - LOG_TIMING ("decoder-wake queue=%1 threads=%2", _queue.size(), threads); + LOG_TIMING("decoder-wake queue={} threads={}", _queue.size(), threads); } _writer.rethrow(); @@ -313,21 +312,21 @@ J2KEncoder::encode (shared_ptr<PlayerVideo> pv, DCPTime time) if (_writer.can_fake_write(position)) { /* We can fake-write this frame */ - LOG_DEBUG_ENCODE("Frame @ %1 FAKE", to_string(time)); + LOG_DEBUG_ENCODE("Frame @ {} FAKE", to_string(time)); _writer.fake_write(position, pv->eyes ()); frame_done (); } else if (pv->has_j2k() && !_film->reencode_j2k()) { - LOG_DEBUG_ENCODE("Frame @ %1 J2K", to_string(time)); + LOG_DEBUG_ENCODE("Frame @ {} J2K", to_string(time)); /* This frame already has J2K data, so just write it */ _writer.write(pv->j2k(), position, pv->eyes ()); frame_done (); } else if (_last_player_video[pv->eyes()] && _writer.can_repeat(position) && pv->same(_last_player_video[pv->eyes()])) { - LOG_DEBUG_ENCODE("Frame @ %1 REPEAT", to_string(time)); + LOG_DEBUG_ENCODE("Frame @ {} REPEAT", to_string(time)); _writer.repeat(position, pv->eyes()); } else { - LOG_DEBUG_ENCODE("Frame @ %1 ENCODE", to_string(time)); + LOG_DEBUG_ENCODE("Frame @ {} ENCODE", to_string(time)); /* Queue this new frame for encoding */ - LOG_TIMING ("add-frame-to-queue queue=%1", _queue.size ()); + LOG_TIMING("add-frame-to-queue queue={}", _queue.size ()); auto dcpv = DCPVideo( pv, position, @@ -365,7 +364,7 @@ J2KEncoder::terminate_threads () void J2KEncoder::remake_threads(int cpu, int gpu, list<EncodeServerDescription> servers) { - LOG_GENERAL("Making threads: CPU=%1, GPU=%2, Remote=%3", cpu, gpu, servers.size()); + LOG_GENERAL("Making threads: CPU={}, GPU={}, Remote={}", cpu, gpu, servers.size()); if ((cpu + gpu + servers.size()) == 0) { /* Make at least one thread, even if all else fails. Maybe we are configured * for "only servers encode" but no servers have been registered yet. @@ -440,9 +439,9 @@ J2KEncoder::remake_threads(int cpu, int gpu, list<EncodeServerDescription> serve auto const wanted_threads = server.threads(); if (wanted_threads > current_threads) { - LOG_GENERAL(N_("Adding %1 worker threads for remote %2"), wanted_threads - current_threads, server.host_name()); + LOG_GENERAL(N_("Adding {} worker threads for remote {}"), wanted_threads - current_threads, server.host_name()); } else if (wanted_threads < current_threads) { - LOG_GENERAL(N_("Removing %1 worker threads for remote %2"), current_threads - wanted_threads, server.host_name()); + LOG_GENERAL(N_("Removing {} worker threads for remote {}"), current_threads - wanted_threads, server.host_name()); } for (auto i = current_threads; i < wanted_threads; ++i) { @@ -466,7 +465,7 @@ J2KEncoder::pop() _empty_condition.wait (lock); } - LOG_TIMING("encoder-wake thread=%1 queue=%2", thread_id(), _queue.size()); + LOG_TIMING("encoder-wake thread={} queue={}", thread_id(), _queue.size()); auto vf = _queue.front(); _queue.pop_front(); diff --git a/src/lib/j2k_encoder_thread.cc b/src/lib/j2k_encoder_thread.cc index d0e8a439c..b6f927ceb 100644 --- a/src/lib/j2k_encoder_thread.cc +++ b/src/lib/j2k_encoder_thread.cc @@ -49,7 +49,7 @@ J2KEncoderThread::stop() try { _thread.join(); } catch (std::exception& e) { - LOG_ERROR("join() threw an exception: %1", e.what()); + LOG_ERROR("join() threw an exception: {}", e.what()); } catch (...) { LOG_ERROR_NC("join() threw an exception"); } diff --git a/src/lib/j2k_sync_encoder_thread.cc b/src/lib/j2k_sync_encoder_thread.cc index ef6834f60..9df6c253a 100644 --- a/src/lib/j2k_sync_encoder_thread.cc +++ b/src/lib/j2k_sync_encoder_thread.cc @@ -40,7 +40,7 @@ try log_thread_start(); while (true) { - LOG_TIMING("encoder-sleep thread=%1", thread_id()); + LOG_TIMING("encoder-sleep thread={}", thread_id()); auto frame = _encoder.pop(); dcp::ScopeGuard frame_guard([this, &frame]() { @@ -48,7 +48,7 @@ try _encoder.retry(frame); }); - LOG_TIMING("encoder-pop thread=%1 frame=%2 eyes=%3", thread_id(), frame.index(), static_cast<int>(frame.eyes())); + LOG_TIMING("encoder-pop thread={} frame={} eyes={}", thread_id(), frame.index(), static_cast<int>(frame.eyes())); auto encoded = encode(frame); diff --git a/src/lib/job.cc b/src/lib/job.cc index ee6ad4e70..8891f83c2 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -24,7 +24,6 @@ */ -#include "compose.hpp" #include "constants.h" #include "cross.h" #include "dcpomatic_log.h" @@ -105,7 +104,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 { @@ -113,7 +112,7 @@ Job::run_wrapper () } catch (dcp::FileError& e) { - string m = String::compose(_("An error occurred whilst handling the file %1."), e.filename().filename()); + string m = fmt::format(_("An error occurred whilst handling the file {}."), e.filename().filename().string()); try { auto const s = dcp::filesystem::space(e.filename()); @@ -138,9 +137,9 @@ Job::run_wrapper () /* 32-bit */ set_error ( _("Failed to encode the DCP."), - String::compose( - _("This error has probably occurred because you are running the 32-bit version of %1 and " - "trying to use too many encoding threads. Please reduce the 'number of threads %2 should " + fmt::format( + _("This error has probably occurred because you are running the 32-bit version of {} and " + "trying to use too many encoding threads. Please reduce the 'number of threads {} should " "use' in the General tab of Preferences and try again."), variant::dcpomatic(), variant::dcpomatic() @@ -152,9 +151,9 @@ Job::run_wrapper () if (running_32_on_64()) { set_error ( _("Failed to encode the DCP."), - String::compose( - _("This error has probably occurred because you are running the 32-bit version of %1. " - "Please re-install %2 with the 64-bit installer and try again."), + fmt::format( + _("This error has probably occurred because you are running the 32-bit version of {}. " + "Please re-install {} with the 64-bit installer and try again."), variant::dcpomatic(), variant::dcpomatic() ) @@ -167,7 +166,7 @@ Job::run_wrapper () if (!done) { set_error ( e.what (), - String::compose(_("It is not known what caused this error. %1"), report_problem()) + fmt::format(_("It is not known what caused this error. {}"), report_problem()) ); } @@ -177,8 +176,8 @@ Job::run_wrapper () } catch (OpenFileError& e) { set_error ( - String::compose (_("Could not open %1"), e.file().string()), - String::compose(_("%1 could not open the file %2 (%3). Perhaps it does not exist or is in an unexpected format."), + fmt::format(_("Could not open {}"), e.file().string()), + fmt::format(_("{} could not open the file {} ({}). Perhaps it does not exist or is in an unexpected format."), variant::dcpomatic(), dcp::filesystem::absolute(e.file()).string(), e.what() @@ -192,8 +191,8 @@ Job::run_wrapper () if (e.code() == boost::system::errc::no_such_file_or_directory) { set_error ( - String::compose (_("Could not open %1"), e.path1().string ()), - String::compose(_("%1 could not open the file %2 (%3). Perhaps it does not exist or is in an unexpected format."), + fmt::format(_("Could not open {}"), e.path1().string()), + fmt::format(_("{} could not open the file {} ({}). Perhaps it does not exist or is in an unexpected format."), variant::dcpomatic(), dcp::filesystem::absolute(e.path1()).string(), e.what() @@ -202,7 +201,7 @@ Job::run_wrapper () } else { set_error ( e.what (), - String::compose(_("It is not known what caused this error. %1"), report_problem()) + fmt::format(_("It is not known what caused this error. {}"), report_problem()) ); } @@ -262,7 +261,7 @@ Job::run_wrapper () set_error ( e.what (), - String::compose(_("It is not known what caused this error. %1"), report_problem()) + fmt::format(_("It is not known what caused this error. {}"), report_problem()) ); set_progress (1); @@ -272,7 +271,7 @@ Job::run_wrapper () set_error ( _("Unknown error"), - String::compose(_("It is not known what caused this error. %1"), report_problem()) + fmt::format(_("It is not known what caused this error. {}"), report_problem()) ); set_progress (1); @@ -493,7 +492,7 @@ Job::sub (string n) { { boost::mutex::scoped_lock lm (_progress_mutex); - LOG_GENERAL ("Sub-job %1 starting", n); + LOG_GENERAL("Sub-job {} starting", n); _sub_name = n; } @@ -527,7 +526,7 @@ void Job::set_error (string s, string d) { if (_film) { - _film->log()->log (String::compose ("Error in job: %1 (%2)", s, d), LogEntry::TYPE_ERROR); + _film->log()->log(fmt::format("Error in job: {} ({})", s, d), LogEntry::TYPE_ERROR); } boost::mutex::scoped_lock lm (_state_mutex); @@ -593,14 +592,14 @@ Job::status () const snprintf (finish_string, sizeof(finish_string), "%02d:%02d", int(finish.time_of_day().hours()), int(finish.time_of_day().minutes())); string day; if (now.date() != finish.date()) { - /// TRANSLATORS: the %1 in this string will be filled in with a day of the week + /// TRANSLATORS: the {} in this string will be filled in with a day of the week /// to say what day a job will finish. - day = String::compose (_(" on %1"), day_of_week_to_string(finish.date().day_of_week())); + day = fmt::format(_(" on {}"), day_of_week_to_string(finish.date().day_of_week())); } /// TRANSLATORS: "remaining; finishing at" here follows an amount of time that is remaining /// on an operation; after it is an estimated wall-clock completion time. - s += String::compose( - _("; %1 remaining; finishing at %2%3"), + s += fmt::format( + _("; {} remaining; finishing at {}{}"), seconds_to_approximate_hms(r), finish_string, day ); } @@ -617,12 +616,12 @@ Job::status () const s = _("OK"); } else if (duration < 600) { /* It took less than 10 minutes; it doesn't seem worth saying when it started and finished */ - s = String::compose(_("OK (ran for %1)"), seconds_to_hms(duration)); + s = fmt::format(_("OK (ran for {})"), seconds_to_hms(duration)); } else { - s = String::compose(_("OK (ran for %1 from %2 to %3)"), seconds_to_hms(duration), time_string(_start_time), time_string(_finish_time)); + s = fmt::format(_("OK (ran for {} from {} to {})"), seconds_to_hms(duration), time_string(_start_time), time_string(_finish_time)); } } else if (finished_in_error ()) { - s = String::compose (_("Error: %1"), error_summary ()); + s = fmt::format(_("Error: {}"), error_summary()); } else if (finished_cancelled ()) { s = _("Cancelled"); } diff --git a/src/lib/kdm_cli.cc b/src/lib/kdm_cli.cc index 20cbf33e6..0d0c6a8b8 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()) {} }; @@ -119,7 +120,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") { @@ -132,7 +133,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)); } @@ -165,7 +166,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 ( @@ -174,7 +175,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())); } } } @@ -219,10 +220,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 */ @@ -283,7 +284,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())); } } @@ -410,7 +411,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())); } } @@ -625,7 +626,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) { @@ -646,7 +647,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 {}; } @@ -714,7 +715,7 @@ try } if (verbose) { - out(String::compose("Making KDMs valid from %1 to %2", valid_from->as_string(), valid_to->as_string())); + out(fmt::format("Making KDMs valid from {} to {}", valid_from->as_string(), valid_to->as_string())); } string const thing = argv[optind]; diff --git a/src/lib/make_dcp.cc b/src/lib/make_dcp.cc index b72756194..840fbf1a1 100644 --- a/src/lib/make_dcp.cc +++ b/src/lib/make_dcp.cc @@ -88,10 +88,10 @@ make_dcp (shared_ptr<Film> film, TranscodeJob::ChangedBehaviour behaviour) } for (auto content: film->content()) { - LOG_GENERAL ("Content: %1", content->technical_summary()); + LOG_GENERAL("Content: {}", content->technical_summary()); } - LOG_GENERAL ("DCP video rate %1 fps", film->video_frame_rate()); - LOG_GENERAL("Video bit rate %1", film->video_bit_rate(film->video_encoding())); + LOG_GENERAL("DCP video rate {} fps", film->video_frame_rate()); + LOG_GENERAL("Video bit rate {}", film->video_bit_rate(film->video_encoding())); auto tj = make_shared<DCPTranscodeJob>(film, behaviour); tj->set_encoder(make_shared<DCPFilmEncoder>(film, tj)); diff --git a/src/lib/map_cli.cc b/src/lib/map_cli.cc index 149e09fbc..034a4e2aa 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..8c439f36e 100644 --- a/src/lib/nanomsg.cc +++ b/src/lib/nanomsg.cc @@ -22,6 +22,7 @@ #include "dcpomatic_log.h" #include "exceptions.h" #include "nanomsg.h" +#include <fmt/format.h> #include <nanomsg/nn.h> #include <nanomsg/pair.h> #include <cerrno> @@ -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 f348f6b28..3c8da9955 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> @@ -768,7 +768,7 @@ Player::pass () switch (which) { case CONTENT: { - LOG_DEBUG_PLAYER ("Calling pass() on %1", earliest_content->content->path(0)); + LOG_DEBUG_PLAYER("Calling pass() on {}", earliest_content->content->path(0).string()); earliest_content->done = earliest_content->decoder->pass (); auto dcp = dynamic_pointer_cast<DCPContent>(earliest_content->content); if (dcp && !_play_referenced) { @@ -786,7 +786,7 @@ Player::pass () break; } case BLACK: - LOG_DEBUG_PLAYER ("Emit black for gap at %1", to_string(_black.position())); + LOG_DEBUG_PLAYER("Emit black for gap at {}", to_string(_black.position())); if (!_next_video_time) { /* Deciding to emit black has the same effect as getting some video from the content * when we are inaccurately seeking. @@ -803,7 +803,7 @@ Player::pass () break; case SILENT: { - LOG_DEBUG_PLAYER ("Emit silence for gap at %1", to_string(_silent.position())); + LOG_DEBUG_PLAYER("Emit silence for gap at {}", to_string(_silent.position())); DCPTimePeriod period (_silent.period_at_position()); if (_next_audio_time) { /* Sometimes the thing that happened last finishes fractionally before @@ -815,7 +815,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; @@ -858,14 +858,18 @@ Player::pass () std::map<AudioStreamPtr, StreamState> alive_stream_states; if (latest_last_push_end != have_pushed.end()) { - LOG_DEBUG_PLAYER("Leading audio stream is in %1 at %2", latest_last_push_end->second.piece->content->path(0), to_string(latest_last_push_end->second.last_push_end.get())); + LOG_DEBUG_PLAYER( + "Leading audio stream is in {} at {}", + latest_last_push_end->second.piece->content->path(0).string(), + to_string(latest_last_push_end->second.last_push_end.get()) + ); /* Now make a list of those streams that are less than ignore_streams_behind behind the leader */ for (auto const& i: _stream_states) { if (!i.second.last_push_end || (latest_last_push_end->second.last_push_end.get() - i.second.last_push_end.get()) < dcpomatic::DCPTime::from_seconds(ignore_streams_behind)) { alive_stream_states.insert(i); } else { - LOG_DEBUG_PLAYER("Ignoring stream %1 because it is too far behind", i.second.piece->content->path(0)); + LOG_DEBUG_PLAYER("Ignoring stream {} because it is too far behind", i.second.piece->content->path(0).string()); } } } @@ -881,7 +885,7 @@ Player::pass () pull_to = _silent.position(); } - LOG_DEBUG_PLAYER("Emitting audio up to %1", to_string(pull_to)); + LOG_DEBUG_PLAYER("Emitting audio up to {}", to_string(pull_to)); auto audio = _audio_merger.pull (pull_to); for (auto i = audio.begin(); i != audio.end(); ++i) { if (_next_audio_time && i->second < *_next_audio_time) { @@ -901,7 +905,7 @@ Player::pass () if (done) { if (_next_video_time) { - LOG_DEBUG_PLAYER("Done: emit video until end of film at %1", to_string(film->length())); + LOG_DEBUG_PLAYER("Done: emit video until end of film at {}", to_string(film->length())); emit_video_until(film->length()); } @@ -977,7 +981,7 @@ Player::open_texts_for_frame(DCPTime time) const void Player::emit_video_until(DCPTime time) { - LOG_DEBUG_PLAYER("emit_video_until %1; next video time is %2", to_string(time), to_string(_next_video_time.get_value_or({}))); + LOG_DEBUG_PLAYER("emit_video_until {}; next video time is {}", to_string(time), to_string(_next_video_time.get_value_or({}))); auto frame = [this](shared_ptr<PlayerVideo> pv, DCPTime time) { /* We need a delay to give a little wiggle room to ensure that relevant subtitles arrive at the player before the video that requires them. @@ -1017,7 +1021,7 @@ Player::emit_video_until(DCPTime time) frame(right.first, next); } else if (both.first && (both.second - next) < age_threshold) { frame(both.first, next); - LOG_DEBUG_PLAYER("Content %1 selected for DCP %2 (age %3)", to_string(both.second), to_string(next), to_string(both.second - next)); + LOG_DEBUG_PLAYER("Content {} selected for DCP {} (age {})", to_string(both.second), to_string(next), to_string(both.second - next)); } else { auto film = _film.lock(); if (film && film->three_d()) { @@ -1026,7 +1030,7 @@ Player::emit_video_until(DCPTime time) } else { frame(black_player_video_frame(Eyes::BOTH), next); } - LOG_DEBUG_PLAYER("Black selected for DCP %1", to_string(next)); + LOG_DEBUG_PLAYER("Black selected for DCP {}", to_string(next)); } } } @@ -1077,7 +1081,7 @@ Player::video (weak_ptr<Piece> weak_piece, ContentVideo video) /* Time of the frame we just received within the DCP */ auto const time = content_time_to_dcp(piece, video.time); - LOG_DEBUG_PLAYER("Received video frame %1 %2 eyes %3", to_string(video.time), to_string(time), static_cast<int>(video.eyes)); + LOG_DEBUG_PLAYER("Received video frame {} {} eyes {}", to_string(video.time), to_string(time), static_cast<int>(video.eyes)); if (time < piece->content->position()) { return; @@ -1167,7 +1171,7 @@ Player::audio (weak_ptr<Piece> weak_piece, AudioStreamPtr stream, ContentAudio c /* And the end of this block in the DCP */ auto end = time + DCPTime::from_frames(content_audio.audio->frames(), rfr); - LOG_DEBUG_PLAYER("Received audio frame %1 covering %2 to %3 (%4)", content_audio.frame, to_string(time), to_string(end), piece->content->path(0).filename()); + LOG_DEBUG_PLAYER("Received audio frame {} covering {} to {} ({})", content_audio.frame, to_string(time), to_string(end), piece->content->path(0).filename().string()); /* Remove anything that comes before the start or after the end of the content */ if (time < piece->content->position()) { @@ -1369,7 +1373,7 @@ void Player::seek (DCPTime time, bool accurate) { boost::mutex::scoped_lock lm (_mutex); - LOG_DEBUG_PLAYER("Seek to %1 (%2accurate)", to_string(time), accurate ? "" : "in"); + LOG_DEBUG_PLAYER("Seek to {} ({}accurate)", to_string(time), accurate ? "" : "in"); if (_suspended) { /* We can't seek in this state */ @@ -1457,7 +1461,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/playlist.cc b/src/lib/playlist.cc index a0d7d6531..92871f8b0 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -20,7 +20,6 @@ #include "audio_content.h" -#include "compose.hpp" #include "config.h" #include "content_factory.h" #include "dcp_content.h" @@ -36,6 +35,7 @@ #include "video_content.h" #include <libcxml/cxml.h> #include <libxml++/libxml++.h> +#include <fmt/format.h> #include <boost/bind/placeholders.hpp> #include <iostream> @@ -236,13 +236,13 @@ Playlist::set_from_xml (shared_ptr<const Film> film, cxml::ConstNodePtr node, in string note = _("Your project contains video content that was not aligned to a frame boundary."); note += " "; if (old_pos < content->position()) { - note += String::compose( - _("The file %1 has been moved %2 milliseconds later."), + note += fmt::format( + _("The file {} has been moved {} milliseconds later."), content->path_summary(), DCPTime(content->position() - old_pos).seconds() * 1000 ); } else { - note += String::compose( - _("The file %1 has been moved %2 milliseconds earlier."), + note += fmt::format( + _("The file {} has been moved {} milliseconds earlier."), content->path_summary(), DCPTime(content->position() - old_pos).seconds() * 1000 ); } @@ -256,13 +256,13 @@ Playlist::set_from_xml (shared_ptr<const Film> film, cxml::ConstNodePtr node, in string note = _("Your project contains video content whose trim was not aligned to a frame boundary."); note += " "; if (old_trim < content->trim_start()) { - note += String::compose( - _("The file %1 has been trimmed by %2 milliseconds more."), + note += fmt::format( + _("The file {} has been trimmed by {} milliseconds more."), content->path_summary(), ContentTime(content->trim_start() - old_trim).seconds() * 1000 ); } else { - note += String::compose( - _("The file %1 has been trimmed by %2 milliseconds less."), + note += fmt::format( + _("The file {} has been trimmed by {} milliseconds less."), content->path_summary(), ContentTime(old_trim - content->trim_start()).seconds() * 1000 ); } diff --git a/src/lib/raw_image_proxy.cc b/src/lib/raw_image_proxy.cc index 996cdc65f..9e819140b 100644 --- a/src/lib/raw_image_proxy.cc +++ b/src/lib/raw_image_proxy.cc @@ -30,6 +30,7 @@ extern "C" { LIBDCP_DISABLE_WARNINGS #include <libxml++/libxml++.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/format.h> #include "i18n.h" diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index f8694c5d3..7dbf16a02 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -20,7 +20,6 @@ #include "audio_buffers.h" -#include "compose.hpp" #include "config.h" #include "constants.h" #include "cross.h" @@ -164,7 +163,7 @@ ReelWriter::ReelWriter ( auto new_asset_filename = _output_dir / video_asset_filename(picture_asset, _reel_index, _reel_count, _content_summary); if (_first_nonexistent_frame > 0) { - LOG_GENERAL("Re-using partial asset %1: has frames up to %2", *existing_asset_filename, _first_nonexistent_frame); + LOG_GENERAL("Re-using partial asset {}: has frames up to {}", existing_asset_filename->string(), _first_nonexistent_frame); dcp::filesystem::rename(*existing_asset_filename, new_asset_filename); } remembered_assets.push_back(RememberedAsset(new_asset_filename.filename(), period, film()->video_identifier())); @@ -178,7 +177,7 @@ ReelWriter::ReelWriter ( _mpeg2_picture_asset_writer = _mpeg2_picture_asset->start_write(new_asset_filename, behaviour); } } else { - LOG_GENERAL("Re-using complete asset %1", *existing_asset_filename); + LOG_GENERAL("Re-using complete asset {}", existing_asset_filename->string()); /* We already have a complete picture asset that we can just re-use */ /* XXX: what about if the encryption key changes? */ auto new_asset_filename = _output_dir / existing_asset_filename->filename(); @@ -249,10 +248,10 @@ ReelWriter::check_existing_picture_asset (boost::filesystem::path asset) /* Try to open the existing asset */ dcp::File asset_file(asset, "rb"); if (!asset_file) { - LOG_GENERAL ("Could not open existing asset at %1 (errno=%2)", asset.string(), errno); + LOG_GENERAL("Could not open existing asset at {} (errno={})", asset.string(), errno); return 0; } else { - LOG_GENERAL ("Opened existing asset at %1", asset.string()); + LOG_GENERAL("Opened existing asset at {}", asset.string()); } shared_ptr<InfoFileHandle> info_file; @@ -266,7 +265,7 @@ ReelWriter::check_existing_picture_asset (boost::filesystem::path asset) /* Offset of the last dcp::FrameInfo in the info file */ int const n = (dcp::filesystem::file_size(info_file->get().path()) / J2KFrameInfo::size_on_disk()) - 1; - LOG_GENERAL("The last FI is %1; info file is %2, info size %3", n, dcp::filesystem::file_size(info_file->get().path()), J2KFrameInfo::size_on_disk()) + LOG_GENERAL("The last FI is {}; info file is {}, info size {}", n, dcp::filesystem::file_size(info_file->get().path()), J2KFrameInfo::size_on_disk()) Frame first_nonexistent_frame; if (film()->three_d()) { @@ -287,7 +286,7 @@ ReelWriter::check_existing_picture_asset (boost::filesystem::path asset) ++first_nonexistent_frame; } - LOG_GENERAL ("Proceeding with first nonexistent frame %1", first_nonexistent_frame); + LOG_GENERAL("Proceeding with first nonexistent frame {}", first_nonexistent_frame); return first_nonexistent_frame; } @@ -360,13 +359,13 @@ ReelWriter::finish (boost::filesystem::path output_dcp) { if (_j2k_picture_asset_writer && !_j2k_picture_asset_writer->finalize()) { /* Nothing was written to the J2K picture asset */ - LOG_GENERAL("Nothing was written to J2K asset for reel %1 of %2", _reel_index, _reel_count); + LOG_GENERAL("Nothing was written to J2K asset for reel {} of {}", _reel_index, _reel_count); _j2k_picture_asset.reset(); } if (_mpeg2_picture_asset_writer && !_mpeg2_picture_asset_writer->finalize()) { /* Nothing was written to the MPEG2 picture asset */ - LOG_GENERAL("Nothing was written to MPEG2 asset for reel %1 of %2", _reel_index, _reel_count); + LOG_GENERAL("Nothing was written to MPEG2 asset for reel {} of {}", _reel_index, _reel_count); _mpeg2_picture_asset.reset(); } @@ -385,7 +384,7 @@ ReelWriter::finish (boost::filesystem::path output_dcp) dcp::filesystem::rename(film()->file(aaf), audio_to, ec); if (ec) { throw FileError ( - String::compose(_("could not move audio asset into the DCP (%1)"), error_details(ec)), aaf + fmt::format(_("could not move audio asset into the DCP ({})"), error_details(ec)), aaf ); } @@ -402,7 +401,7 @@ ReelWriter::finish (boost::filesystem::path output_dcp) dcp::filesystem::rename(film()->file(aaf), atmos_to, ec); if (ec) { throw FileError ( - String::compose(_("could not move atmos asset into the DCP (%1)"), error_details(ec)), aaf + fmt::format(_("could not move atmos asset into the DCP ({})"), error_details(ec)), aaf ); } @@ -484,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); @@ -511,12 +510,12 @@ ReelWriter::create_reel_picture (shared_ptr<dcp::Reel> reel, list<ReferencedReel } else if (_mpeg2_picture_asset) { reel_asset = make_shared<dcp::ReelMonoPictureAsset>(_mpeg2_picture_asset, 0); } else { - LOG_GENERAL ("no picture asset of our own; look through %1", refs.size()); + LOG_GENERAL("no picture asset of our own; look through {}", refs.size()); /* We don't have a picture asset of our own; hopefully we have one to reference */ for (auto j: refs) { auto k = dynamic_pointer_cast<dcp::ReelPictureAsset> (j.asset); if (k) { - LOG_GENERAL ("candidate picture asset period is %1-%2", j.period.from.get(), j.period.to.get()); + LOG_GENERAL("candidate picture asset period is {}-{}", j.period.from.get(), j.period.to.get()); } if (k && j.period == _period) { reel_asset = k; @@ -530,7 +529,7 @@ ReelWriter::create_reel_picture (shared_ptr<dcp::Reel> reel, list<ReferencedReel 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); @@ -553,12 +552,12 @@ ReelWriter::create_reel_sound (shared_ptr<dcp::Reel> reel, list<ReferencedReelAs /* We have made a sound asset of our own. Put it into the reel */ reel_asset = make_shared<dcp::ReelSoundAsset>(_sound_asset, 0); } else { - LOG_GENERAL ("no sound asset of our own; look through %1", refs.size()); + LOG_GENERAL("no sound asset of our own; look through {}", refs.size()); /* We don't have a sound asset of our own; hopefully we have one to reference */ for (auto j: refs) { auto k = dynamic_pointer_cast<dcp::ReelSoundAsset> (j.asset); if (k) { - LOG_GENERAL ("candidate sound asset period is %1-%2", j.period.from.get(), j.period.to.get()); + LOG_GENERAL("candidate sound asset period is {}-{}", j.period.from.get(), j.period.to.get()); } if (k && j.period == _period) { reel_asset = k; @@ -574,15 +573,15 @@ ReelWriter::create_reel_sound (shared_ptr<dcp::Reel> reel, list<ReferencedReelAs DCPOMATIC_ASSERT (reel_asset); if (reel_asset->actual_duration() != period_duration) { - LOG_ERROR ( - "Reel sound asset has length %1 but reel period is %2", + LOG_ERROR( + "Reel sound asset has length {} but reel period is {}", reel_asset->actual_duration(), period_duration ); 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) ); } @@ -703,7 +702,7 @@ ReelWriter::create_reel ( set<DCPTextTrack> ensure_closed_captions ) { - LOG_GENERAL ("create_reel for %1-%2; %3 of %4", _period.from.get(), _period.to.get(), _reel_index, _reel_count); + LOG_GENERAL("create_reel for {}-{}; {} of {}", _period.from.get(), _period.to.get(), _reel_index, _reel_count); auto reel = make_shared<dcp::Reel>(); @@ -967,7 +966,7 @@ ReelWriter::write(PlayerText subs, TextType type, optional<DCPTextTrack> track, bool ReelWriter::existing_picture_frame_ok (dcp::File& asset_file, shared_ptr<InfoFileHandle> info_file, Frame frame) const { - LOG_GENERAL ("Checking existing picture frame %1", frame); + LOG_GENERAL("Checking existing picture frame {}", frame); /* Read the data from the info file; for 3D we just check the left frames until we find a good one. @@ -980,16 +979,16 @@ ReelWriter::existing_picture_frame_ok (dcp::File& asset_file, shared_ptr<InfoFil asset_file.seek(info.offset, SEEK_SET); ArrayData data (info.size); size_t const read = asset_file.read(data.data(), 1, data.size()); - LOG_GENERAL ("Read %1 bytes of asset data; wanted %2", read, info.size); + LOG_GENERAL("Read {} bytes of asset data; wanted {}", read, info.size); if (read != static_cast<size_t> (data.size ())) { - LOG_GENERAL ("Existing frame %1 is incomplete", frame); + LOG_GENERAL("Existing frame {} is incomplete", frame); ok = false; } else { Digester digester; digester.add (data.data(), data.size()); - LOG_GENERAL ("Hash %1 vs %2", digester.get(), info.hash); + LOG_GENERAL("Hash {} vs {}", digester.get(), info.hash); if (digester.get() != info.hash) { - LOG_GENERAL ("Existing frame %1 failed hash check", frame); + LOG_GENERAL("Existing frame {} failed hash check", frame); ok = false; } } diff --git a/src/lib/release_notes.cc b/src/lib/release_notes.cc index 64556bb26..58461f120 100644 --- a/src/lib/release_notes.cc +++ b/src/lib/release_notes.cc @@ -24,6 +24,7 @@ #include "variant.h" #include "version.h" #include <dcp/raw_convert.h> +#include <fmt/format.h> #include <boost/algorithm/string.hpp> #include "i18n.h" @@ -93,9 +94,9 @@ find_release_notes(bool dark, optional<string> current) } string const colour = dark ? "white" : "black"; - auto const span = String::compose("<span style=\"color: %1\">", colour); + auto const span = fmt::format("<span style=\"color: {}\">", colour); - auto output = String::compose("<h1>%1%2 %3 release notes</span></h1><ul>", span, variant::dcpomatic(), *current); + auto output = fmt::format("<h1>{}{} {} release notes</span></h1><ul>", span, variant::dcpomatic(), *current); for (auto const& note: notes) { output += string("<li>") + span + note + "</span>"; diff --git a/src/lib/remembered_asset.cc b/src/lib/remembered_asset.cc index cc3d93edf..dfe0917c5 100644 --- a/src/lib/remembered_asset.cc +++ b/src/lib/remembered_asset.cc @@ -53,8 +53,8 @@ RememberedAsset::as_xml(xmlpp::Element* parent) const { cxml::add_text_child(parent, "Filename", _filename.string()); auto period_node = cxml::add_child(parent, "Period"); - cxml::add_text_child(period_node, "From", dcp::fmt::to_string(_period.from.get())); - cxml::add_text_child(period_node, "To", dcp::fmt::to_string(_period.to.get())); + cxml::add_text_child(period_node, "From", fmt::to_string(_period.from.get())); + cxml::add_text_child(period_node, "To", fmt::to_string(_period.to.get())); cxml::add_text_child(parent, "Identifier", _identifier); } diff --git a/src/lib/remote_j2k_encoder_thread.cc b/src/lib/remote_j2k_encoder_thread.cc index 49d80953d..51d3e3207 100644 --- a/src/lib/remote_j2k_encoder_thread.cc +++ b/src/lib/remote_j2k_encoder_thread.cc @@ -44,7 +44,7 @@ void RemoteJ2KEncoderThread::log_thread_start() const { start_of_thread("RemoteJ2KEncoder"); - LOG_TIMING("start-encoder-thread thread=%1 server=%2", thread_id(), _server.host_name()); + LOG_TIMING("start-encoder-thread thread={} server={}", thread_id(), _server.host_name()); } @@ -56,17 +56,17 @@ RemoteJ2KEncoderThread::encode(DCPVideo const& frame) try { encoded = make_shared<dcp::ArrayData>(frame.encode_remotely(_server)); if (_remote_backoff > 0) { - LOG_GENERAL("%1 was lost, but now she is found; removing backoff", _server.host_name()); + LOG_GENERAL("{} was lost, but now she is found; removing backoff", _server.host_name()); _remote_backoff = 0; } } catch (std::exception& e) { LOG_ERROR( - N_("Remote encode of %1 on %2 failed (%3); thread sleeping for %4s"), + N_("Remote encode of {} on {} failed ({}); thread sleeping for {}s"), frame.index(), _server.host_name(), e.what(), _remote_backoff ); } catch (...) { LOG_ERROR( - N_("Remote encode of %1 on %2 failed; thread sleeping for %4s"), + N_("Remote encode of {} on {} failed; thread sleeping for {}s"), frame.index(), _server.host_name(), _remote_backoff ); } diff --git a/src/lib/resampler.cc b/src/lib/resampler.cc index 2c6594a6d..c2b75e1d5 100644 --- a/src/lib/resampler.cc +++ b/src/lib/resampler.cc @@ -22,8 +22,8 @@ #include "resampler.h" #include "audio_buffers.h" #include "exceptions.h" -#include "compose.hpp" #include "dcpomatic_assert.h" +#include <fmt/format.h> #include <samplerate.h> #include <iostream> #include <cmath> @@ -51,7 +51,7 @@ Resampler::Resampler (int in, int out, int channels) int error; _src = src_new (SRC_SINC_BEST_QUALITY, _channels, &error); if (!_src) { - throw runtime_error (String::compose(N_("could not create sample-rate converter (%1)"), error)); + throw runtime_error (fmt::format(N_("could not create sample-rate converter ({})"), error)); } } @@ -73,7 +73,7 @@ Resampler::set_fast () int error; _src = src_new (SRC_LINEAR, _channels, &error); if (!_src) { - throw runtime_error (String::compose(N_("could not create sample-rate converter (%1)"), error)); + throw runtime_error (fmt::format(N_("could not create sample-rate converter ({})"), error)); } } @@ -119,8 +119,8 @@ Resampler::run (shared_ptr<const AudioBuffers> in) int const r = src_process (_src, &data); if (r) { throw EncodeError ( - String::compose ( - N_("could not run sample-rate converter (%1) [processing %2 to %3, %4 channels]"), + fmt::format ( + N_("could not run sample-rate converter ({}) [processing {} to {}, {} channels]"), src_strerror (r), in_frames, max_resampled_frames, @@ -174,7 +174,7 @@ Resampler::flush () int const r = src_process (_src, &data); if (r) { - throw EncodeError (String::compose(N_("could not run sample-rate converter (%1)"), src_strerror(r))); + throw EncodeError(fmt::format(N_("could not run sample-rate converter ({})"), src_strerror(r))); } out->set_frames (out_offset + data.output_frames_gen); diff --git a/src/lib/scp_uploader.cc b/src/lib/scp_uploader.cc index 6c63a6c3e..17577529a 100644 --- a/src/lib/scp_uploader.cc +++ b/src/lib/scp_uploader.cc @@ -24,7 +24,6 @@ #include "job.h" #include "config.h" #include "cross.h" -#include "compose.hpp" #include <dcp/file.h> #include <dcp/filesystem.h> #include <dcp/warnings.h> @@ -44,7 +43,7 @@ SCPUploader::SCPUploader (function<void (string)> set_status, function<void (flo { _session = ssh_new (); if (!_session) { - throw NetworkError (String::compose(_("SSH error [%1]"), "ssh_new")); + throw NetworkError(fmt::format(_("SSH error [{}]"), "ssh_new")); } ssh_options_set (_session, SSH_OPTIONS_HOST, Config::instance()->tms_ip().c_str()); @@ -54,33 +53,33 @@ SCPUploader::SCPUploader (function<void (string)> set_status, function<void (flo int r = ssh_connect (_session); if (r != SSH_OK) { - throw NetworkError (String::compose(_("Could not connect to server %1 (%2)"), Config::instance()->tms_ip(), ssh_get_error(_session))); + throw NetworkError(fmt::format(_("Could not connect to server {} ({})"), Config::instance()->tms_ip(), ssh_get_error(_session))); } LIBDCP_DISABLE_WARNINGS r = ssh_is_server_known (_session); if (r == SSH_SERVER_ERROR) { - throw NetworkError (String::compose(_("SSH error [%1] (%2)"), "ssh_is_server_known", ssh_get_error(_session))); + throw NetworkError(fmt::format(_("SSH error [{}] ({})"), "ssh_is_server_known", ssh_get_error(_session))); } LIBDCP_ENABLE_WARNINGS r = ssh_userauth_password (_session, 0, Config::instance()->tms_password().c_str ()); if (r != SSH_AUTH_SUCCESS) { - throw NetworkError (String::compose(_("Failed to authenticate with server (%1)"), ssh_get_error(_session))); + throw NetworkError(fmt::format(_("Failed to authenticate with server ({})"), ssh_get_error(_session))); } LIBDCP_DISABLE_WARNINGS _scp = ssh_scp_new (_session, SSH_SCP_WRITE | SSH_SCP_RECURSIVE, Config::instance()->tms_path().c_str()); LIBDCP_ENABLE_WARNINGS if (!_scp) { - throw NetworkError (String::compose(_("SSH error [%1] (%2)"), "ssh_scp_new", ssh_get_error(_session))); + throw NetworkError(fmt::format(_("SSH error [{}] ({})"), "ssh_scp_new", ssh_get_error(_session))); } LIBDCP_DISABLE_WARNINGS r = ssh_scp_init (_scp); LIBDCP_ENABLE_WARNINGS if (r != SSH_OK) { - throw NetworkError (String::compose(_("SSH error [%1] (%2)"), "ssh_scp_init", ssh_get_error(_session))); + throw NetworkError(fmt::format(_("SSH error [{}] ({})"), "ssh_scp_init", ssh_get_error(_session))); } } @@ -103,7 +102,7 @@ LIBDCP_DISABLE_WARNINGS int const r = ssh_scp_push_directory (_scp, directory.generic_string().c_str(), S_IRWXU); LIBDCP_ENABLE_WARNINGS if (r != SSH_OK) { - throw NetworkError (String::compose(_("Could not create remote directory %1 (%2)"), directory, ssh_get_error(_session))); + throw NetworkError(fmt::format(_("Could not create remote directory {} ({})"), directory.string(), ssh_get_error(_session))); } } @@ -119,7 +118,7 @@ LIBDCP_ENABLE_WARNINGS dcp::File f(from, "rb"); if (!f) { - throw NetworkError (String::compose(_("Could not open %1 to send"), from)); + throw NetworkError(fmt::format(_("Could not open {} to send"), from.string())); } boost::uintmax_t buffer_size = 64 * 1024; @@ -136,7 +135,7 @@ LIBDCP_DISABLE_WARNINGS int const r = ssh_scp_write (_scp, buffer, t); LIBDCP_ENABLE_WARNINGS if (r != SSH_OK) { - throw NetworkError (String::compose(_("Could not write to remote file (%1)"), ssh_get_error(_session))); + throw NetworkError(fmt::format(_("Could not write to remote file ({})"), ssh_get_error(_session))); } to_do -= t; transferred += t; diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc index 59e33d4bc..e088de069 100644 --- a/src/lib/send_kdm_email_job.cc +++ b/src/lib/send_kdm_email_job.cc @@ -19,10 +19,10 @@ */ -#include "compose.hpp" #include "film.h" #include "kdm_with_metadata.h" #include "send_kdm_email_job.h" +#include <fmt/format.h> #include <list> #include "i18n.h" @@ -94,7 +94,7 @@ SendKDMEmailJob::name () const return _("Email KDMs"); } - return String::compose (_("Email KDMs for %1"), *f); + return fmt::format(_("Email KDMs for {}"), *f); } diff --git a/src/lib/send_problem_report_job.cc b/src/lib/send_problem_report_job.cc index ed78112e9..d3570c83f 100644 --- a/src/lib/send_problem_report_job.cc +++ b/src/lib/send_problem_report_job.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "cross.h" #include "email.h" #include "environment_info.h" @@ -29,6 +28,7 @@ #include "send_problem_report_job.h" #include "variant.h" #include "version.h" +#include <fmt/format.h> #include <libxml++/libxml++.h> #include "i18n.h" @@ -69,7 +69,7 @@ SendProblemReportJob::name () const return _("Email problem report"); } - return String::compose (_("Email problem report for %1"), _film->name()); + return fmt::format(_("Email problem report for {}"), _film->name()); } @@ -109,7 +109,7 @@ SendProblemReportJob::run () body += "---<8----\n"; } - Email email(_from, {"carl@dcpomatic.com"}, variant::insert_dcpomatic("%1 problem report"), body); + Email email(_from, {"carl@dcpomatic.com"}, variant::insert_dcpomatic("{} problem report"), body); email.send("main.carlh.net", 2525, EmailProtocol::STARTTLS); set_progress (1); diff --git a/src/lib/shuffler.cc b/src/lib/shuffler.cc index a4ea0f5dc..6b477073c 100644 --- a/src/lib/shuffler.cc +++ b/src/lib/shuffler.cc @@ -23,6 +23,7 @@ #include "content_video.h" #include "dcpomatic_assert.h" #include "dcpomatic_log.h" +#include <fmt/format.h> #include <string> #include <iostream> @@ -51,7 +52,7 @@ struct Comparator void Shuffler::video (weak_ptr<Piece> weak_piece, ContentVideo video) { - LOG_DEBUG_THREE_D("Shuffler::video time=%1 eyes=%2 part=%3", to_string(video.time), static_cast<int>(video.eyes), static_cast<int>(video.part)); + LOG_DEBUG_THREE_D("Shuffler::video time={} eyes={} part={}", to_string(video.time), static_cast<int>(video.eyes), static_cast<int>(video.part)); if (video.eyes != Eyes::LEFT && video.eyes != Eyes::RIGHT) { /* Pass through anything that we don't care about */ @@ -84,9 +85,9 @@ Shuffler::video (weak_ptr<Piece> weak_piece, ContentVideo video) ); if (!store_front_in_sequence) { - string const store = _store.empty() ? "store empty" : String::compose("store front time=%1 eyes=%2", to_string(_store.front().second.time), static_cast<int>(_store.front().second.eyes)); - string const last = _last ? String::compose("last time=%1 eyes=%2", to_string(_last->time), static_cast<int>(_last->eyes)) : "no last"; - LOG_DEBUG_THREE_D("Shuffler not in sequence: %1 %2", store, last); + string const store = _store.empty() ? "store empty" : fmt::format("store front time={} eyes={}", to_string(_store.front().second.time), static_cast<int>(_store.front().second.eyes)); + string const last = _last ? fmt::format("last time={} eyes={}", to_string(_last->time), static_cast<int>(_last->eyes)) : "no last"; + LOG_DEBUG_THREE_D("Shuffler not in sequence: {} {}", store, last); } if (!store_front_in_sequence && _store.size() <= _max_size) { @@ -98,10 +99,10 @@ Shuffler::video (weak_ptr<Piece> weak_piece, ContentVideo video) } if (_store.size() > _max_size) { - LOG_WARNING("Shuffler is full after receiving frame at %1; 3D sync may be incorrect.", to_string(video.time)); + LOG_WARNING("Shuffler is full after receiving frame at {}; 3D sync may be incorrect.", to_string(video.time)); } - LOG_DEBUG_THREE_D("Shuffler emits time=%1 eyes=%2 store=%3", to_string(_store.front().second.time), static_cast<int>(_store.front().second.eyes), _store.size()); + LOG_DEBUG_THREE_D("Shuffler emits time={} eyes={} store={}", to_string(_store.front().second.time), static_cast<int>(_store.front().second.eyes), _store.size()); Video (_store.front().first, _store.front().second); _last = _store.front().second; _store.pop_front (); diff --git a/src/lib/sqlite_table.cc b/src/lib/sqlite_table.cc index f00fa6b74..03c0278df 100644 --- a/src/lib/sqlite_table.cc +++ b/src/lib/sqlite_table.cc @@ -20,9 +20,9 @@ #include "dcpomatic_assert.h" -#include "compose.hpp" #include "sqlite_table.h" #include "util.h" +#include <fmt/format.h> using std::string; @@ -46,7 +46,7 @@ SQLiteTable::create() const for (size_t i = 0; i < _columns.size(); ++i) { columns[i] = _columns[i] + " " + _types[i]; } - return String::compose("CREATE TABLE IF NOT EXISTS %1 (id INTEGER PRIMARY KEY, %2)", _name, join_strings(columns, ", ")); + return fmt::format("CREATE TABLE IF NOT EXISTS {} (id INTEGER PRIMARY KEY, {})", _name, join_strings(columns, ", ")); } @@ -55,7 +55,7 @@ SQLiteTable::insert() const { DCPOMATIC_ASSERT(!_columns.empty()); vector<string> placeholders(_columns.size(), "?"); - return String::compose("INSERT INTO %1 (%2) VALUES (%3)", _name, join_strings(_columns, ", "), join_strings(placeholders, ", ")); + return fmt::format("INSERT INTO {} ({}) VALUES ({})", _name, join_strings(_columns, ", "), join_strings(placeholders, ", ")); } @@ -68,12 +68,12 @@ SQLiteTable::update(string const& condition) const placeholders[i] = _columns[i] + "=?"; } - return String::compose("UPDATE %1 SET %2 %3", _name, join_strings(placeholders, ", "), condition); + return fmt::format("UPDATE {} SET {} {}", _name, join_strings(placeholders, ", "), condition); } string SQLiteTable::select(string const& condition) const { - return String::compose("SELECT id,%1 FROM %2 %3", join_strings(_columns, ","), _name, condition); + return fmt::format("SELECT id,{} FROM {} {}", join_strings(_columns, ","), _name, condition); } diff --git a/src/lib/subtitle_film_encoder.cc b/src/lib/subtitle_film_encoder.cc index 8dff4bc5c..fc9ce92ee 100644 --- a/src/lib/subtitle_film_encoder.cc +++ b/src/lib/subtitle_film_encoder.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "film.h" #include "job.h" #include "player.h" @@ -70,9 +69,9 @@ SubtitleFilmEncoder::SubtitleFilmEncoder(shared_ptr<const Film> film, shared_ptr boost::filesystem::path filename = output; if (dcp::filesystem::is_directory(filename)) { if (files > 1) { - /// TRANSLATORS: _reel%1 here is to be added to an export filename to indicate - /// which reel it is. Preserve the %1; it will be replaced with the reel number. - filename /= String::compose("%1_reel%2", initial_name, i + 1); + /// TRANSLATORS: _reel{} here is to be added to an export filename to indicate + /// which reel it is. Preserve the {}; it will be replaced with the reel number. + filename /= fmt::format("{}_reel{}", initial_name, i + 1); } else { filename /= initial_name; } diff --git a/src/lib/text_content.cc b/src/lib/text_content.cc index 15e1d4055..3c5eb5527 100644 --- a/src/lib/text_content.cc +++ b/src/lib/text_content.cc @@ -27,6 +27,7 @@ #include "variant.h" #include <libcxml/cxml.h> #include <libxml++/libxml++.h> +#include <fmt/format.h> #include <iostream> #include "i18n.h" @@ -245,9 +246,9 @@ TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version, */ if (version <= 37) { if (!lang->content().empty()) { - notes.push_back(String::compose( - _("A subtitle or closed caption file in this project is marked with the language '%1', " - "which %2 does not recognise. The file's language has been cleared."), lang->content(), variant::dcpomatic())); + notes.push_back(fmt::format( + _("A subtitle or closed caption file in this project is marked with the language '{}', " + "which {} does not recognise. The file's language has been cleared."), lang->content(), variant::dcpomatic())); } } else { throw; diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc index db072eda6..33f3862d5 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" @@ -308,7 +307,7 @@ TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & sub_subti auto font = content()->get_font(block.font.get_value_or("")); if (!font) { - LOG_WARNING("Could not find font '%1' in content; falling back to default", block.font.get_value_or("")); + LOG_WARNING("Could not find font '{}' in content; falling back to default", block.font.get_value_or("")); font = std::make_shared<dcpomatic::Font>(block.font.get_value_or(""), default_font_file()); } DCPOMATIC_ASSERT(font); diff --git a/src/lib/text_type.cc b/src/lib/text_type.cc index 33e74bdca..fa0d9e146 100644 --- a/src/lib/text_type.cc +++ b/src/lib/text_type.cc @@ -19,12 +19,12 @@ */ -#include "compose.hpp" #include "dcpomatic_assert.h" #include "exceptions.h" #include "text_type.h" #include "types.h" #include <dcp/text_type.h> +#include <fmt/format.h> #include "i18n.h" @@ -46,7 +46,7 @@ string_to_text_type(string s) } else if (s == "closed-caption") { return TextType::CLOSED_CAPTION; } else { - throw MetadataError(String::compose("Unknown text type %1", s)); + throw MetadataError(fmt::format("Unknown text type {}", s)); } } 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/transcode_job.cc b/src/lib/transcode_job.cc index f1373fb4a..bdb0cb2b1 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -25,7 +25,6 @@ #include "analytics.h" -#include "compose.hpp" #include "content.h" #include "config.h" #include "dcp_film_encoder.h" @@ -72,7 +71,7 @@ TranscodeJob::~TranscodeJob () string TranscodeJob::name () const { - return String::compose (_("Transcoding %1"), _film->name()); + return fmt::format(_("Transcoding {}"), _film->name()); } @@ -113,7 +112,7 @@ TranscodeJob::run () set_progress (1); set_error( _("Files have changed since they were added to the project."), - variant::insert_dcpomatic(_("Open the project in %1, check the settings, then save it before trying again.")) + variant::insert_dcpomatic(_("Open the project in {}, check the settings, then save it before trying again.")) ); set_state (FINISHED_ERROR); return; @@ -131,13 +130,13 @@ TranscodeJob::run () set_progress (1); set_state (FINISHED_OK); - LOG_GENERAL(N_("Transcode job completed successfully: %1 fps"), dcp::locale_convert<string>(frames_per_second(), 2, true)); + LOG_GENERAL(N_("Transcode job completed successfully: {} fps"), dcp::locale_convert<string>(frames_per_second(), 2, true)); if (variant::count_created_dcps() && dynamic_pointer_cast<DCPFilmEncoder>(_encoder)) { try { Analytics::instance()->successful_dcp_encode(); } catch (FileError& e) { - LOG_WARNING (N_("Failed to write analytics (%1)"), e.what()); + LOG_WARNING(N_("Failed to write analytics ({})"), e.what()); } } @@ -177,10 +176,10 @@ TranscodeJob::status () const return Job::status(); } - auto status = String::compose(_("%1; %2/%3 frames"), Job::status(), _encoder->frames_done(), _film->length().frames_round(_film->video_frame_rate())); + auto status = fmt::format(_("{}; {}/{} frames"), Job::status(), _encoder->frames_done(), _film->length().frames_round(_film->video_frame_rate())); if (auto const fps = _encoder->current_rate()) { /// TRANSLATORS: fps here is an abbreviation for frames per second - status += String::compose(_("; %1 fps"), dcp::locale_convert<string>(*fps, 1, true)); + status += fmt::format(_("; {} fps"), dcp::locale_convert<string>(*fps, 1, true)); } return status; diff --git a/src/lib/types.cc b/src/lib/types.cc index 48363f892..2ef2bbf8c 100644 --- a/src/lib/types.cc +++ b/src/lib/types.cc @@ -18,9 +18,8 @@ */ -#include "types.h" -#include "compose.hpp" #include "dcpomatic_assert.h" +#include "types.h" #include <dcp/cpl.h> #include <dcp/dcp.h> #include <dcp/filesystem.h> diff --git a/src/lib/unzipper.cc b/src/lib/unzipper.cc index 8d468f24f..2f9510347 100644 --- a/src/lib/unzipper.cc +++ b/src/lib/unzipper.cc @@ -22,9 +22,11 @@ #include "dcpomatic_assert.h" #include "exceptions.h" #include "unzipper.h" +#include <dcp/array_data.h> #include <dcp/filesystem.h> #include <dcp/scope_guard.h> #include <zip.h> +#include <fmt/format.h> #include <boost/filesystem.hpp> #include <stdexcept> @@ -73,7 +75,7 @@ Unzipper::get(string const& filename) const { auto file = zip_fopen(_zip, filename.c_str(), 0); if (!file) { - throw runtime_error(String::compose(_("Could not find file %1 in ZIP file"), filename)); + throw runtime_error(fmt::format(_("Could not find file {} in ZIP file"), filename)); } dcp::ScopeGuard sg = [file]() { zip_fclose(file); }; diff --git a/src/lib/uploader.cc b/src/lib/uploader.cc index f2a47f50e..bd5955602 100644 --- a/src/lib/uploader.cc +++ b/src/lib/uploader.cc @@ -21,13 +21,12 @@ #include "uploader.h" #include "dcpomatic_assert.h" -#include "compose.hpp" +#include <fmt/format.h> #include "i18n.h" using std::string; -using std::shared_ptr; using std::function; @@ -76,7 +75,7 @@ Uploader::upload_directory (boost::filesystem::path base, boost::filesystem::pat if (is_directory(i.path())) { upload_directory (base, i.path(), transferred, total_size); } else { - _set_status(String::compose(_("copying %1"), i.path().filename())); + _set_status(fmt::format(_("copying {}"), i.path().filename().string())); upload_file (i.path(), remove_prefix (base, i.path()), transferred, total_size); } } diff --git a/src/lib/util.cc b/src/lib/util.cc index bc0b44dd4..01f126559 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -29,7 +29,6 @@ #include "audio_buffers.h" #include "audio_processor.h" #include "cinema_sound_processor.h" -#include "compose.hpp" #include "config.h" #include "constants.h" #include "cross.h" @@ -380,7 +379,7 @@ public: if (entry.TestFilter(m_filter)) { string buffer; entry.CreateStringWithOptions(buffer, m_options); - LOG_GENERAL("asdcplib: %1", buffer); + LOG_GENERAL("asdcplib: {}", buffer); } } }; @@ -407,7 +406,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); } @@ -458,7 +457,7 @@ LIBDCP_ENABLE_WARNINGS putenv ("PANGOCAIRO_BACKEND=fontconfig"); if (dcp::filesystem::exists(resources_path() / "fonts.conf")) { /* The actual application after installation */ - putenv(String::compose("FONTCONFIG_PATH=%1", resources_path().string()).c_str()); + putenv(fmt::format("FONTCONFIG_PATH={}", resources_path().string()).c_str()); } else { /* The place where fonts.conf is during tests */ putenv("FONTCONFIG_PATH=build\\fonts"); @@ -538,11 +537,11 @@ dcpomatic_setup_gettext_i18n (string lang) /* Override our environment language. Note that the caller must not free the string passed into putenv(). */ - string s = String::compose ("LANGUAGE=%1", lang); + string s = fmt::format("LANGUAGE={}", lang); putenv (strdup (s.c_str ())); - s = String::compose ("LANG=%1", lang); + s = fmt::format("LANG={}", lang); putenv (strdup (s.c_str ())); - s = String::compose ("LC_ALL=%1", lang); + s = fmt::format("LC_ALL={}", lang); putenv (strdup (s.c_str ())); } @@ -1029,9 +1028,9 @@ decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm) } } if (!on_chain) { - throw KDMError(variant::insert_dcpomatic(_("This KDM was not made for %1's decryption certificate.")), e.what()); + throw KDMError(variant::insert_dcpomatic(_("This KDM was not made for {}'s decryption certificate.")), e.what()); } else if (kdm_subject_name != dc->leaf().subject()) { - throw KDMError(variant::insert_dcpomatic(_("This KDM was made for %1 but not for its leaf certificate.")), e.what()); + throw KDMError(variant::insert_dcpomatic(_("This KDM was made for {} but not for its leaf certificate.")), e.what()); } else { throw; } @@ -1089,7 +1088,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()); } @@ -1193,7 +1192,7 @@ screen_names_to_string(vector<string> names) string report_problem() { - return String::compose(_("Please report this problem by using Help -> Report a problem or via email to %1"), variant::report_problem_email()); + return fmt::format(_("Please report this problem by using Help -> Report a problem or via email to {}"), variant::report_problem_email()); } diff --git a/src/lib/variant.cc b/src/lib/variant.cc index a9dc56307..81931dcf7 100644 --- a/src/lib/variant.cc +++ b/src/lib/variant.cc @@ -20,6 +20,7 @@ #include "variant.h" +#include <fmt/format.h> static char const* _dcpomatic = "DCP-o-matic"; @@ -108,19 +109,19 @@ variant::dcpomatic_verifier() std::string variant::insert_dcpomatic(std::string const& s) { - return String::compose(s, _dcpomatic); + return fmt::format(s, _dcpomatic); } std::string variant::insert_dcpomatic_encode_server(std::string const& s) { - return String::compose(s, _dcpomatic_encode_server); + return fmt::format(s, _dcpomatic_encode_server); } std::string variant::insert_dcpomatic_kdm_creator(std::string const& s) { - return String::compose(s, _dcpomatic_kdm_creator); + return fmt::format(s, _dcpomatic_kdm_creator); } std::string diff --git a/src/lib/variant.h b/src/lib/variant.h index 9a42f3eca..c7e26c1d6 100644 --- a/src/lib/variant.h +++ b/src/lib/variant.h @@ -19,7 +19,7 @@ */ -#include "compose.hpp" +#include <string> namespace variant diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index dc658144a..7fa39c89d 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -20,7 +20,6 @@ #include "colour_conversion.h" -#include "compose.hpp" #include "config.h" #include "content.h" #include "dcpomatic_log.h" @@ -332,7 +331,7 @@ VideoContent::take_from_examiner(shared_ptr<const Film> film, shared_ptr<VideoEx _pixel_quanta = pixel_quanta; } - LOG_GENERAL ("Video length obtained from header as %1 frames", _length); + LOG_GENERAL ("Video length obtained from header as {} frames", _length); if (d->video_frame_rate()) { _parent->set_video_frame_rate(film, d->video_frame_rate().get()); @@ -372,16 +371,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; @@ -456,8 +455,8 @@ VideoContent::processing_description (shared_ptr<const Film> film) char buffer[256]; if (size() && size()->width && size()->height) { - d += String::compose ( - _("Content video is %1x%2"), + d += fmt::format( + _("Content video is {}x{}"), size_after_3d_split()->width, size_after_3d_split()->height ); @@ -480,8 +479,8 @@ VideoContent::processing_description (shared_ptr<const Film> film) if ((crop.left || crop.right || crop.top || crop.bottom) && size() != dcp::Size(0, 0)) { auto const cropped = size_after_crop (); if (cropped) { - d += String::compose ( - _("\nCropped to %1x%2"), + d += fmt::format( + _("\nCropped to {}x{}"), cropped->width, cropped->height ); @@ -494,8 +493,8 @@ VideoContent::processing_description (shared_ptr<const Film> film) auto const scaled = scaled_size (container_size); if (scaled && *scaled != size_after_crop()) { - d += String::compose ( - _("\nScaled to %1x%2"), + d += fmt::format( + _("\nScaled to {}x{}"), scaled->width, scaled->height ); @@ -504,8 +503,8 @@ VideoContent::processing_description (shared_ptr<const Film> film) } if (scaled && *scaled != container_size) { - d += String::compose ( - _("\nPadded with black to fit container %1 (%2x%3)"), + d += fmt::format( + _("\nPadded with black to fit container {} ({}x{})"), film->container()->container_nickname (), container_size.width, container_size.height ); @@ -532,7 +531,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_decoder.cc b/src/lib/video_decoder.cc index c628fddd9..15c9fd8fd 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -19,13 +19,13 @@ */ -#include "compose.hpp" #include "frame_interval_checker.h" #include "image.h" #include "j2k_image_proxy.h" #include "log.h" #include "raw_image_proxy.h" #include "video_decoder.h" +#include <fmt/format.h> #include <iostream> #include "i18n.h" @@ -66,10 +66,10 @@ VideoDecoder::emit(shared_ptr<const Film> film, shared_ptr<const ImageProxy> ima if (_frame_interval_checker->guess() == FrameIntervalChecker::PROBABLY_NOT_3D && vft == VideoFrameType::THREE_D) { boost::throw_exception ( DecodeError( - String::compose( - _("The content file %1 is set as 3D but does not appear to contain 3D images. Please set it to 2D. " + 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."), - _content->path(0) + _content->path(0).string() ) ) ); diff --git a/src/lib/video_filter_graph.cc b/src/lib/video_filter_graph.cc index d5840c6d3..e78850908 100644 --- a/src/lib/video_filter_graph.cc +++ b/src/lib/video_filter_graph.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "dcpomatic_assert.h" #include "exceptions.h" #include "image.h" @@ -76,7 +75,7 @@ VideoFilterGraph::process(shared_ptr<const Image> image) int r = av_buffersrc_write_frame(_buffer_src_context, frame); if (r < 0) { - throw DecodeError(String::compose(N_("could not push buffer into filter chain (%1)."), r)); + throw DecodeError(fmt::format(N_("could not push buffer into filter chain ({})."), r)); } list<shared_ptr<const Image>> images; @@ -107,7 +106,7 @@ VideoFilterGraph::process (AVFrame* frame) } else { int r = av_buffersrc_write_frame (_buffer_src_context, frame); if (r < 0) { - throw DecodeError (String::compose(N_("could not push buffer into filter chain (%1)."), r)); + throw DecodeError(fmt::format(N_("could not push buffer into filter chain ({})."), r)); } while (true) { diff --git a/src/lib/video_filter_graph_set.cc b/src/lib/video_filter_graph_set.cc index dbae17d4c..0c966d3ac 100644 --- a/src/lib/video_filter_graph_set.cc +++ b/src/lib/video_filter_graph_set.cc @@ -48,7 +48,7 @@ VideoFilterGraphSet::get(dcp::Size size, AVPixelFormat format) new_graph->setup(_filters); _graphs.push_back(new_graph); - LOG_GENERAL(N_("New graph for %1x%2, pixel format %3"), size.width, size.height, static_cast<int>(format)); + LOG_GENERAL(N_("New graph for {}x{}, pixel format {}"), size.width, size.height, static_cast<int>(format)); return new_graph; } diff --git a/src/lib/video_mxf_content.cc b/src/lib/video_mxf_content.cc index ded81e6bf..533a12bb0 100644 --- a/src/lib/video_mxf_content.cc +++ b/src/lib/video_mxf_content.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "film.h" #include "job.h" #include "video_content.h" @@ -30,6 +29,7 @@ #include <dcp/mono_j2k_picture_asset.h> #include <dcp/stereo_j2k_picture_asset.h> #include <libxml++/libxml++.h> +#include <fmt/format.h> #include "i18n.h" @@ -103,7 +103,7 @@ VideoMXFContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job) string VideoMXFContent::summary () const { - return String::compose (_("%1 [video]"), path_summary()); + return fmt::format(_("{} [video]"), path_summary()); } diff --git a/src/lib/video_ring_buffers.cc b/src/lib/video_ring_buffers.cc index 63c52ee06..00df2f9cc 100644 --- a/src/lib/video_ring_buffers.cc +++ b/src/lib/video_ring_buffers.cc @@ -21,17 +21,17 @@ #include "video_ring_buffers.h" #include "player_video.h" -#include "compose.hpp" +#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 58a01badb..61785f558 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" @@ -397,9 +396,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 @@ -410,12 +409,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, size %1, frame %2, eyes %3"), i.info.size, i.frame, (int) i.eyes); + LOG_WARNING(N_("- type FAKE, size {}, frame {}, eyes {}"), i.info.size, i.frame, (int) i.eyes); } } } @@ -437,7 +436,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) { qi.encoded.reset (new ArrayData(film()->j2c_path(qi.reel, qi.frame, qi.eyes, false))); } @@ -445,12 +444,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.info); ++_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; @@ -483,7 +482,7 @@ try thread could erase the last item in the list. */ - LOG_GENERAL("Writer full; pushes %1 to disk while awaiting %2", item->frame, awaiting); + LOG_GENERAL("Writer full; pushes {} to disk while awaiting {}", item->frame, awaiting); item->encoded->write_via_temp( film()->j2c_path(item->reel, item->frame, item->eyes, true), @@ -626,12 +625,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); @@ -718,7 +717,7 @@ Writer::finish() dcp.write_xml(signer, !film()->limit_to_smpte_bv20(), Config::instance()->dcp_metadata_filename_format()); 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, {} pushed to disk"), _full_written, _fake_written, _repeat_written, _pushed_to_disk ); write_cover_sheet(); @@ -768,13 +767,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"); @@ -788,11 +787,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 625f3049a..52f4b5615 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 3d9d571af..c673a2099 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -61,7 +61,6 @@ #include "lib/audio_content.h" #include "lib/check_content_job.h" #include "lib/cinema.h" -#include "lib/compose.hpp" #include "lib/config.h" #include "lib/constants.h" #include "lib/content.h" @@ -1481,7 +1480,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(); } @@ -1648,7 +1647,7 @@ private: setvbuf(hf_in, NULL, _IONBF, 128); *stdin = *hf_in; - cout << variant::insert_dcpomatic("%1 is starting.") << "\n"; + cout << variant::insert_dcpomatic("{} is starting.") << "\n"; } #endif wxInitAllImageHandlers (); @@ -1725,7 +1724,7 @@ private: try { _frame->load_film (_film_to_load); } catch (exception& e) { - error_dialog (nullptr, std_to_wx(String::compose(wx_to_std(_("Could not load film %1 (%2)")), _film_to_load)), std_to_wx(e.what())); + error_dialog(nullptr, std_to_wx(fmt::format(wx_to_std(_("Could not load film {} ({})")), _film_to_load)), std_to_wx(e.what())); } } diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index 379a3c074..69e1dac1e 100644 --- a/src/tools/dcpomatic_batch.cc +++ b/src/tools/dcpomatic_batch.cc @@ -29,7 +29,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/dcpomatic_socket.h" #include "lib/film.h" @@ -53,6 +52,7 @@ LIBDCP_DISABLE_WARNINGS #include <wx/stdpaths.h> #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/format.h> #include <iostream> #include <set> @@ -493,7 +493,7 @@ class App : public wxApp } catch (exception& e) { error_dialog ( 0, - std_to_wx(String::compose(wx_to_std(_("Could not load film %1")), i.string())), + std_to_wx(fmt::format(wx_to_std(_("Could not load film {}")), i.string())), std_to_wx(e.what()) ); } diff --git a/src/tools/dcpomatic_cli.cc b/src/tools/dcpomatic_cli.cc index 7ee61ac23..908bcdc8b 100644 --- a/src/tools/dcpomatic_cli.cc +++ b/src/tools/dcpomatic_cli.cc @@ -67,7 +67,7 @@ static void help (string n) { cerr << "Syntax: " << n << " [OPTION] [<FILM>]\n" - << variant::insert_dcpomatic(" -v, --version show %1 version\n") + << variant::insert_dcpomatic(" -v, --version show {} version\n") << " -h, --help show this help\n" << " -f, --flags show flags passed to C++ compiler on build\n" << " -n, --no-progress do not print progress to stdout\n" @@ -76,7 +76,7 @@ help (string n) << " -j, --json <port> run a JSON server on the specified port\n" << " -k, --keep-going keep running even when the job is complete\n" << " -s, --servers <file> specify servers to use in a text file\n" - << variant::insert_dcpomatic(" -l, --list-servers just display a list of encoding servers that %1 is configured to use; don't encode\n") + << variant::insert_dcpomatic(" -l, --list-servers just display a list of encoding servers that {} is configured to use; don't encode\n") << " -d, --dcp-path echo DCP's path to stdout on successful completion (implies -n)\n" << " -c, --config <dir> directory containing config.xml and cinemas.xml\n" << " --dump just dump a summary of the film's settings; don't encode\n" diff --git a/src/tools/dcpomatic_combiner.cc b/src/tools/dcpomatic_combiner.cc index 890f01ad0..1125876a3 100644 --- a/src/tools/dcpomatic_combiner.cc +++ b/src/tools/dcpomatic_combiner.cc @@ -36,6 +36,7 @@ LIBDCP_DISABLE_WARNINGS #include <wx/filepicker.h> LIBDCP_ENABLE_WARNINGS #include <wx/wx.h> +#include <fmt/format.h> #include <boost/bind/bind.hpp> #include <boost/filesystem.hpp> #include <exception> @@ -161,8 +162,8 @@ private: if (!confirm_dialog ( this, std_to_wx ( - String::compose(wx_to_std(_("The directory %1 already exists and is not empty. " - "Are you sure you want to use it?")), + fmt::format(wx_to_std(_("The directory {} already exists and is not empty. " + "Are you sure you want to use it?")), output.string()) ) )) { diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc index b47addce9..55327040e 100644 --- a/src/tools/dcpomatic_disk.cc +++ b/src/tools/dcpomatic_disk.cc @@ -45,6 +45,7 @@ #include <wx/cmdline.h> #include <wx/progdlg.h> #include <wx/wx.h> +#include <fmt/format.h> LIBDCP_DISABLE_WARNINGS #include <boost/process.hpp> LIBDCP_ENABLE_WARNINGS @@ -180,7 +181,7 @@ public: */ dcpomatic_log = make_shared<FileLog>(State::write_path("disk.log")); dcpomatic_log->set_types (dcpomatic_log->types() | LogEntry::TYPE_DISK); - LOG_DISK("dcpomatic_disk %1 started", dcpomatic_git_commit); + LOG_DISK("dcpomatic_disk {} started", dcpomatic_git_commit); { int constexpr seconds_to_look = 3; @@ -201,7 +202,7 @@ public: #ifdef DCPOMATIC_WINDOWS /* We must use ::shell here, it seems, to avoid error code 740 (related to privilege escalation) */ - LOG_DISK("Starting writer process %1", disk_writer_path().string()); + LOG_DISK("Starting writer process {}", disk_writer_path().string()); _writer = new boost::process::child (disk_writer_path(), boost::process::shell, boost::process::windows::hide); #endif @@ -209,7 +210,7 @@ public: if (getenv("DCPOMATIC_NO_START_WRITER")) { LOG_DISK_NC("Not starting writer process as DCPOMATIC_NO_START_WRITER is set"); } else { - LOG_DISK("Starting writer process %1", disk_writer_path().string()); + LOG_DISK("Starting writer process {}", disk_writer_path().string()); _writer = new boost::process::child (disk_writer_path()); } #endif @@ -251,7 +252,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 @@ -302,12 +303,12 @@ private: if (reply && reply->type() == DiskWriterBackEndResponse::Type::PONG) { return true; } else if (reply) { - LOG_DISK("Unexpected response %1 to ping received (attempt %2)", static_cast<int>(reply->type()), attempt); + LOG_DISK("Unexpected response {} to ping received (attempt {})", static_cast<int>(reply->type()), attempt); } else { - LOG_DISK("No reply received from ping (attempt %1)", attempt); + LOG_DISK("No reply received from ping (attempt {})", attempt); } } else { - LOG_DISK("Could not send ping to writer (attempt %1)", attempt); + LOG_DISK("Could not send ping to writer (attempt {})", attempt); } dcpomatic_sleep_seconds (1); return false; @@ -352,7 +353,7 @@ private: return; } - LOG_DISK("Sending unmount request to disk writer for %1", drive.as_xml()); + LOG_DISK("Sending unmount request to disk writer for {}", drive.as_xml()); if (!_nanomsg.send(DISK_WRITER_UNMOUNT "\n", 2000)) { LOG_DISK_NC("Failed to send unmount request."); throw CommunicationFailedError (); diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 64c7ca7e3..3ec2ff923 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -40,7 +40,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" @@ -128,7 +127,7 @@ public: setvbuf(hf_in, NULL, _IONBF, 128); *stdin = *hf_in; - std::cout << variant::insert_dcpomatic_kdm_creator("%1 is starting.\n"); + std::cout << variant::insert_dcpomatic_kdm_creator("{} is starting.\n"); } #endif diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index ed72de172..1893b43f6 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" @@ -74,7 +73,6 @@ #include <dcp/dcp.h> #include <dcp/exceptions.h> #include <dcp/filesystem.h> -#include <dcp/raw_convert.h> #include <dcp/scope_guard.h> #include <dcp/search.h> #include <dcp/warnings.h> @@ -119,7 +117,6 @@ using boost::thread; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif -using dcp::raw_convert; using namespace dcpomatic; @@ -914,17 +911,17 @@ private: _viewer.panel()->Reparent(_dual_screen); _viewer.panel()->SetFocus(); _dual_screen->Show (); - LOG_DEBUG_PLAYER("Setting up dual screen mode with %1 displays", wxDisplay::GetCount()); + LOG_DEBUG_PLAYER("Setting up dual screen mode with {} displays", wxDisplay::GetCount()); for (auto index = 0U; index < wxDisplay::GetCount(); ++index) { wxDisplay display(index); auto client = display.GetClientArea(); auto mode = display.GetCurrentMode(); auto geometry = display.GetGeometry(); - LOG_DEBUG_PLAYER("Display %1", index); - LOG_DEBUG_PLAYER(" ClientArea position=(%1, %2) size=(%3, %4)", client.GetX(), client.GetY(), client.GetWidth(), client.GetHeight()); - LOG_DEBUG_PLAYER(" Geometry position=(%1, %2) size=(%3, %4)", geometry.GetX(), geometry.GetY(), geometry.GetWidth(), geometry.GetHeight()); - LOG_DEBUG_PLAYER(" Mode size=(%1, %2)", mode.GetWidth(), mode.GetHeight()); - LOG_DEBUG_PLAYER(" Primary? %1", static_cast<int>(display.IsPrimary())); + LOG_DEBUG_PLAYER("Display {}", index); + LOG_DEBUG_PLAYER(" ClientArea position=({}, {}) size=({}, {})", client.GetX(), client.GetY(), client.GetWidth(), client.GetHeight()); + LOG_DEBUG_PLAYER(" Geometry position=({}, {}) size=({}, {})", geometry.GetX(), geometry.GetY(), geometry.GetWidth(), geometry.GetHeight()); + LOG_DEBUG_PLAYER(" Mode size=({}, {})", mode.GetWidth(), mode.GetHeight()); + LOG_DEBUG_PLAYER(" Primary? {}", static_cast<int>(display.IsPrimary())); } if (wxDisplay::GetCount() > 1) { wxRect geometry[2] = { @@ -1091,7 +1088,7 @@ private: _http_server_thread = boost::thread(boost::bind(&HTTPServer::run, _http_server.get())); } } catch (std::exception& e) { - LOG_DEBUG_PLAYER("Failed to start player HTTP server (%1)", e.what()); + LOG_DEBUG_PLAYER("Failed to start player HTTP server ({})", e.what()); } } @@ -1105,7 +1102,7 @@ private: /* This is not the end of the world; probably a failure to bind the server socket * because there's already another player running. */ - LOG_DEBUG_PLAYER("Failed to start internal player server (%1)", e.what()); + LOG_DEBUG_PLAYER("Failed to start internal player server ({})", e.what()); } } @@ -1134,7 +1131,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 5747e89af..b4c642a69 100644 --- a/src/tools/dcpomatic_server.cc +++ b/src/tools/dcpomatic_server.cc @@ -42,6 +42,7 @@ LIBDCP_DISABLE_WARNINGS #include <wx/splash.h> #include <wx/taskbar.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/format.h> #include <boost/thread.hpp> #include <boost/optional.hpp> #include <iostream> @@ -250,7 +251,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/tools/dcpomatic_server_cli.cc b/src/tools/dcpomatic_server_cli.cc index ea78d41a5..a20b14f68 100644 --- a/src/tools/dcpomatic_server_cli.cc +++ b/src/tools/dcpomatic_server_cli.cc @@ -56,7 +56,7 @@ static void help (string n) { cerr << "Syntax: " << n << " [OPTION]\n" - << variant::insert_dcpomatic(" -v, --version show %1 version\n") + << variant::insert_dcpomatic(" -v, --version show {} version\n") << " -h, --help show this help\n" << " -t, --threads number of parallel encoding threads to use\n" << " --verbose be verbose to stdout\n" @@ -127,7 +127,7 @@ main (int argc, char* argv[]) server.run (); } catch (boost::system::system_error& e) { if (e.code() == boost::system::errc::address_in_use) { - cerr << program_name << variant::insert_dcpomatic(": address already in use. Is another %1 server instance already running?\n"); + cerr << program_name << variant::insert_dcpomatic(": address already in use. Is another {} server instance already running?\n"); exit (EXIT_FAILURE); } cerr << program_name << ": " << e.what() << "\n"; diff --git a/src/wx/about_dialog.cc b/src/wx/about_dialog.cc index 345ae2582..258a87df0 100644 --- a/src/wx/about_dialog.cc +++ b/src/wx/about_dialog.cc @@ -27,7 +27,6 @@ #include "static_text.h" #include "wx_util.h" #include "wx_variant.h" -#include "lib/compose.hpp" #include "lib/variant.h" #include "lib/version.h" #include <dcp/warnings.h> @@ -35,6 +34,7 @@ LIBDCP_DISABLE_WARNINGS #include <wx/notebook.h> #include <wx/hyperlink.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/format.h> using std::vector; @@ -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/barco_alchemy_certificate_panel.cc b/src/wx/barco_alchemy_certificate_panel.cc index 34b2aa82e..a7f470ed3 100644 --- a/src/wx/barco_alchemy_certificate_panel.cc +++ b/src/wx/barco_alchemy_certificate_panel.cc @@ -23,8 +23,8 @@ #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> #include <boost/algorithm/string.hpp> @@ -61,8 +61,8 @@ BarcoAlchemyCertificatePanel::do_download () { string serial = wx_to_std (_serial->GetValue()); trim(serial); - string url = String::compose ( - "sftp://%1:%2@certificates.barco.com/%3xxx/%4/Barco-ICMP.%5_cert.pem", + auto url = fmt::format( + "sftp://{}:{}@certificates.barco.com/{}xxx/{}/Barco-ICMP.{}_cert.pem", Config::instance()->barco_username().get(), Config::instance()->barco_password().get(), serial.substr(0, 7), diff --git a/src/wx/christie_certificate_panel.cc b/src/wx/christie_certificate_panel.cc index 3536f5045..dc2c780b8 100644 --- a/src/wx/christie_certificate_panel.cc +++ b/src/wx/christie_certificate_panel.cc @@ -18,12 +18,14 @@ */ + #include "christie_certificate_panel.h" #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; @@ -32,6 +34,7 @@ using boost::bind; using namespace boost::placeholders; #endif + ChristieCertificatePanel::ChristieCertificatePanel (DownloadCertificateDialog* dialog) : CredentialsDownloadCertificatePanel ( dialog, @@ -50,8 +53,8 @@ ChristieCertificatePanel::ChristieCertificatePanel (DownloadCertificateDialog* d void ChristieCertificatePanel::do_download () { - string const prefix = String::compose( - "ftp://%1:%2@certificates.christiedigital.com/Certificates/", + string const prefix = fmt::format( + "ftp://{}:{}@certificates.christiedigital.com/Certificates/", Config::instance()->christie_username().get(), Config::instance()->christie_password().get() ); @@ -59,7 +62,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); + string const url = fmt::format("{}F-IMB/F-IMB_{}_sha256.pem", prefix, serial); optional<string> all_errors; bool ok = true; @@ -68,7 +71,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/closed_captions_dialog.cc b/src/wx/closed_captions_dialog.cc index c8a04993c..5dcb0426a 100644 --- a/src/wx/closed_captions_dialog.cc +++ b/src/wx/closed_captions_dialog.cc @@ -23,11 +23,11 @@ #include "film_viewer.h" #include "wx_util.h" #include "lib/butler.h" -#include "lib/compose.hpp" #include "lib/constants.h" #include "lib/film.h" #include "lib/string_text.h" #include "lib/text_content.h" +#include <fmt/format.h> #include <boost/bind/bind.hpp> @@ -254,7 +254,7 @@ ClosedCaptionsDialog::update_tracks (shared_ptr<const Film> film) _track->Clear (); for (auto const& i: _tracks) { - _track->Append (std_to_wx(String::compose("%1 (%2)", i.name, i.language ? i.language->to_string() : wx_to_std(_("Unknown"))))); + _track->Append(std_to_wx(fmt::format("{} ({})", i.name, i.language ? i.language->to_string() : wx_to_std(_("Unknown"))))); } if (_track->GetCount() > 0) { 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/download_certificate_panel.cc b/src/wx/download_certificate_panel.cc index 8f826315d..9a955ca3b 100644 --- a/src/wx/download_certificate_panel.cc +++ b/src/wx/download_certificate_panel.cc @@ -22,11 +22,11 @@ #include "download_certificate_dialog.h" #include "download_certificate_panel.h" #include "wx_util.h" -#include "lib/compose.hpp" #include "lib/signal_manager.h" #include <dcp/certificate_chain.h> #include <dcp/exceptions.h> #include <dcp/util.h> +#include <fmt/format.h> #include <boost/bind/bind.hpp> @@ -64,7 +64,7 @@ DownloadCertificatePanel::load_certificate (boost::filesystem::path file, string _certificate = dcp::Certificate (dcp::file_to_string(file)); _url = url; } catch (dcp::MiscError& e) { - return String::compose(wx_to_std(_("Could not read certificate file (%1)")), e.what()); + return fmt::format(wx_to_std(_("Could not read certificate file ({})")), e.what()); } return {}; } @@ -77,7 +77,7 @@ DownloadCertificatePanel::load_certificate_from_chain (boost::filesystem::path f _certificate = dcp::CertificateChain(dcp::file_to_string(file)).leaf(); _url = url; } catch (dcp::MiscError& e) { - return String::compose(wx_to_std(_("Could not read certificate file (%1)")), e.what()); + return fmt::format(wx_to_std(_("Could not read certificate file ({})")), e.what()); } return {}; } diff --git a/src/wx/gdc_certificate_panel.cc b/src/wx/gdc_certificate_panel.cc index 7e81c5a60..f5ae0ebe7 100644 --- a/src/wx/gdc_certificate_panel.cc +++ b/src/wx/gdc_certificate_panel.cc @@ -22,9 +22,9 @@ #include "download_certificate_dialog.h" #include "gdc_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> @@ -56,8 +56,8 @@ GDCCertificatePanel::do_download () { string serial = wx_to_std (_serial->GetValue()); trim(serial); - string url = String::compose( - "ftp://%1:%2@ftp.gdc-tech.com/SHA256/%3.crt.pem", + string url = fmt::format( + "ftp://{}:{}@ftp.gdc-tech.com/SHA256/{}.crt.pem", Config::instance()->gdc_username().get(), Config::instance()->gdc_password().get(), serial diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index 81156c67c..08bbce9b7 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -37,6 +37,7 @@ #include "lib/exceptions.h" #include "lib/image.h" #include "lib/player_video.h" +#include <fmt/format.h> #include <boost/bind/bind.hpp> #include <iostream> @@ -109,7 +110,7 @@ GLVideoView::size_changed (wxSizeEvent const& ev) int const width = std::round(ev.GetSize().GetWidth() * scale); int const height = std::round(ev.GetSize().GetHeight() * scale); _canvas_size = { width, height }; - LOG_GENERAL("GLVideoView canvas size changed to %1x%2", width, height); + LOG_GENERAL("GLVideoView canvas size changed to {}x{}", width, height); Sized (); } @@ -435,7 +436,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 ({})", log).c_str(), -1); } return shader; }; @@ -463,7 +464,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 ({})", log).c_str(), -1); } glDeleteShader (vertex_shader); glDeleteShader (fragment_shader); diff --git a/src/wx/name_format_editor.cc b/src/wx/name_format_editor.cc index 166b0e145..4ecb3c302 100644 --- a/src/wx/name_format_editor.cc +++ b/src/wx/name_format_editor.cc @@ -23,7 +23,7 @@ #include "static_text.h" #include "wx_util.h" #include "lib/util.h" - +#include <fmt/format.h> using std::string; @@ -45,7 +45,7 @@ NameFormatEditor::NameFormatEditor (wxWindow* parent, dcp::NameFormat name, dcp: auto titles_sizer = new wxFlexGridSizer (2); for (auto const& i: titles) { - auto t = new StaticText (_panel, std_to_wx (String::compose ("%%%1 %2", i.first, i.second))); + auto t = new StaticText(_panel, std_to_wx(fmt::format("%{} {}", i.first, i.second))); titles_sizer->Add(t, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP); auto font = t->GetFont(); font.SetStyle (wxFONTSTYLE_ITALIC); diff --git a/src/wx/player_information.cc b/src/wx/player_information.cc index 9b8aafd18..997676663 100644 --- a/src/wx/player_information.cc +++ b/src/wx/player_information.cc @@ -23,11 +23,11 @@ #include "wx_util.h" #include "film_viewer.h" #include "lib/playlist.h" -#include "lib/compose.hpp" #include "lib/video_content.h" #include "lib/audio_content.h" #include "lib/dcp_content.h" #include "lib/film.h" +#include <fmt/format.h> using std::cout; @@ -178,8 +178,8 @@ PlayerInformation::triggered_update () vfr = dcp->video_frame_rate (); DCPOMATIC_ASSERT (vfr); - auto const len = String::compose( - wx_to_std(_("Length: %1 (%2 frames)")), + auto const len = fmt::format( + wx_to_std(_("Length: {} ({} frames)")), time_to_hmsf(dcp->full_length(_viewer.film()), lrint(*vfr)), dcp->full_length(_viewer.film()).frames_round(*vfr) ); 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/simple_video_view.cc b/src/wx/simple_video_view.cc index 84c837757..f6a9e3981 100644 --- a/src/wx/simple_video_view.cc +++ b/src/wx/simple_video_view.cc @@ -166,7 +166,7 @@ SimpleVideoView::timer () return; } - LOG_DEBUG_VIDEO_VIEW("%1 -> %2; delay %3", next.seconds(), _viewer->time().seconds(), max((next.seconds() - _viewer->time().seconds()) * 1000, 1.0)); + LOG_DEBUG_VIDEO_VIEW("{} -> {}; delay {}", next.seconds(), _viewer->time().seconds(), max((next.seconds() - _viewer->time().seconds()) * 1000, 1.0)); _timer.Start (max(1, time_until_next_frame().get_value_or(0)), wxTIMER_ONE_SHOT); if (_viewer->butler()) { diff --git a/src/wx/verify_dcp_result_panel.cc b/src/wx/verify_dcp_result_panel.cc index 57f0f21e3..36905bf13 100644 --- a/src/wx/verify_dcp_result_panel.cc +++ b/src/wx/verify_dcp_result_panel.cc @@ -111,7 +111,7 @@ VerifyDCPResultPanel::fill(shared_ptr<VerifyDCPJob> job) message.Replace(char_to_wx("%calculated_hash"), std_to_wx(note.calculated_hash().get())); } if (note.frame()) { - message.Replace(char_to_wx("%frame"), std_to_wx(dcp::fmt::to_string(note.frame().get()))); + message.Replace(char_to_wx("%frame"), std_to_wx(fmt::to_string(note.frame().get()))); message.Replace( char_to_wx("%timecode"), std_to_wx( @@ -125,13 +125,13 @@ VerifyDCPResultPanel::fill(shared_ptr<VerifyDCPJob> job) message.Replace(char_to_wx("%f"), std_to_wx(note.file()->filename().string())); } if (note.line()) { - message.Replace(char_to_wx("%l"), std_to_wx(dcp::fmt::to_string(note.line().get()))); + message.Replace(char_to_wx("%l"), std_to_wx(fmt::to_string(note.line().get()))); } if (note.component()) { - message.Replace(char_to_wx("%component"), std_to_wx(dcp::fmt::to_string(note.component().get()))); + message.Replace(char_to_wx("%component"), std_to_wx(fmt::to_string(note.component().get()))); } if (note.size()) { - message.Replace(char_to_wx("%size"), std_to_wx(dcp::fmt::to_string(note.size().get()))); + message.Replace(char_to_wx("%size"), std_to_wx(fmt::to_string(note.size().get()))); } if (note.id()) { message.Replace(char_to_wx("%id"), std_to_wx(note.id().get())); diff --git a/src/wx/video_view.cc b/src/wx/video_view.cc index c271cb65e..6f08b92c9 100644 --- a/src/wx/video_view.cc +++ b/src/wx/video_view.cc @@ -77,7 +77,7 @@ VideoView::get_next_frame (bool non_blocking) Butler::Error e; auto pv = butler->get_video (non_blocking ? Butler::Behaviour::NON_BLOCKING : Butler::Behaviour::BLOCKING, &e); if (e.code == Butler::Error::Code::DIED) { - LOG_ERROR ("Butler died with %1", e.summary()); + LOG_ERROR("Butler died with {}", e.summary()); } if (!pv.first) { return e.code == Butler::Error::Code::AGAIN ? AGAIN : FAIL; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index fc8b3dc99..66ff200cc 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -48,6 +48,7 @@ LIBDCP_DISABLE_WARNINGS #include <wx/spinctrl.h> #include <wx/splash.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/format.h> #include <boost/thread.hpp> @@ -758,7 +759,7 @@ bitmap_path (string name) wxString icon_path(string name) { - return gui_is_dark() ? bitmap_path(String::compose("%1_white.png", name)) : bitmap_path(String::compose("%1_black.png", name)); + return gui_is_dark() ? bitmap_path(fmt::format("{}_white.png", name)) : bitmap_path(fmt::format("{}_black.png", name)); } 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 185f69839..6ba713f5d 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> @@ -157,8 +158,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); @@ -171,11 +172,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) || PANGO_VERSION_CHECK(1, 52, 1) - 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 2aa81cd4f..ee0c391bd 100644 --- a/test/file_naming_test.cc +++ b/test/file_naming_test.cc @@ -32,6 +32,7 @@ #include "lib/ffmpeg_content.h" #include "lib/film.h" #include "lib/video_content.h" +#include <fmt/format.h> #ifdef DCPOMATIC_WINDOWS #include <boost/locale.hpp> #endif @@ -48,9 +49,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 fe7da7f31..08e65f5b3 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> @@ -133,7 +134,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"); } @@ -218,41 +219,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..caa2f7cc9 100644 --- a/test/markers_test.cc +++ b/test/markers_test.cc @@ -50,7 +50,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 +86,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 +116,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 cac5dffe9..a91bf6268 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(bind(PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, true), String::compose("build/test/player_seek_test_%1.png", i)); + write_image(video.first->image(bind(PlayerVideo::force, 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(bind(PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, true), String::compose("build/test/player_seek_test2_%1.png", i) + video.first->image(bind(PlayerVideo::force, 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/socket_test.cc b/test/socket_test.cc index c7d43e812..395e5f720 100644 --- a/test/socket_test.cc +++ b/test/socket_test.cc @@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE (socket_basic_test) boost::asio::io_service io_service; tcp::resolver resolver (io_service); - tcp::resolver::query query("127.0.0.1", dcp::fmt::to_string(TEST_SERVER_PORT)); + tcp::resolver::query query("127.0.0.1", fmt::to_string(TEST_SERVER_PORT)); tcp::resolver::iterator endpoint_iterator = resolver.resolve (query); auto socket = make_shared<Socket>(); @@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE (socket_digest_test1) boost::asio::io_service io_service; tcp::resolver resolver (io_service); - tcp::resolver::query query("127.0.0.1", dcp::fmt::to_string(TEST_SERVER_PORT)); + tcp::resolver::query query("127.0.0.1", fmt::to_string(TEST_SERVER_PORT)); tcp::resolver::iterator endpoint_iterator = resolver.resolve (query); shared_ptr<Socket> socket(new Socket); @@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE (socket_digest_test2) boost::asio::io_service io_service; tcp::resolver resolver (io_service); - tcp::resolver::query query("127.0.0.1", dcp::fmt::to_string(TEST_SERVER_PORT)); + tcp::resolver::query query("127.0.0.1", fmt::to_string(TEST_SERVER_PORT)); tcp::resolver::iterator endpoint_iterator = resolver.resolve (query); shared_ptr<Socket> socket(new Socket); diff --git a/test/subtitle_language_test.cc b/test/subtitle_language_test.cc index a1a45eb42..258d4f907 100644 --- a/test/subtitle_language_test.cc +++ b/test/subtitle_language_test.cc @@ -60,7 +60,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 +87,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/subtitle_reel_number_test.cc b/test/subtitle_reel_number_test.cc index 48174d012..96225617f 100644 --- a/test/subtitle_reel_number_test.cc +++ b/test/subtitle_reel_number_test.cc @@ -30,7 +30,7 @@ #include <dcp/reel.h> #include <dcp/interop_text_asset.h> #include <dcp/reel_text_asset.h> -#include <fmt/period.h> +#include <fmt/format.h> #include <boost/test/unit_test.hpp> @@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE (subtitle_reel_number_test) if (i->main_subtitle()) { auto ass = dynamic_pointer_cast<dcp::InteropTextAsset>(i->main_subtitle()->asset()); BOOST_REQUIRE (ass); - BOOST_CHECK_EQUAL(ass->reel_number(), dcp::fmt::to_string(n)); + BOOST_CHECK_EQUAL(ass->reel_number(), fmt::to_string(n)); ++n; } } diff --git a/test/test.cc b/test/test.cc index fe0286799..9d04e1b8f 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" @@ -592,7 +591,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(), @@ -734,7 +733,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)); } @@ -817,7 +816,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); } @@ -1010,13 +1009,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 27dd12cbe..dcf5cfd11 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 ()) {} |
