summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-12-23 16:30:01 +0100
committerCarl Hetherington <cth@carlh.net>2024-12-23 17:35:02 +0100
commit52d807654169d6443909c1d5dd20a155801faa26 (patch)
tree727774d21ea1f4b54ccd61a09127894cb8d572ef
parenta6ccc587277b848b4a60c07456b11eb1b076d181 (diff)
Remove String::compose and use fmt instead.
-rw-r--r--src/asset.cc1
-rw-r--r--src/asset_factory.cc6
-rw-r--r--src/asset_map.cc2
-rw-r--r--src/atmos_asset_writer.cc4
-rw-r--r--src/certificate.cc4
-rw-r--r--src/certificate_chain.cc28
-rw-r--r--src/combine.cc2
-rw-r--r--src/combine.h9
-rw-r--r--src/compose.hpp395
-rw-r--r--src/cpl.cc5
-rw-r--r--src/dcp.cc20
-rw-r--r--src/dcp.h1
-rw-r--r--src/dcp_time.cc22
-rw-r--r--src/decrypted_kdm.cc4
-rw-r--r--src/encrypted_kdm.cc4
-rw-r--r--src/exceptions.cc32
-rw-r--r--src/interop_text_asset.cc9
-rw-r--r--src/j2k_picture_asset.cc10
-rw-r--r--src/j2k_transcode.cc8
-rw-r--r--src/language_tag.cc14
-rw-r--r--src/mono_j2k_picture_asset.cc4
-rw-r--r--src/mono_j2k_picture_frame.cc4
-rw-r--r--src/mono_mpeg2_picture_frame.cc4
-rw-r--r--src/mpeg2_transcode.cc8
-rw-r--r--src/pkl.cc2
-rw-r--r--src/reel_asset.cc13
-rw-r--r--src/reel_markers_asset.cc2
-rw-r--r--src/reel_picture_asset.cc5
-rw-r--r--src/rgb_xyz.cc8
-rw-r--r--src/smpte_text_asset.cc23
-rw-r--r--src/sound_asset.cc28
-rw-r--r--src/sound_asset_writer.cc6
-rw-r--r--src/stereo_j2k_picture_frame.cc4
-rw-r--r--src/text.cc4
-rw-r--r--src/text_asset.cc18
-rw-r--r--src/text_asset_internal.cc3
-rw-r--r--src/text_string.cc26
-rw-r--r--src/types.cc7
-rw-r--r--src/util.cc6
-rw-r--r--src/verify.cc187
-rw-r--r--src/verify_j2k.cc109
-rw-r--r--src/verify_report.cc24
-rw-r--r--src/verify_report.h15
-rw-r--r--src/wscript1
-rw-r--r--test/combine_test.cc5
-rw-r--r--test/cpl_metadata_test.cc1
-rw-r--r--test/dcp_test.cc4
-rw-r--r--test/mca_test.cc14
-rw-r--r--test/test.cc10
-rw-r--r--test/verify_test.cc63
-rw-r--r--tools/dcpinfo.cc52
-rw-r--r--tools/dcpverify.cc1
52 files changed, 417 insertions, 824 deletions
diff --git a/src/asset.cc b/src/asset.cc
index ef06ea8d..411d3b13 100644
--- a/src/asset.cc
+++ b/src/asset.cc
@@ -39,7 +39,6 @@
#include "asset.h"
#include "asset_map.h"
-#include "compose.hpp"
#include "dcp_assert.h"
#include "equality_options.h"
#include "exceptions.h"
diff --git a/src/asset_factory.cc b/src/asset_factory.cc
index 652e1e31..74f18058 100644
--- a/src/asset_factory.cc
+++ b/src/asset_factory.cc
@@ -39,13 +39,13 @@
#include "asset_factory.h"
#include "atmos_asset.h"
-#include "compose.hpp"
#include "mono_j2k_picture_asset.h"
#include "mono_mpeg2_picture_asset.h"
#include "smpte_text_asset.h"
#include "sound_asset.h"
#include "stereo_j2k_picture_asset.h"
#include "stereo_j2k_picture_asset.h"
+#include <fmt/core.h>
#include <memory>
@@ -65,7 +65,7 @@ dcp::asset_factory (boost::filesystem::path path, bool ignore_incorrect_picture_
Kumu::FileReaderFactory factory;
auto const result = ASDCP::EssenceType(dcp::filesystem::fix_long_path(path).string().c_str(), type, factory);
if (!ASDCP_SUCCESS(result)) {
- throw ReadError(String::compose("Could not find essence type (%1)", result.Message()), path.string());
+ throw ReadError(fmt::format("Could not find essence type ({})", result.Message()), path.string());
}
switch (type) {
case ASDCP::ESS_UNKNOWN:
@@ -97,7 +97,7 @@ dcp::asset_factory (boost::filesystem::path path, bool ignore_incorrect_picture_
case ASDCP::ESS_DCDATA_DOLBY_ATMOS:
return make_shared<AtmosAsset>(path);
default:
- throw ReadError (String::compose("Unknown MXF essence type %1 in %2", static_cast<int>(type), path.string()));
+ throw ReadError(fmt::format("Unknown MXF essence type {} in {}", static_cast<int>(type), path.string()));
}
return {};
diff --git a/src/asset_map.cc b/src/asset_map.cc
index b8d455fe..5e427468 100644
--- a/src/asset_map.cc
+++ b/src/asset_map.cc
@@ -41,7 +41,7 @@
LIBDCP_DISABLE_WARNINGS
#include <libxml++/libxml++.h>
LIBDCP_ENABLE_WARNINGS
-#include <fmt/core.h>
+#include <fmt/format.h>
#include <boost/algorithm/string.hpp>
diff --git a/src/atmos_asset_writer.cc b/src/atmos_asset_writer.cc
index 0c895b5b..3d2c1b00 100644
--- a/src/atmos_asset_writer.cc
+++ b/src/atmos_asset_writer.cc
@@ -39,11 +39,11 @@
#include "atmos_asset.h"
#include "atmos_asset_writer.h"
-#include "compose.hpp"
#include "crypto_context.h"
#include "dcp_assert.h"
#include "exceptions.h"
#include "filesystem.h"
+#include <fmt/core.h>
#include <asdcp/AS_DCP.h>
@@ -110,7 +110,7 @@ AtmosAssetWriter::write (uint8_t const * data, int size)
auto const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _crypto_context->context(), _crypto_context->hmac());
if (ASDCP_FAILURE(r)) {
- boost::throw_exception (MiscError(String::compose("could not write atmos MXF frame (%1)", static_cast<int>(r))));
+ boost::throw_exception(MiscError(fmt::format("could not write atmos MXF frame ({})", static_cast<int>(r))));
}
++_frames_written;
diff --git a/src/certificate.cc b/src/certificate.cc
index a11e85bd..d37c98e9 100644
--- a/src/certificate.cc
+++ b/src/certificate.cc
@@ -38,7 +38,6 @@
#include "certificate.h"
-#include "compose.hpp"
#include "exceptions.h"
#include "util.h"
#include "dcp_assert.h"
@@ -48,6 +47,7 @@
#include <openssl/ssl.h>
#include <openssl/asn1.h>
#include <openssl/err.h>
+#include <fmt/core.h>
#include <boost/algorithm/string.hpp>
#include <cerrno>
#include <iostream>
@@ -470,7 +470,7 @@ Certificate::public_key () const
_public_key = EVP_PKEY_get1_RSA (key);
if (!_public_key) {
- throw MiscError (String::compose ("could not get RSA public key (%1)", ERR_error_string (ERR_get_error(), 0)));
+ throw MiscError(fmt::format("could not get RSA public key ({})", ERR_error_string (ERR_get_error(), 0)));
}
return _public_key;
diff --git a/src/certificate_chain.cc b/src/certificate_chain.cc
index 2bbddc7f..b05ea7e7 100644
--- a/src/certificate_chain.cc
+++ b/src/certificate_chain.cc
@@ -38,7 +38,6 @@
#include "certificate_chain.h"
-#include "compose.hpp"
#include "dcp_assert.h"
#include "exceptions.h"
#include "filesystem.h"
@@ -60,6 +59,7 @@ LIBDCP_ENABLE_WARNINGS
#include <openssl/pem.h>
#include <openssl/rsa.h>
#include <openssl/x509.h>
+#include <fmt/format.h>
#include <boost/algorithm/string.hpp>
#include <fstream>
#include <iostream>
@@ -116,7 +116,7 @@ command (string cmd)
int const code = WEXITSTATUS (r);
#endif
if (code) {
- throw dcp::MiscError(String::compose("error %1 in %2 within %3", code, cmd, filesystem::current_path().string()));
+ throw dcp::MiscError(fmt::format("error {} in {} within {}", code, cmd, filesystem::current_path().string()));
}
}
@@ -246,9 +246,9 @@ CertificateChain::CertificateChain (
{
command (
- String::compose (
- "%1 req -new -x509 -sha256 -config ca.cnf -days %2 -set_serial 5"
- " -subj \"%3\" -key ca.key -outform PEM -out ca.self-signed.pem",
+ fmt::format(
+ "{} req -new -x509 -sha256 -config ca.cnf -days {} -set_serial 5"
+ " -subj \"{}\" -key ca.key -outform PEM -out ca.self-signed.pem",
quoted_openssl, validity_in_days, ca_subject
)
);
@@ -280,16 +280,16 @@ CertificateChain::CertificateChain (
{
command (
- String::compose (
- "%1 req -new -config intermediate.cnf -days %2 -subj \"%3\" -key intermediate.key -out intermediate.csr",
+ fmt::format(
+ "{} req -new -config intermediate.cnf -days {} -subj \"{}\" -key intermediate.key -out intermediate.csr",
quoted_openssl, validity_in_days - 1, inter_subject
)
);
}
command (
- String::compose (
- "%1 x509 -req -sha256 -days %2 -CA ca.self-signed.pem -CAkey ca.key -set_serial 6"
+ fmt::format(
+ "{} x509 -req -sha256 -days {} -CA ca.self-signed.pem -CAkey ca.key -set_serial 6"
" -in intermediate.csr -extfile intermediate.cnf -extensions v3_ca -out intermediate.signed.pem",
quoted_openssl, validity_in_days - 1
)
@@ -321,16 +321,16 @@ CertificateChain::CertificateChain (
{
command (
- String::compose (
- "%1 req -new -config leaf.cnf -days %2 -subj \"%3\" -key leaf.key -outform PEM -out leaf.csr",
+ fmt::format(
+ "{} req -new -config leaf.cnf -days {} -subj \"{}\" -key leaf.key -outform PEM -out leaf.csr",
quoted_openssl, validity_in_days - 2, leaf_subject
)
);
}
command (
- String::compose (
- "%1 x509 -req -sha256 -days %2 -CA intermediate.signed.pem -CAkey intermediate.key"
+ fmt::format(
+ "{} x509 -req -sha256 -days {} -CA intermediate.signed.pem -CAkey intermediate.key"
" -set_serial 7 -in leaf.csr -extfile leaf.cnf -extensions v3_ca -out leaf.signed.pem",
quoted_openssl, validity_in_days - 2
)
@@ -689,7 +689,7 @@ CertificateChain::add_signature_value (xmlpp::Element* parent, string ns, bool a
}
int const r = xmlSecDSigCtxSign (signature_context, parent->cobj ());
if (r < 0) {
- throw MiscError (String::compose ("could not sign (%1)", r));
+ throw MiscError(fmt::format("could not sign ({})", r));
}
xmlSecDSigCtxDestroy (signature_context);
diff --git a/src/combine.cc b/src/combine.cc
index 3320aab2..a609a23e 100644
--- a/src/combine.cc
+++ b/src/combine.cc
@@ -46,7 +46,7 @@
#include "filesystem.h"
#include "font_asset.h"
#include "interop_text_asset.h"
-#include <fmt/core.h>
+#include <fmt/format.h>
#include <boost/filesystem.hpp>
#include <set>
#include <string>
diff --git a/src/combine.h b/src/combine.h
index b23b21be..bfeb0275 100644
--- a/src/combine.h
+++ b/src/combine.h
@@ -37,8 +37,9 @@
*/
-#include "compose.hpp"
+#include "local_time.h"
#include "version.h"
+#include <fmt/core.h>
#include <boost/filesystem.hpp>
@@ -51,10 +52,10 @@ class CertificateChain;
void combine (
std::vector<boost::filesystem::path> inputs,
boost::filesystem::path output,
- std::string issuer = String::compose("libdcp %1", dcp::version),
- std::string creator = String::compose("libdcp %1", dcp::version),
+ std::string issuer = fmt::format("libdcp {}", dcp::version),
+ std::string creator = fmt::format("libdcp {}", dcp::version),
std::string issue_date = LocalTime().as_string(),
- std::string annotation_text = String::compose("Created by libdcp %1", dcp::version),
+ std::string annotation_text = fmt::format("Created by libdcp {}", dcp::version),
std::shared_ptr<const CertificateChain> signer = std::shared_ptr<CertificateChain>()
);
diff --git a/src/compose.hpp b/src/compose.hpp
deleted file mode 100644
index 41a4075a..00000000
--- a/src/compose.hpp
+++ /dev/null
@@ -1,395 +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 STRING_COMPOSE_H
-#define STRING_COMPOSE_H
-
-#include "locale_convert.h"
-#include <boost/filesystem.hpp>
-#include <string>
-#include <list>
-#include <map>
-#include <inttypes.h>
-#include <cstdio>
-
-namespace dcp {
-
-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/cpl.cc b/src/cpl.cc
index dc3a49fe..d7734f9a 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -38,7 +38,6 @@
#include "certificate_chain.h"
-#include "compose.hpp"
#include "cpl.h"
#include "dcp_assert.h"
#include "equality_options.h"
@@ -62,7 +61,7 @@ LIBDCP_ENABLE_WARNINGS
LIBDCP_DISABLE_WARNINGS
#include <libxml++/libxml++.h>
LIBDCP_ENABLE_WARNINGS
-#include <fmt/core.h>
+#include <fmt/format.h>
#include <boost/algorithm/string.hpp>
@@ -663,7 +662,7 @@ CPL::equals(shared_ptr<const Asset> other, EqualityOptions const& opt, NoteHandl
}
if (_reels.size() != other_cpl->_reels.size()) {
- note (NoteType::ERROR, String::compose ("CPL: reel counts differ (%1 vs %2)", _reels.size(), other_cpl->_reels.size()));
+ note (NoteType::ERROR, fmt::format("CPL: reel counts differ ({} vs {})", _reels.size(), other_cpl->_reels.size()));
return false;
}
diff --git a/src/dcp.cc b/src/dcp.cc
index 742018f5..26251e4b 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -40,7 +40,6 @@
#include "asset_factory.h"
#include "atmos_asset.h"
#include "certificate_chain.h"
-#include "compose.hpp"
#include "cpl.h"
#include "dcp.h"
#include "dcp_assert.h"
@@ -72,6 +71,7 @@ LIBDCP_ENABLE_WARNINGS
LIBDCP_DISABLE_WARNINGS
#include <libxml++/libxml++.h>
LIBDCP_ENABLE_WARNINGS
+#include <fmt/core.h>
#include <boost/algorithm/string.hpp>
#include <numeric>
@@ -228,7 +228,7 @@ DCP::read (vector<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_m
p->parse_file(dcp::filesystem::fix_long_path(path).string());
} catch (std::exception& e) {
delete p;
- throw ReadError(String::compose("XML error in %1", path.string()), e.what());
+ throw ReadError(fmt::format("XML error in {}", path.string()), e.what());
}
auto const root = p->get_document()->get_root_node()->get_name();
@@ -268,7 +268,7 @@ DCP::read (vector<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_m
} else if (*pkl_type == "image/png") {
/* It's an Interop PNG subtitle; let it go */
} else {
- throw ReadError (String::compose("Unknown asset type %1 in PKL", *pkl_type));
+ throw ReadError(fmt::format("Unknown asset type {} in PKL", *pkl_type));
}
}
@@ -345,7 +345,7 @@ DCP::equals(DCP const & other, EqualityOptions const& opt, NoteHandler note) con
auto b = other.cpls ();
if (a.size() != b.size()) {
- note (NoteType::ERROR, String::compose ("CPL counts differ: %1 vs %2", a.size(), b.size()));
+ note(NoteType::ERROR, fmt::format("CPL counts differ: {} vs {}", a.size(), b.size()));
return false;
}
@@ -475,10 +475,10 @@ DCP::write_xml(shared_ptr<const CertificateChain> signer, bool include_mca_subde
_pkls.push_back(
make_shared<PKL>(
standard,
- _new_annotation_text.get_value_or(String::compose("Created by libdcp %1", dcp::version)),
+ _new_annotation_text.get_value_or(fmt::format("Created by libdcp {}", dcp::version)),
_new_issue_date.get_value_or(LocalTime().as_string()),
- _new_issuer.get_value_or(String::compose("libdcp %1", dcp::version)),
- _new_creator.get_value_or(String::compose("libdcp %1", dcp::version))
+ _new_issuer.get_value_or(fmt::format("libdcp {}", dcp::version)),
+ _new_creator.get_value_or(fmt::format("libdcp {}", dcp::version))
)
);
}
@@ -499,10 +499,10 @@ DCP::write_xml(shared_ptr<const CertificateChain> signer, bool include_mca_subde
if (!_asset_map) {
_asset_map = AssetMap(
standard,
- _new_annotation_text.get_value_or(String::compose("Created by libdcp %1", dcp::version)),
+ _new_annotation_text.get_value_or(fmt::format("Created by libdcp {}", dcp::version)),
_new_issue_date.get_value_or(LocalTime().as_string()),
- _new_issuer.get_value_or(String::compose("libdcp %1", dcp::version)),
- _new_creator.get_value_or(String::compose("libdcp %1", dcp::version))
+ _new_issuer.get_value_or(fmt::format("libdcp {}", dcp::version)),
+ _new_creator.get_value_or(fmt::format("libdcp {}", dcp::version))
);
}
diff --git a/src/dcp.h b/src/dcp.h
index 9f4c93de..8c2ac34a 100644
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -43,7 +43,6 @@
#include "asset_map.h"
#include "certificate.h"
-#include "compose.hpp"
#include "metadata.h"
#include "name_format.h"
#include "util.h"
diff --git a/src/dcp_time.cc b/src/dcp_time.cc
index f08f2b1c..22079938 100644
--- a/src/dcp_time.cc
+++ b/src/dcp_time.cc
@@ -40,8 +40,8 @@
#include "raw_convert.h"
#include "dcp_time.h"
#include "exceptions.h"
-#include "compose.hpp"
#include "dcp_assert.h"
+#include <fmt/core.h>
#include <boost/algorithm/string.hpp>
#include <boost/optional.hpp>
#include <iostream>
@@ -105,7 +105,7 @@ Time::Time (string time, optional<int> tcr_)
split (b, time, is_any_of (":"));
if (b.size() < 3 || b[0].empty() || b[1].empty() || b[0].length() > 2 || b[1].length() > 2) {
- boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1", time)));
+ boost::throw_exception(ReadError(fmt::format("unrecognised time specification {}", time)));
}
if (!tcr_) {
@@ -115,17 +115,17 @@ Time::Time (string time, optional<int> tcr_)
vector<string> bs;
split (bs, b[2], is_any_of ("."));
if (bs.size() != 2) {
- boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1", time)));
+ boost::throw_exception(ReadError(fmt::format("unrecognised time specification {}", time)));
}
h = raw_convert<int> (b[0]);
m = raw_convert<int> (b[1]);
if (bs[0].empty() || bs[0].length() > 2) {
- boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, bs[0])));
+ boost::throw_exception(ReadError(fmt::format("unrecognised time specification {}; {} has bad length", time, bs[0])));
}
s = raw_convert<int> (bs[0]);
if (bs[1].empty() || bs[1].length() > 3) {
- boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, bs[1])));
+ boost::throw_exception(ReadError(fmt::format("unrecognised time specification {}; {} has bad length", time, bs[1])));
}
e = raw_convert<int> (bs[1]);
tcr = 1000;
@@ -134,16 +134,16 @@ Time::Time (string time, optional<int> tcr_)
h = raw_convert<int> (b[0]);
m = raw_convert<int> (b[1]);
if (b[2].empty() || b[2].length() > 2) {
- boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, b[2])));
+ boost::throw_exception(ReadError(fmt::format("unrecognised time specification {}; {} has bad length", time, b[2])));
}
s = raw_convert<int> (b[2]);
if (b[3].empty() || b[3].length() > 3) {
- boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, b[3])));
+ boost::throw_exception(ReadError(fmt::format("unrecognised time specification {}; {} has bad length", time, b[3])));
}
e = raw_convert<int> (b[3]);
tcr = 250;
} else {
- boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1", time)));
+ boost::throw_exception(ReadError(fmt::format("unrecognised time specification {}", time)));
}
} else {
@@ -151,17 +151,17 @@ Time::Time (string time, optional<int> tcr_)
* It seems like there can be any number of E digits but let's just allow 2 or 3 */
split (b, time, is_any_of (":"));
if (b.size() != 4) {
- boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; does not have 4 parts", time)));
+ boost::throw_exception(ReadError(fmt::format("unrecognised time specification {}; does not have 4 parts", time)));
}
h = raw_convert<int> (b[0]);
m = raw_convert<int> (b[1]);
if (b[2].empty() || b[2].length() > 2) {
- boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, b[2])));
+ boost::throw_exception(ReadError(fmt::format("unrecognised time specification {}; {} has bad length", time, b[2])));
}
s = raw_convert<int> (b[2]);
if (b[3].empty() || b[3].length() > 3) {
- boost::throw_exception (ReadError (String::compose ("unrecognised time specification %1; %2 has bad length", time, b[3])));
+ boost::throw_exception(ReadError(fmt::format("unrecognised time specification {}; {} has bad length", time, b[3])));
}
e = raw_convert<int> (b[3]);
tcr = tcr_.get();
diff --git a/src/decrypted_kdm.cc b/src/decrypted_kdm.cc
index bf099a9a..eab1c87f 100644
--- a/src/decrypted_kdm.cc
+++ b/src/decrypted_kdm.cc
@@ -38,7 +38,6 @@
#include "certificate_chain.h"
-#include "compose.hpp"
#include "cpl.h"
#include "dcp_assert.h"
#include "decrypted_kdm.h"
@@ -53,6 +52,7 @@
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/err.h>
+#include <fmt/core.h>
using std::hex;
@@ -381,7 +381,7 @@ DecryptedKDM::encrypt (
unsigned char encrypted[RSA_size(rsa)];
int const encrypted_len = RSA_public_encrypt (p - block, block, encrypted, rsa, RSA_PKCS1_OAEP_PADDING);
if (encrypted_len == -1) {
- throw MiscError (String::compose ("Could not encrypt KDM (%1)", ERR_error_string (ERR_get_error(), 0)));
+ throw MiscError(fmt::format("Could not encrypt KDM ({})", ERR_error_string(ERR_get_error(), 0)));
}
/* Lazy overallocation */
diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc
index d1089c0b..1e1c8523 100644
--- a/src/encrypted_kdm.cc
+++ b/src/encrypted_kdm.cc
@@ -38,7 +38,6 @@
#include "certificate_chain.h"
-#include "compose.hpp"
#include "encrypted_kdm.h"
#include "exceptions.h"
#include "file.h"
@@ -48,6 +47,7 @@
#include <libxml++/document.h>
#include <libxml++/nodes/element.h>
#include <libxml/parser.h>
+#include <fmt/core.h>
#include <boost/algorithm/string.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/format.hpp>
@@ -450,7 +450,7 @@ public:
if (disable_forensic_marking_audio) {
auto mrkflg = audio_disable;
if (*disable_forensic_marking_audio > 0) {
- mrkflg += String::compose ("-above-channel-%1", *disable_forensic_marking_audio);
+ mrkflg += fmt::format("-above-channel-{}", *disable_forensic_marking_audio);
}
cxml::add_text_child(forensic_mark_flag_list, "ForensicMarkFlag", mrkflg);
}
diff --git a/src/exceptions.cc b/src/exceptions.cc
index 4420125c..aa6eb6e4 100644
--- a/src/exceptions.cc
+++ b/src/exceptions.cc
@@ -38,7 +38,7 @@
#include "exceptions.h"
-#include "compose.hpp"
+#include <fmt/core.h>
using std::string;
@@ -48,7 +48,7 @@ using namespace dcp;
FileError::FileError (string message, boost::filesystem::path filename, int number)
- : runtime_error (String::compose ("%1 (%2) (error %3)", message, filename.string(), number))
+ : runtime_error(fmt::format("{} ({}) (error {})", message, filename.string(), number))
, _filename (filename)
, _number (number)
{
@@ -57,49 +57,49 @@ FileError::FileError (string message, boost::filesystem::path filename, int numb
UnresolvedRefError::UnresolvedRefError (string id)
- : runtime_error (String::compose ("Unresolved reference to asset id %1", id))
+ : runtime_error(fmt::format("Unresolved reference to asset id {}", id))
{
}
TimeFormatError::TimeFormatError (string bad_time)
- : runtime_error (String::compose ("Bad time string %1", bad_time))
+ : runtime_error(fmt::format("Bad time string {}", bad_time))
{
}
BadContentKindError::BadContentKindError (string content_kind)
- : ReadError (String::compose("Bad content kind '%1'", content_kind))
+ : ReadError(fmt::format("Bad content kind '{}'", content_kind))
{
}
NotEncryptedError::NotEncryptedError (string const & what)
- : runtime_error (String::compose ("%1 is not encrypted", what))
+ : runtime_error(fmt::format("{} is not encrypted", what))
{
}
ProgrammingError::ProgrammingError (string file, int line)
- : runtime_error (String::compose ("Programming error at %1:%2", file, line))
+ : runtime_error(fmt::format("Programming error at {}:{}", file, line))
{
}
KDMDecryptionError::KDMDecryptionError (std::string message, int cipher_length, int modulus_dmax)
- : runtime_error (String::compose ("Could not decrypt KDM (%1) (%2/%3)", message, cipher_length, modulus_dmax))
+ : runtime_error(fmt::format("Could not decrypt KDM ({}) ({}/%3)", message, cipher_length, modulus_dmax))
{
}
KDMFormatError::KDMFormatError (std::string message)
- : runtime_error (String::compose ("Could not parse KDM (%1)", message))
+ : runtime_error(fmt::format("Could not parse KDM ({})", message))
{
}
@@ -113,7 +113,7 @@ CertificateChainError::CertificateChainError (string message)
ReadError::ReadError (string message, string detail)
- : runtime_error(String::compose("%1 (%2)", message, detail))
+ : runtime_error(fmt::format("{} ({})", message, detail))
, _message(message)
, _detail(detail)
{
@@ -122,7 +122,7 @@ ReadError::ReadError (string message, string detail)
MissingTextImageError::MissingTextImageError (string id)
- : runtime_error (String::compose("Could not load image for subtitle/caption %1", id))
+ : runtime_error(fmt::format("Could not load image for subtitle/caption {}", id))
{
}
@@ -141,7 +141,7 @@ BadKDMDateError::BadKDMDateError (bool starts_too_early)
StartCompressionError::StartCompressionError (optional<int> code)
- : runtime_error (String::compose("Could not start JPEG2000 encoding%1", code ? String::compose(" (%1)", *code) : ""))
+ : runtime_error(fmt::format("Could not start JPEG2000 encoding{}", code ? fmt::format(" ({})", *code) : ""))
, _code (code)
{}
@@ -172,14 +172,14 @@ DuplicateIdError::DuplicateIdError (std::string message)
MainSoundConfigurationError::MainSoundConfigurationError (std::string s)
- : runtime_error (String::compose("Could not parse MainSoundConfiguration %1", s))
+ : runtime_error(fmt::format("Could not parse MainSoundConfiguration {}", s))
{
}
UnknownChannelIdError::UnknownChannelIdError (std::string id)
- : runtime_error(String::compose("Unrecognised channel ID '%1'", id))
+ : runtime_error(fmt::format("Unrecognised channel ID '{}'", id))
{
}
@@ -193,7 +193,7 @@ NoReelsError::NoReelsError ()
MissingAssetmapError::MissingAssetmapError (boost::filesystem::path dir)
- : ReadError (String::compose("Could not find ASSETMAP nor ASSETMAP.xml in '%1'", dir.string()))
+ : ReadError(fmt::format("Could not find ASSETMAP nor ASSETMAP.xml in '{}'", dir.string()))
{
}
@@ -207,7 +207,7 @@ InconsistentValidityPeriodError::InconsistentValidityPeriodError()
BadURNUUIDError::BadURNUUIDError(string bad_id)
- : runtime_error(String::compose("Badly-formed URN UUID %1", bad_id))
+ : runtime_error(fmt::format("Badly-formed URN UUID {}", bad_id))
{
}
diff --git a/src/interop_text_asset.cc b/src/interop_text_asset.cc
index 4650904f..78eeb7ce 100644
--- a/src/interop_text_asset.cc
+++ b/src/interop_text_asset.cc
@@ -37,7 +37,6 @@
*/
-#include "compose.hpp"
#include "dcp_assert.h"
#include "equality_options.h"
#include "filesystem.h"
@@ -53,7 +52,7 @@
LIBDCP_DISABLE_WARNINGS
#include <libxml++/libxml++.h>
LIBDCP_ENABLE_WARNINGS
-#include <fmt/core.h>
+#include <fmt/format.h>
#include <boost/weak_ptr.hpp>
#include <cmath>
#include <cstdio>
@@ -96,7 +95,7 @@ InteropTextAsset::InteropTextAsset(boost::filesystem::path file)
for (auto i: _texts) {
auto si = dynamic_pointer_cast<TextImage>(i);
if (si) {
- si->read_png_file (file.parent_path() / String::compose("%1.png", si->id()));
+ si->read_png_file (file.parent_path() / fmt::format("{}.png", si->id()));
}
}
}
@@ -136,7 +135,7 @@ void
InteropTextAsset::add_font(string load_id, dcp::ArrayData data)
{
_fonts.push_back (Font(load_id, make_uuid(), data));
- auto const uri = String::compose("font_%1.ttf", _load_font_nodes.size());
+ auto const uri = fmt::format("font_{}.ttf", _load_font_nodes.size());
_load_font_nodes.push_back (make_shared<InteropLoadFontNode>(load_id, uri));
}
@@ -208,7 +207,7 @@ InteropTextAsset::write(boost::filesystem::path p) const
/* Image subtitles */
for (auto i: _texts) {
if (auto im = dynamic_pointer_cast<dcp::TextImage>(i)) {
- im->write_png_file(p.parent_path() / String::compose("%1.png", im->id()));
+ im->write_png_file(p.parent_path() / fmt::format("{}.png", im->id()));
}
}
diff --git a/src/j2k_picture_asset.cc b/src/j2k_picture_asset.cc
index 98792253..8f539a62 100644
--- a/src/j2k_picture_asset.cc
+++ b/src/j2k_picture_asset.cc
@@ -37,7 +37,6 @@
*/
-#include "compose.hpp"
#include "dcp_assert.h"
#include "equality_options.h"
#include "exceptions.h"
@@ -49,6 +48,7 @@
#include <asdcp/AS_DCP.h>
#include <asdcp/KM_fileio.h>
#include <libxml++/nodes/element.h>
+#include <fmt/core.h>
#include <boost/filesystem.hpp>
#include <list>
#include <stdexcept>
@@ -158,7 +158,7 @@ J2KPictureAsset::frame_buffer_equals (
for (int c = 0; c < 3; ++c) {
if (image_A->size() != image_B->size()) {
- note (NoteType::ERROR, String::compose ("image sizes for frame %1 differ", frame));
+ note(NoteType::ERROR, fmt::format("image sizes for frame {} differ", frame));
return false;
}
@@ -184,12 +184,12 @@ J2KPictureAsset::frame_buffer_equals (
auto const std_dev = sqrt (double (total_squared_deviation) / abs_diffs.size());
- note (NoteType::NOTE, String::compose("mean difference %1 deviation %2", mean, std_dev));
+ note(NoteType::NOTE, fmt::format("mean difference {} deviation {}", mean, std_dev));
if (mean > opt.max_mean_pixel_error) {
note (
NoteType::ERROR,
- String::compose ("mean %1 out of range %2 in frame %3", mean, opt.max_mean_pixel_error, frame)
+ fmt::format("mean {} out of range {} in frame {}", mean, opt.max_mean_pixel_error, frame)
);
return false;
@@ -198,7 +198,7 @@ J2KPictureAsset::frame_buffer_equals (
if (std_dev > opt.max_std_dev_pixel_error) {
note (
NoteType::ERROR,
- String::compose ("standard deviation %1 out of range %2 in frame %3", std_dev, opt.max_std_dev_pixel_error, frame)
+ fmt::format("standard deviation {} out of range {} in frame {}", std_dev, opt.max_std_dev_pixel_error, frame)
);
return false;
diff --git a/src/j2k_transcode.cc b/src/j2k_transcode.cc
index 664d18a3..4b30230d 100644
--- a/src/j2k_transcode.cc
+++ b/src/j2k_transcode.cc
@@ -42,8 +42,8 @@
#include "exceptions.h"
#include "openjpeg_image.h"
#include "dcp_assert.h"
-#include "compose.hpp"
#include <openjpeg.h>
+#include <fmt/core.h>
#include <cmath>
#include <iostream>
@@ -170,9 +170,9 @@ dcp::decompress_j2k (uint8_t const * data, int64_t size, int reduce)
opj_destroy_codec (decoder);
opj_stream_destroy (stream);
if (format == OPJ_CODEC_J2K) {
- boost::throw_exception (ReadError (String::compose ("could not decode JPEG2000 codestream of %1 bytes.", size)));
+ boost::throw_exception(ReadError(fmt::format("could not decode JPEG2000 codestream of {} bytes.", size)));
} else {
- boost::throw_exception (ReadError (String::compose ("could not decode JP2 file of %1 bytes.", size)));
+ boost::throw_exception(ReadError(fmt::format("could not decode JP2 file of {} bytes.", size)));
}
}
@@ -280,7 +280,7 @@ dcp::compress_j2k (shared_ptr<const OpenJPEGImage> xyz, int bandwidth, int frame
opj_setup_encoder (encoder, &parameters, xyz->opj_image());
#ifndef LIBDCP_HAVE_NUMGBITS
- string numgbits = String::compose("GUARD_BITS=%1", fourk ? 2 : 1);
+ string numgbits = fmt::format("GUARD_BITS={}", fourk ? 2 : 1);
char const* extra_options[] = { numgbits.c_str(), nullptr };
opj_encoder_set_extra_options(encoder, extra_options);
#endif
diff --git a/src/language_tag.cc b/src/language_tag.cc
index 037814f9..af758cc1 100644
--- a/src/language_tag.cc
+++ b/src/language_tag.cc
@@ -37,11 +37,11 @@
*/
-#include "compose.hpp"
#include "dcp_assert.h"
#include "exceptions.h"
#include "file.h"
#include "language_tag.h"
+#include <fmt/core.h>
#include <boost/algorithm/string.hpp>
#include <string>
@@ -83,7 +83,7 @@ LanguageTag::Subtag::Subtag (string subtag, SubtagType type)
: _subtag (subtag)
{
if (!get_subtag_data(type, subtag)) {
- throw LanguageTagError(String::compose("Unknown %1 string %2", subtag_type_name(type), subtag));
+ throw LanguageTagError(fmt::format("Unknown {} string {}", subtag_type_name(type), subtag));
}
}
@@ -93,7 +93,7 @@ LanguageTag::LanguageTag (string tag)
vector<string> parts;
boost::split (parts, tag, boost::is_any_of("-"));
if (parts.empty()) {
- throw LanguageTagError (String::compose("Could not parse language tag %1", tag));
+ throw LanguageTagError(fmt::format("Could not parse language tag {}", tag));
}
vector<string>::size_type p = 0;
@@ -143,7 +143,7 @@ LanguageTag::LanguageTag (string tag)
} catch (...) {}
if (p < parts.size()) {
- throw LanguageTagError (String::compose("Unrecognised subtag %1", parts[p]));
+ throw LanguageTagError(fmt::format("Unrecognised subtag {}", parts[p]));
}
}
@@ -202,7 +202,7 @@ void
LanguageTag::add_variant (VariantSubtag variant)
{
if (find(_variants.begin(), _variants.end(), variant) != _variants.end()) {
- throw LanguageTagError (String::compose("Duplicate Variant subtag %1", variant.subtag()));
+ throw LanguageTagError(fmt::format("Duplicate Variant subtag {}", variant.subtag()));
}
_variants.push_back (variant);
@@ -218,7 +218,7 @@ check_for_duplicates (vector<T> const& subtags, dcp::LanguageTag::SubtagType typ
optional<T> last;
for (auto const& i: sorted) {
if (last && i == *last) {
- throw LanguageTagError (String::compose("Duplicate %1 subtag %2", dcp::LanguageTag::subtag_type_name(type), i.subtag()));
+ throw LanguageTagError(fmt::format("Duplicate {} subtag {}", dcp::LanguageTag::subtag_type_name(type), i.subtag()));
}
last = i;
}
@@ -237,7 +237,7 @@ void
LanguageTag::add_extlang (ExtlangSubtag extlang)
{
if (find(_extlangs.begin(), _extlangs.end(), extlang) != _extlangs.end()) {
- throw LanguageTagError (String::compose("Duplicate Extlang subtag %1", extlang.subtag()));
+ throw LanguageTagError(fmt::format("Duplicate Extlang subtag {}", extlang.subtag()));
}
_extlangs.push_back (extlang);
diff --git a/src/mono_j2k_picture_asset.cc b/src/mono_j2k_picture_asset.cc
index b1f311d6..b76ef708 100644
--- a/src/mono_j2k_picture_asset.cc
+++ b/src/mono_j2k_picture_asset.cc
@@ -37,7 +37,6 @@
*/
-#include "compose.hpp"
#include "dcp_assert.h"
#include "equality_options.h"
#include "exceptions.h"
@@ -48,6 +47,7 @@
#include "mono_j2k_picture_frame.h"
#include <asdcp/AS_DCP.h>
#include <asdcp/KM_fileio.h>
+#include <fmt/core.h>
#include <boost/bind/bind.hpp>
@@ -175,7 +175,7 @@ MonoJ2KPictureAsset::equals(shared_ptr<const Asset> other, EqualityOptions const
#pragma omp critical
#endif
{
- note (NoteType::PROGRESS, String::compose("Compared video frame %1 of %2", i, _intrinsic_duration));
+ note(NoteType::PROGRESS, fmt::format("Compared video frame {} of {}", i, _intrinsic_duration));
for (auto const& i: notes) {
note (i.first, i.second);
}
diff --git a/src/mono_j2k_picture_frame.cc b/src/mono_j2k_picture_frame.cc
index 69ba9a59..4b105176 100644
--- a/src/mono_j2k_picture_frame.cc
+++ b/src/mono_j2k_picture_frame.cc
@@ -38,7 +38,6 @@
#include "colour_conversion.h"
-#include "compose.hpp"
#include "crypto_context.h"
#include "exceptions.h"
#include "file.h"
@@ -49,6 +48,7 @@
#include "util.h"
#include <asdcp/KM_fileio.h>
#include <asdcp/AS_DCP.h>
+#include <fmt/core.h>
using std::make_shared;
@@ -89,7 +89,7 @@ MonoJ2KPictureFrame::MonoJ2KPictureFrame (ASDCP::JP2K::MXFReader* reader, int n,
auto const r = reader->ReadFrame (n, *_buffer, c->context(), check_hmac ? c->hmac() : nullptr);
if (ASDCP_FAILURE(r)) {
- boost::throw_exception (ReadError(String::compose ("could not read video frame %1 (%2)", n, static_cast<int>(r))));
+ boost::throw_exception(ReadError(fmt::format("could not read video frame {} ({})", n, static_cast<int>(r))));
}
}
diff --git a/src/mono_mpeg2_picture_frame.cc b/src/mono_mpeg2_picture_frame.cc
index 3c79a94c..a3585657 100644
--- a/src/mono_mpeg2_picture_frame.cc
+++ b/src/mono_mpeg2_picture_frame.cc
@@ -32,8 +32,8 @@
*/
-#include "compose.hpp"
#include "mono_mpeg2_picture_frame.h"
+#include <fmt/core.h>
using std::make_shared;
@@ -64,7 +64,7 @@ MonoMPEG2PictureFrame::MonoMPEG2PictureFrame(ASDCP::MPEG2::MXFReader* reader, in
auto const r = reader->ReadFrame(n, *_buffer, context->context(), check_hmac ? context->hmac() : nullptr);
if (ASDCP_FAILURE(r)) {
- boost::throw_exception(ReadError(String::compose("could not read video frame %1 (%2)", n, static_cast<int>(r))));
+ boost::throw_exception(ReadError(fmt::format("could not read video frame {} ({})", n, static_cast<int>(r))));
}
}
diff --git a/src/mpeg2_transcode.cc b/src/mpeg2_transcode.cc
index 0ac2c1af..95a15af8 100644
--- a/src/mpeg2_transcode.cc
+++ b/src/mpeg2_transcode.cc
@@ -32,7 +32,6 @@
*/
-#include "compose.hpp"
#include "exceptions.h"
#include "mono_mpeg2_picture_frame.h"
#include "mpeg2_transcode.h"
@@ -40,6 +39,7 @@
extern "C" {
#include <libavcodec/avcodec.h>
}
+#include <fmt/core.h>
using std::make_shared;
@@ -121,7 +121,7 @@ MPEG2Decompressor::decompress_packet(AVPacket* packet)
{
int const r = avcodec_send_packet(_context, packet);
if (r < 0) {
- throw MPEG2DecompressionError(String::compose("avcodec_send_packet failed (%1)", r));
+ throw MPEG2DecompressionError(fmt::format("avcodec_send_packet failed ({})", r));
}
vector<FFmpegImage> images;
@@ -176,7 +176,7 @@ MPEG2Compressor::send_and_receive(AVFrame const* frame)
{
int r = avcodec_send_frame(_context, frame);
if (r < 0) {
- throw MPEG2CompressionError(String::compose("avcodec_send_frame failed (%1", r));
+ throw MPEG2CompressionError(fmt::format("avcodec_send_frame failed ({})", r));
}
auto packet = av_packet_alloc();
@@ -186,7 +186,7 @@ MPEG2Compressor::send_and_receive(AVFrame const* frame)
r = avcodec_receive_packet(_context, packet);
if (r < 0 && r != AVERROR(EAGAIN)) {
- throw MPEG2CompressionError(String::compose("avcodec_receive_packet failed (%1)", r));
+ throw MPEG2CompressionError(fmt::format("avcodec_receive_packet failed ({})", r));
}
ScopeGuard sg = [&packet]() {
diff --git a/src/pkl.cc b/src/pkl.cc
index 94befed0..08d1f66b 100644
--- a/src/pkl.cc
+++ b/src/pkl.cc
@@ -47,7 +47,7 @@
LIBDCP_DISABLE_WARNINGS
#include <libxml++/libxml++.h>
LIBDCP_ENABLE_WARNINGS
-#include <fmt/core.h>
+#include <fmt/format.h>
#include <iostream>
diff --git a/src/reel_asset.cc b/src/reel_asset.cc
index 46812e49..9e52dfaa 100644
--- a/src/reel_asset.cc
+++ b/src/reel_asset.cc
@@ -38,7 +38,6 @@
#include "asset.h"
-#include "compose.hpp"
#include "dcp_assert.h"
#include "equality_options.h"
#include "reel_asset.h"
@@ -47,7 +46,7 @@
LIBDCP_DISABLE_WARNINGS
#include <libxml++/libxml++.h>
LIBDCP_ENABLE_WARNINGS
-#include <fmt/core.h>
+#include <fmt/format.h>
using std::make_pair;
@@ -141,7 +140,7 @@ ReelAsset::asset_equals(shared_ptr<const ReelAsset> other, EqualityOptions const
auto const node = cpl_node_name();
if (_annotation_text != other->_annotation_text) {
- string const s = String::compose("Reel %1: annotation texts differ (%2 vs %3)", node, optional_to_string(_annotation_text), optional_to_string(other->_annotation_text));
+ string const s = fmt::format("Reel {}: annotation texts differ ({} vs {})", node, optional_to_string(_annotation_text), optional_to_string(other->_annotation_text));
if (!opt.reel_annotation_texts_can_differ) {
note (NoteType::ERROR, s);
return false;
@@ -153,7 +152,7 @@ ReelAsset::asset_equals(shared_ptr<const ReelAsset> other, EqualityOptions const
if (_edit_rate != other->_edit_rate) {
note (
NoteType::ERROR,
- String::compose("Reel %1: edit rates differ (%2 vs %3)", node, _edit_rate.as_string(), other->_edit_rate.as_string())
+ fmt::format("Reel {}: edit rates differ ({} vs {})", node, _edit_rate.as_string(), other->_edit_rate.as_string())
);
return false;
}
@@ -161,7 +160,7 @@ ReelAsset::asset_equals(shared_ptr<const ReelAsset> other, EqualityOptions const
if (_intrinsic_duration != other->_intrinsic_duration) {
note (
NoteType::ERROR,
- String::compose("Reel %1: intrinsic durations differ (%2 vs %3)", node, _intrinsic_duration, other->_intrinsic_duration)
+ fmt::format("Reel {}: intrinsic durations differ ({} vs {})", node, _intrinsic_duration, other->_intrinsic_duration)
);
return false;
}
@@ -169,7 +168,7 @@ ReelAsset::asset_equals(shared_ptr<const ReelAsset> other, EqualityOptions const
if (_entry_point != other->_entry_point) {
note (
NoteType::ERROR,
- String::compose("Reel %1: entry points differ (%2 vs %3)", node, optional_to_string(_entry_point), optional_to_string(other->_entry_point))
+ fmt::format("Reel {}: entry points differ ({} vs {})", node, optional_to_string(_entry_point), optional_to_string(other->_entry_point))
);
return false;
}
@@ -177,7 +176,7 @@ ReelAsset::asset_equals(shared_ptr<const ReelAsset> other, EqualityOptions const
if (_duration != other->_duration) {
note (
NoteType::ERROR,
- String::compose("Reel %1: durations differ (%2 vs %3)", node, optional_to_string(_duration), optional_to_string(other->_duration))
+ fmt::format("Reel {}: durations differ ({} vs {})", node, optional_to_string(_duration), optional_to_string(other->_duration))
);
return false;
}
diff --git a/src/reel_markers_asset.cc b/src/reel_markers_asset.cc
index 91d8948d..f1c5bfd5 100644
--- a/src/reel_markers_asset.cc
+++ b/src/reel_markers_asset.cc
@@ -43,7 +43,7 @@
LIBDCP_DISABLE_WARNINGS
#include <libxml++/libxml++.h>
LIBDCP_ENABLE_WARNINGS
-#include <fmt/core.h>
+#include <fmt/format.h>
using std::string;
diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc
index cd6fef44..180a2fd4 100644
--- a/src/reel_picture_asset.cc
+++ b/src/reel_picture_asset.cc
@@ -37,7 +37,6 @@
*/
-#include "compose.hpp"
#include "dcp_assert.h"
#include "j2k_picture_asset.h"
#include "reel_picture_asset.h"
@@ -91,7 +90,7 @@ ReelPictureAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
{
auto asset = ReelFileAsset::write_to_cpl (node, standard);
- cxml::add_text_child(asset, "FrameRate", String::compose("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
+ cxml::add_text_child(asset, "FrameRate", fmt::format("{} {}", _frame_rate.numerator, _frame_rate.denominator));
if (standard == Standard::INTEROP) {
@@ -118,7 +117,7 @@ ReelPictureAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
cxml::add_text_child(
asset,
"ScreenAspectRatio",
- String::compose("%1 %2", _screen_aspect_ratio.numerator, _screen_aspect_ratio.denominator)
+ fmt::format("{} {}", _screen_aspect_ratio.numerator, _screen_aspect_ratio.denominator)
);
}
diff --git a/src/rgb_xyz.cc b/src/rgb_xyz.cc
index c9854107..28a18441 100644
--- a/src/rgb_xyz.cc
+++ b/src/rgb_xyz.cc
@@ -38,12 +38,12 @@
#include "colour_conversion.h"
-#include "compose.hpp"
#include "dcp_assert.h"
#include "openjpeg_image.h"
#include "piecewise_lut.h"
#include "rgb_xyz.h"
#include "transfer_function.h"
+#include <fmt/core.h>
#include <cmath>
@@ -181,21 +181,21 @@ dcp::xyz_to_rgb (
if (cx < 0 || cx > 4095) {
if (note) {
- note.get()(NoteType::NOTE, String::compose("XYZ value %1 out of range", cx));
+ note.get()(NoteType::NOTE, fmt::format("XYZ value {} out of range", cx));
}
cx = max (min (cx, 4095), 0);
}
if (cy < 0 || cy > 4095) {
if (note) {
- note.get()(NoteType::NOTE, String::compose("XYZ value %1 out of range", cy));
+ note.get()(NoteType::NOTE, fmt::format("XYZ value {} out of range", cy));
}
cy = max (min (cy, 4095), 0);
}
if (cz < 0 || cz > 4095) {
if (note) {
- note.get()(NoteType::NOTE, String::compose("XYZ value %1 out of range", cz));
+ note.get()(NoteType::NOTE, fmt::format("XYZ value {} out of range", cz));
}
cz = max (min (cz, 4095), 0);
}
diff --git a/src/smpte_text_asset.cc b/src/smpte_text_asset.cc
index 18ea27d9..e37359f9 100644
--- a/src/smpte_text_asset.cc
+++ b/src/smpte_text_asset.cc
@@ -37,7 +37,6 @@
*/
-#include "compose.hpp"
#include "crypto_context.h"
#include "dcp_assert.h"
#include "equality_options.h"
@@ -56,7 +55,7 @@ LIBDCP_DISABLE_WARNINGS
#include <asdcp/KM_log.h>
#include <libxml++/libxml++.h>
LIBDCP_ENABLE_WARNINGS
-#include <fmt/core.h>
+#include <fmt/format.h>
#include <boost/algorithm/string.hpp>
@@ -130,9 +129,9 @@ SMPTETextAsset::SMPTETextAsset(boost::filesystem::path file)
} catch (cxml::Error& e) {
boost::throw_exception (
ReadError (
- String::compose (
- "Failed to read subtitle file %1; MXF failed with %2, XML failed with %3",
- file, static_cast<int>(r), e.what()
+ fmt::format(
+ "Failed to read subtitle file {}; MXF failed with {}, XML failed with {}",
+ file.string(), static_cast<int>(r), e.what()
)
)
);
@@ -145,11 +144,11 @@ SMPTETextAsset::SMPTETextAsset(boost::filesystem::path file)
auto im = dynamic_pointer_cast<TextImage>(i);
if (im && im->png_image().size() == 0) {
/* Even more dubious; allow <id>.png or urn:uuid:<id>.png */
- auto p = file.parent_path() / String::compose("%1.png", im->id());
+ auto p = file.parent_path() / fmt::format("{}.png", im->id());
if (filesystem::is_regular_file(p)) {
im->read_png_file (p);
} else if (starts_with (im->id(), "urn:uuid:")) {
- p = file.parent_path() / String::compose("%1.png", remove_urn_uuid(im->id()));
+ p = file.parent_path() / fmt::format("{}.png", remove_urn_uuid(im->id()));
if (filesystem::is_regular_file(p)) {
im->read_png_file (p);
}
@@ -241,11 +240,11 @@ SMPTETextAsset::read_mxf_resources(shared_ptr<ASDCP::TimedText::MXFReader> reade
if (ASDCP_FAILURE(result)) {
switch (i->Type) {
case ASDCP::TimedText::MT_OPENTYPE:
- throw ReadError(String::compose("Could not read font from MXF file (%1)", static_cast<int>(result)));
+ throw ReadError(fmt::format("Could not read font from MXF file ({})", static_cast<int>(result)));
case ASDCP::TimedText::MT_PNG:
- throw ReadError(String::compose("Could not read subtitle image from MXF file (%1)", static_cast<int>(result)));
+ throw ReadError(fmt::format("Could not read subtitle image from MXF file ({})", static_cast<int>(result)));
default:
- throw ReadError(String::compose("Could not read resource from MXF file (%1)", static_cast<int>(result)));
+ throw ReadError(fmt::format("Could not read resource from MXF file ({})", static_cast<int>(result)));
}
}
@@ -328,7 +327,7 @@ SMPTETextAsset::set_key(Key key)
if (ASDCP_FAILURE (r)) {
boost::throw_exception (
ReadError (
- String::compose ("Could not read encrypted subtitle MXF (%1)", static_cast<int> (r))
+ fmt::format("Could not read encrypted subtitle MXF ({})", static_cast<int> (r))
)
);
}
@@ -544,7 +543,7 @@ SMPTETextAsset::equals(shared_ptr<const Asset> other_asset, EqualityOptions cons
}
if (_language != other->_language) {
- note (NoteType::ERROR, String::compose("Subtitle/caption languages differ (`%1' vs `%2')", _language.get_value_or("[none]"), other->_language.get_value_or("[none]")));
+ note(NoteType::ERROR, fmt::format("Subtitle/caption languages differ (`{}' vs `{}')", _language.get_value_or("[none]"), other->_language.get_value_or("[none]")));
return false;
}
diff --git a/src/sound_asset.cc b/src/sound_asset.cc
index c73255b8..c62f11f2 100644
--- a/src/sound_asset.cc
+++ b/src/sound_asset.cc
@@ -37,7 +37,6 @@
*/
-#include "compose.hpp"
#include "dcp_assert.h"
#include "equality_options.h"
#include "exceptions.h"
@@ -54,6 +53,7 @@ LIBDCP_DISABLE_WARNINGS
#include <asdcp/Metadata.h>
LIBDCP_ENABLE_WARNINGS
#include <libxml++/nodes/element.h>
+#include <fmt/core.h>
#include <boost/filesystem.hpp>
#include <stdexcept>
@@ -166,8 +166,8 @@ SoundAsset::equals(shared_ptr<const Asset> other, EqualityOptions const& opt, No
if (desc_A.EditRate != desc_B.EditRate) {
note (
NoteType::ERROR,
- String::compose (
- "audio edit rates differ: %1/%2 cf %3/%4",
+ fmt::format(
+ "audio edit rates differ: {}/{} cf {}/%4",
desc_A.EditRate.Numerator, desc_A.EditRate.Denominator, desc_B.EditRate.Numerator, desc_B.EditRate.Denominator
)
);
@@ -175,33 +175,33 @@ SoundAsset::equals(shared_ptr<const Asset> other, EqualityOptions const& opt, No
} else if (desc_A.AudioSamplingRate != desc_B.AudioSamplingRate) {
note (
NoteType::ERROR,
- String::compose (
- "audio sampling rates differ: %1 cf %2",
+ fmt::format(
+ "audio sampling rates differ: {} cf {}",
desc_A.AudioSamplingRate.Numerator, desc_A.AudioSamplingRate.Denominator,
desc_B.AudioSamplingRate.Numerator, desc_B.AudioSamplingRate.Numerator
)
);
return false;
} else if (desc_A.Locked != desc_B.Locked) {
- note (NoteType::ERROR, String::compose ("audio locked flags differ: %1 cf %2", desc_A.Locked, desc_B.Locked));
+ note(NoteType::ERROR, fmt::format("audio locked flags differ: {} cf {}", desc_A.Locked, desc_B.Locked));
return false;
} else if (desc_A.ChannelCount != desc_B.ChannelCount) {
- note (NoteType::ERROR, String::compose ("audio channel counts differ: %1 cf %2", desc_A.ChannelCount, desc_B.ChannelCount));
+ note(NoteType::ERROR, fmt::format("audio channel counts differ: {} cf {}", desc_A.ChannelCount, desc_B.ChannelCount));
return false;
} else if (desc_A.QuantizationBits != desc_B.QuantizationBits) {
- note (NoteType::ERROR, String::compose ("audio bits per sample differ: %1 cf %2", desc_A.QuantizationBits, desc_B.QuantizationBits));
+ note(NoteType::ERROR, fmt::format("audio bits per sample differ: {} cf {}", desc_A.QuantizationBits, desc_B.QuantizationBits));
return false;
} else if (desc_A.BlockAlign != desc_B.BlockAlign) {
- note (NoteType::ERROR, String::compose ("audio bytes per sample differ: %1 cf %2", desc_A.BlockAlign, desc_B.BlockAlign));
+ note(NoteType::ERROR, fmt::format("audio bytes per sample differ: {} cf {}", desc_A.BlockAlign, desc_B.BlockAlign));
return false;
} else if (desc_A.AvgBps != desc_B.AvgBps) {
- note (NoteType::ERROR, String::compose ("audio average bps differ: %1 cf %2", desc_A.AvgBps, desc_B.AvgBps));
+ note(NoteType::ERROR, fmt::format("audio average bps differ: {} cf {}", desc_A.AvgBps, desc_B.AvgBps));
return false;
} else if (desc_A.LinkedTrackID != desc_B.LinkedTrackID) {
- note (NoteType::ERROR, String::compose ("audio linked track IDs differ: %1 cf %2", desc_A.LinkedTrackID, desc_B.LinkedTrackID));
+ note(NoteType::ERROR, fmt::format("audio linked track IDs differ: {} cf {}", desc_A.LinkedTrackID, desc_B.LinkedTrackID));
return false;
} else if (desc_A.ContainerDuration != desc_B.ContainerDuration) {
- note (NoteType::ERROR, String::compose ("audio container durations differ: %1 cf %2", desc_A.ContainerDuration, desc_B.ContainerDuration));
+ note(NoteType::ERROR, fmt::format("audio container durations differ: {} cf {}", desc_A.ContainerDuration, desc_B.ContainerDuration));
return false;
} else if (desc_A.ChannelFormat != desc_B.ChannelFormat) {
/* XXX */
@@ -218,7 +218,7 @@ SoundAsset::equals(shared_ptr<const Asset> other, EqualityOptions const& opt, No
auto frame_B = other_reader->get_frame (i);
if (frame_A->size() != frame_B->size()) {
- note (NoteType::ERROR, String::compose ("sizes of audio data for frame %1 differ", i));
+ note(NoteType::ERROR, fmt::format("sizes of audio data for frame {} differ", i));
return false;
}
@@ -227,7 +227,7 @@ SoundAsset::equals(shared_ptr<const Asset> other, EqualityOptions const& opt, No
for (int channel = 0; channel < frame_A->channels(); ++channel) {
int32_t const d = abs(frame_A->get(channel, sample) - frame_B->get(channel, sample));
if (d > opt.max_audio_sample_error) {
- note (NoteType::ERROR, String::compose("PCM data difference of %1 in frame %2, channel %3, sample %4", d, i, channel, sample));
+ note(NoteType::ERROR, fmt::format("PCM data difference of {} in frame {}, channel {}, sample %4", d, i, channel, sample));
return false;
}
}
diff --git a/src/sound_asset_writer.cc b/src/sound_asset_writer.cc
index 3ea2243b..60a3217f 100644
--- a/src/sound_asset_writer.cc
+++ b/src/sound_asset_writer.cc
@@ -38,7 +38,6 @@
#include "bitstream.h"
-#include "compose.hpp"
#include "crypto_context.h"
#include "dcp_assert.h"
#include "exceptions.h"
@@ -50,6 +49,7 @@ LIBDCP_DISABLE_WARNINGS
#include <asdcp/AS_DCP.h>
#include <asdcp/Metadata.h>
LIBDCP_ENABLE_WARNINGS
+#include <fmt/core.h>
#include <iostream>
@@ -261,7 +261,7 @@ SoundAssetWriter::write_current_frame ()
{
auto const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _crypto_context->context(), _crypto_context->hmac());
if (ASDCP_FAILURE(r)) {
- boost::throw_exception (MiscError(String::compose("could not write audio MXF frame (%1)", static_cast<int>(r))));
+ boost::throw_exception(MiscError(fmt::format("could not write audio MXF frame ({})", static_cast<int>(r))));
}
++_frames_written;
@@ -282,7 +282,7 @@ SoundAssetWriter::finalize ()
if (_started) {
auto const r = _state->mxf_writer.Finalize();
if (ASDCP_FAILURE(r)) {
- boost::throw_exception (MiscError(String::compose ("could not finalise audio MXF (%1)", static_cast<int>(r))));
+ boost::throw_exception(MiscError(fmt::format("could not finalise audio MXF ({})", static_cast<int>(r))));
}
}
diff --git a/src/stereo_j2k_picture_frame.cc b/src/stereo_j2k_picture_frame.cc
index 9ef91c5c..5eff1788 100644
--- a/src/stereo_j2k_picture_frame.cc
+++ b/src/stereo_j2k_picture_frame.cc
@@ -38,7 +38,6 @@
#include "colour_conversion.h"
-#include "compose.hpp"
#include "crypto_context.h"
#include "exceptions.h"
#include "j2k_transcode.h"
@@ -47,6 +46,7 @@
#include "util.h"
#include <asdcp/AS_DCP.h>
#include <asdcp/KM_fileio.h>
+#include <fmt/core.h>
using std::string;
@@ -102,7 +102,7 @@ StereoJ2KPictureFrame::StereoJ2KPictureFrame (ASDCP::JP2K::MXFSReader* reader, i
_buffer = make_shared<ASDCP::JP2K::SFrameBuffer>(4 * Kumu::Megabyte);
if (ASDCP_FAILURE (reader->ReadFrame (n, *_buffer, c->context(), check_hmac ? c->hmac() : nullptr))) {
- boost::throw_exception (ReadError (String::compose ("could not read video frame %1 of %2", n)));
+ boost::throw_exception(ReadError(fmt::format("could not read video frame {}", n)));
}
}
diff --git a/src/text.cc b/src/text.cc
index 158af38c..2be8d279 100644
--- a/src/text.cc
+++ b/src/text.cc
@@ -37,10 +37,10 @@
*/
-#include "compose.hpp"
#include "dcp_time.h"
#include "equality_options.h"
#include "text.h"
+#include <fmt/core.h>
using std::shared_ptr;
@@ -102,7 +102,7 @@ Text::equals(shared_ptr<const Text> other, EqualityOptions const& options, NoteH
if (vpos > options.max_text_vertical_position_error) {
note(
NoteType::ERROR,
- String::compose("text vertical positions differ by %1 (more than the allowed difference of %2)", vpos, options.max_text_vertical_position_error)
+ fmt::format("text vertical positions differ by {} (more than the allowed difference of {})", vpos, options.max_text_vertical_position_error)
);
same = false;
}
diff --git a/src/text_asset.cc b/src/text_asset.cc
index ff662b69..f2882572 100644
--- a/src/text_asset.cc
+++ b/src/text_asset.cc
@@ -37,7 +37,6 @@
*/
-#include "compose.hpp"
#include "dcp_assert.h"
#include "load_font_node.h"
#include "raw_convert.h"
@@ -51,6 +50,7 @@
#include <asdcp/AS_DCP.h>
#include <asdcp/KM_util.h>
#include <libxml++/nodes/element.h>
+#include <fmt/core.h>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/shared_array.hpp>
@@ -89,7 +89,7 @@ string_attribute (xmlpp::Element const * node, string name)
{
auto a = node->get_attribute (name);
if (!a) {
- throw XMLError (String::compose ("missing attribute %1", name));
+ throw XMLError(fmt::format("missing attribute {}", name));
}
return string (a->get_value ());
}
@@ -611,7 +611,7 @@ TextAsset::equals(shared_ptr<const Asset> other_asset, EqualityOptions const& op
}
if (_texts.size() != other->_texts.size()) {
- note (NoteType::ERROR, String::compose("different number of texts: %1 vs %2", _texts.size(), other->_texts.size()));
+ note(NoteType::ERROR, fmt::format("different number of texts: {} vs {}", _texts.size(), other->_texts.size()));
return false;
}
@@ -923,7 +923,7 @@ format_xml_node (xmlpp::Node const* node, State& state)
state.xml += "<" + element->get_name();
for (auto attribute: element->get_attributes()) {
- state.xml += String::compose(" %1=\"%2\"", attribute->get_name().raw(), attribute->get_value().raw());
+ state.xml += fmt::format(" {}=\"{}\"", attribute->get_name().raw(), attribute->get_value().raw());
}
if (children.empty()) {
@@ -943,7 +943,7 @@ format_xml_node (xmlpp::Node const* node, State& state)
state.xml += "\n" + string(state.indent * 2, ' ');
}
- state.xml += String::compose("</%1>", element->get_name().raw());
+ state.xml += fmt::format("</{}>", element->get_name().raw());
if (should_disable_formatting) {
--state.disable_formatting;
@@ -973,14 +973,14 @@ TextAsset::format_xml(xmlpp::Document const& document, optional<pair<string, str
if (xml_namespace) {
if (xml_namespace->first.empty()) {
- state.xml += String::compose(" xmlns=\"%1\"", xml_namespace->second);
+ state.xml += fmt::format(" xmlns=\"{}\"", xml_namespace->second);
} else {
- state.xml += String::compose(" xmlns:%1=\"%2\"", xml_namespace->first, xml_namespace->second);
+ state.xml += fmt::format(" xmlns:{}=\"{}\"", xml_namespace->first, xml_namespace->second);
}
}
for (auto attribute: root->get_attributes()) {
- state.xml += String::compose(" %1=\"%2\"", attribute->get_name().raw(), attribute->get_value().raw());
+ state.xml += fmt::format(" {}=\"{}\"", attribute->get_name().raw(), attribute->get_value().raw());
}
state.xml += ">";
@@ -989,7 +989,7 @@ TextAsset::format_xml(xmlpp::Document const& document, optional<pair<string, str
format_xml_node(child, state);
}
- state.xml += String::compose("\n</%1>\n", root->get_name().raw());
+ state.xml += fmt::format("\n</{}>\n", root->get_name().raw());
return state.xml;
}
diff --git a/src/text_asset_internal.cc b/src/text_asset_internal.cc
index f1bb83fb..e7e5d0fa 100644
--- a/src/text_asset_internal.cc
+++ b/src/text_asset_internal.cc
@@ -39,8 +39,7 @@
#include "text_asset_internal.h"
#include "text_string.h"
-#include "compose.hpp"
-#include <fmt/core.h>
+#include <fmt/format.h>
#include <cmath>
diff --git a/src/text_string.cc b/src/text_string.cc
index 32f9e4ed..b7786edf 100644
--- a/src/text_string.cc
+++ b/src/text_string.cc
@@ -37,9 +37,9 @@
*/
-#include "compose.hpp"
#include "text_string.h"
#include "xml.h"
+#include <fmt/core.h>
#include <cmath>
@@ -203,62 +203,62 @@ TextString::equals(shared_ptr<const Text> other_sub, EqualityOptions const& opti
bool same = true;
if (_font != other->_font) {
- note(NoteType::ERROR, String::compose("text font differs: %1 vs %2", _font.get_value_or("[none]"), other->_font.get_value_or("[none]")));
+ note(NoteType::ERROR, fmt::format("text font differs: {} vs {}", _font.get_value_or("[none]"), other->_font.get_value_or("[none]")));
same = false;
}
if (_italic != other->_italic) {
- note(NoteType::ERROR, String::compose("text italic flag differs: %1 vs %2", _italic ? "true" : "false", other->_italic ? "true" : "false"));
+ note(NoteType::ERROR, fmt::format("text italic flag differs: {} vs {}", _italic ? "true" : "false", other->_italic ? "true" : "false"));
same = false;
}
if (_bold != other->_bold) {
- note(NoteType::ERROR, String::compose("text bold flag differs: %1 vs %2", _bold ? "true" : "false", other->_bold ? "true" : "false"));
+ note(NoteType::ERROR, fmt::format("text bold flag differs: {} vs {}", _bold ? "true" : "false", other->_bold ? "true" : "false"));
same = false;
}
if (_underline != other->_underline) {
- note(NoteType::ERROR, String::compose("text underline flag differs: %1 vs %2", _underline ? "true" : "false", other->_underline ? "true" : "false"));
+ note(NoteType::ERROR, fmt::format("text underline flag differs: {} vs {}", _underline ? "true" : "false", other->_underline ? "true" : "false"));
same = false;
}
if (_colour != other->_colour) {
- note(NoteType::ERROR, String::compose("text colour differs: %1 vs %2", _colour.to_rgb_string(), other->_colour.to_rgb_string()));
+ note(NoteType::ERROR, fmt::format("text colour differs: {} vs {}", _colour.to_rgb_string(), other->_colour.to_rgb_string()));
same = false;
}
if (_size != other->_size) {
- note(NoteType::ERROR, String::compose("text size differs: %1 vs %2", _size, other->_size));
+ note(NoteType::ERROR, fmt::format("text size differs: {} vs {}", _size, other->_size));
same = false;
}
if (_aspect_adjust != other->_aspect_adjust) {
- note(NoteType::ERROR, String::compose("text aspect_adjust differs: %1 vs %2", _aspect_adjust, other->_aspect_adjust));
+ note(NoteType::ERROR, fmt::format("text aspect_adjust differs: {} vs {}", _aspect_adjust, other->_aspect_adjust));
same = false;
}
if (_direction != other->_direction) {
- note(NoteType::ERROR, String::compose("text direction differs: %1 vs %2", direction_to_string(_direction), direction_to_string(other->_direction)));
+ note(NoteType::ERROR, fmt::format("text direction differs: {} vs {}", direction_to_string(_direction), direction_to_string(other->_direction)));
same = false;
}
if (_text != other->_text) {
- note(NoteType::ERROR, String::compose("text text differs: %1 vs %2", _text, other->_text));
+ note(NoteType::ERROR, fmt::format("text text differs: {} vs {}", _text, other->_text));
same = false;
}
if (_effect != other->_effect) {
- note(NoteType::ERROR, String::compose("text effect differs: %1 vs %2", effect_to_string(_effect), effect_to_string(other->_effect)));
+ note(NoteType::ERROR, fmt::format("text effect differs: {} vs {}", effect_to_string(_effect), effect_to_string(other->_effect)));
same = false;
}
if (_effect_colour != other->_effect_colour) {
- note(NoteType::ERROR, String::compose("text effect colour differs: %1 vs %2", _effect_colour.to_rgb_string(), other->_effect_colour.to_rgb_string()));
+ note(NoteType::ERROR, fmt::format("text effect colour differs: {} vs {}", _effect_colour.to_rgb_string(), other->_effect_colour.to_rgb_string()));
same = false;
}
if (_space_before != other->_space_before) {
- note(NoteType::ERROR, String::compose("text space before differs: %1 vs %2", _space_before, other->_space_before));
+ note(NoteType::ERROR, fmt::format("text space before differs: {} vs {}", _space_before, other->_space_before));
same = false;
}
diff --git a/src/types.cc b/src/types.cc
index 58c2dee0..496c470f 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -37,7 +37,6 @@
*/
-#include "compose.hpp"
#include "dcp_assert.h"
#include "exceptions.h"
#include "raw_convert.h"
@@ -92,7 +91,7 @@ Fraction::Fraction (string s)
string
Fraction::as_string () const
{
- return String::compose ("%1 %2", numerator, denominator);
+ return fmt::format("{} {}", numerator, denominator);
}
@@ -344,7 +343,7 @@ void
Luminance::set_value (float v)
{
if (v < 0) {
- throw dcp::MiscError (String::compose("Invalid luminance value %1", v));
+ throw dcp::MiscError(fmt::format("Invalid luminance value {}", v));
}
_value = v;
@@ -385,7 +384,7 @@ Luminance::string_to_unit (string u)
return Unit::FOOT_LAMBERT;
}
- throw XMLError (String::compose("Invalid luminance unit %1", u));
+ throw XMLError(fmt::format("Invalid luminance unit {}", u));
}
diff --git a/src/util.cc b/src/util.cc
index 01bc8dea..d02c5a01 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -38,7 +38,6 @@
#include "certificate.h"
-#include "compose.hpp"
#include "dcp_assert.h"
#include "exceptions.h"
#include "file.h"
@@ -59,6 +58,7 @@
#include <libxml++/nodes/element.h>
#include <libxml++/document.h>
#include <openssl/sha.h>
+#include <fmt/core.h>
#include <boost/algorithm/string.hpp>
#if BOOST_VERSION >= 106100
#include <boost/dll/runtime_symbol_info.hpp>
@@ -257,7 +257,7 @@ dcp::file_to_string (boost::filesystem::path p, uintmax_t max_length)
{
auto len = filesystem::file_size(p);
if (len > max_length) {
- throw MiscError (String::compose("Unexpectedly long file (%1)", p.string()));
+ throw MiscError(fmt::format("Unexpectedly long file ({})", p.string()));
}
File f(p, "r");
@@ -388,7 +388,7 @@ dcp::unique_string (vector<string> existing, string base)
{
int const max_tries = existing.size() + 1;
for (int i = 0; i < max_tries; ++i) {
- string trial = String::compose("%1%2", base, i);
+ string const trial = fmt::format("{}{}", base, i);
if (find(existing.begin(), existing.end(), trial) == existing.end()) {
return trial;
}
diff --git a/src/verify.cc b/src/verify.cc
index 15fb0608..7d651435 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -37,7 +37,6 @@
*/
-#include "compose.hpp"
#include "cpl.h"
#include "dcp.h"
#include "exceptions.h"
@@ -77,7 +76,7 @@
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/PlatformUtils.hpp>
-#include <fmt/core.h>
+#include <fmt/format.h>
#include <boost/algorithm/string.hpp>
#include <iostream>
#include <map>
@@ -342,7 +341,7 @@ validate_xml(Context& context, T xml)
*/
string locations;
for (auto i: schema) {
- locations += String::compose("%1 %1 ", i, i);
+ locations += fmt::format("{} {} ", i, i);
}
parser.setExternalSchemaLocation(locations.c_str());
@@ -560,7 +559,7 @@ verify_main_picture_asset(Context& context, shared_ptr<const ReelPictureAsset> r
asset->size() != Size(1998, 1080) &&
asset->size() != Size(4096, 1716) &&
asset->size() != Size(3996, 2160)) {
- context.bv21_error(VerificationNote::Code::INVALID_PICTURE_SIZE_IN_PIXELS, String::compose("%1x%2", asset->size().width, asset->size().height), file);
+ context.bv21_error(VerificationNote::Code::INVALID_PICTURE_SIZE_IN_PIXELS, fmt::format("{}x{}", asset->size().width, asset->size().height), file);
}
/* Only 24, 25, 48fps allowed for 2K */
@@ -570,7 +569,7 @@ verify_main_picture_asset(Context& context, shared_ptr<const ReelPictureAsset> r
) {
context.bv21_error(
VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_2K,
- String::compose("%1/%2", asset->edit_rate().numerator, asset->edit_rate().denominator),
+ fmt::format("{}/{}", asset->edit_rate().numerator, asset->edit_rate().denominator),
file
);
}
@@ -580,7 +579,7 @@ verify_main_picture_asset(Context& context, shared_ptr<const ReelPictureAsset> r
if (asset->edit_rate() != Fraction(24, 1)) {
context.bv21_error(
VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_4K,
- String::compose("%1/%2", asset->edit_rate().numerator, asset->edit_rate().denominator),
+ fmt::format("{}/{}", asset->edit_rate().numerator, asset->edit_rate().denominator),
file
);
}
@@ -589,7 +588,7 @@ verify_main_picture_asset(Context& context, shared_ptr<const ReelPictureAsset> r
if (dynamic_pointer_cast<const StereoJ2KPictureAsset>(asset)) {
context.bv21_error(
VerificationNote::Code::INVALID_PICTURE_ASSET_RESOLUTION_FOR_3D,
- String::compose("%1/%2", asset->edit_rate().numerator, asset->edit_rate().denominator),
+ fmt::format("{}/{}", asset->edit_rate().numerator, asset->edit_rate().denominator),
file
);
@@ -719,7 +718,7 @@ verify_smpte_timed_text_asset (
if (reel_asset_duration && *reel_asset_duration != asset->intrinsic_duration()) {
context.bv21_error(
VerificationNote::Code::MISMATCHED_TIMED_TEXT_DURATION,
- String::compose("%1 %2", *reel_asset_duration, asset->intrinsic_duration()),
+ fmt::format("{} {}", *reel_asset_duration, asset->intrinsic_duration()),
asset->file().get()
);
}
@@ -1402,7 +1401,7 @@ verify_reel(
frame_rate.numerator != 50 &&
frame_rate.numerator != 60 &&
frame_rate.numerator != 96)) {
- context.error(VerificationNote::Code::INVALID_PICTURE_FRAME_RATE, String::compose("%1/%2", frame_rate.numerator, frame_rate.denominator));
+ context.error(VerificationNote::Code::INVALID_PICTURE_FRAME_RATE, fmt::format("{}/{}", frame_rate.numerator, frame_rate.denominator));
}
/* Check asset */
if (reel->main_picture()->asset_ref().resolved()) {
@@ -1412,14 +1411,14 @@ verify_reel(
if (main_picture_active_area->width > asset_size.width) {
context.error(
VerificationNote::Code::INVALID_MAIN_PICTURE_ACTIVE_AREA,
- String::compose("width %1 is bigger than the asset width %2", main_picture_active_area->width, asset_size.width),
+ fmt::format("width {} is bigger than the asset width {}", main_picture_active_area->width, asset_size.width),
context.cpl->file().get()
);
}
if (main_picture_active_area->height > asset_size.height) {
context.error(
VerificationNote::Code::INVALID_MAIN_PICTURE_ACTIVE_AREA,
- String::compose("height %1 is bigger than the asset height %2", main_picture_active_area->height, asset_size.height),
+ fmt::format("height {} is bigger than the asset height {}", main_picture_active_area->height, asset_size.height),
context.cpl->file().get()
);
}
@@ -1594,7 +1593,7 @@ verify_cpl(Context& context, shared_ptr<const CPL> cpl)
if (main_picture_active_area && (main_picture_active_area->width % 2)) {
context.error(
VerificationNote::Code::INVALID_MAIN_PICTURE_ACTIVE_AREA,
- String::compose("width %1 is not a multiple of 2", main_picture_active_area->width),
+ fmt::format("width {} is not a multiple of 2", main_picture_active_area->width),
cpl->file().get()
);
active_area_ok = false;
@@ -1602,7 +1601,7 @@ verify_cpl(Context& context, shared_ptr<const CPL> cpl)
if (main_picture_active_area && (main_picture_active_area->height % 2)) {
context.error(
VerificationNote::Code::INVALID_MAIN_PICTURE_ACTIVE_AREA,
- String::compose("height %1 is not a multiple of 2", main_picture_active_area->height),
+ fmt::format("height {} is not a multiple of 2", main_picture_active_area->height),
cpl->file().get()
);
active_area_ok = false;
@@ -1610,7 +1609,7 @@ verify_cpl(Context& context, shared_ptr<const CPL> cpl)
if (main_picture_active_area && active_area_ok) {
context.ok(
- VerificationNote::Code::VALID_MAIN_PICTURE_ACTIVE_AREA, String::compose("%1x%2", main_picture_active_area->width, main_picture_active_area->height),
+ VerificationNote::Code::VALID_MAIN_PICTURE_ACTIVE_AREA, fmt::format("{}x{}", main_picture_active_area->width, main_picture_active_area->height),
cpl->file().get()
);
}
@@ -1639,7 +1638,7 @@ verify_cpl(Context& context, shared_ptr<const CPL> cpl)
if (context.audio_channels && msc->channels() != *context.audio_channels) {
context.error(
VerificationNote::Code::INVALID_MAIN_SOUND_CONFIGURATION,
- String::compose("MainSoundConfiguration has %1 channels but sound assets have %2", msc->channels(), *context.audio_channels),
+ fmt::format("MainSoundConfiguration has {} channels but sound assets have {}", msc->channels(), *context.audio_channels),
cpl->file().get()
);
}
@@ -1881,7 +1880,7 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
return process_filename(note.file()->filename().string());
};
-#define compose(format, ...) String::compose(process_string(format), __VA_ARGS__)
+#define compose(f, ...) fmt::format(process_string(f), __VA_ARGS__)
switch (note.code()) {
case VerificationNote::Code::FAILED_READ:
@@ -1889,81 +1888,81 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
case VerificationNote::Code::MATCHING_CPL_HASHES:
return process_string("The hash of the CPL in the PKL matches the CPL file.");
case VerificationNote::Code::MISMATCHED_CPL_HASHES:
- return compose("The hash (%1) of the CPL (%2) in the PKL does not agree with the CPL file (%3).", note.reference_hash().get(), note.cpl_id().get(), note.calculated_hash().get());
+ return compose("The hash ({}) of the CPL ({}) in the PKL does not agree with the CPL file ({}).", note.reference_hash().get(), note.cpl_id().get(), note.calculated_hash().get());
case VerificationNote::Code::INVALID_PICTURE_FRAME_RATE:
- return compose("The picture in a reel has an invalid frame rate %1.", note.note().get());
+ return compose("The picture in a reel has an invalid frame rate {}.", note.note().get());
case VerificationNote::Code::INCORRECT_PICTURE_HASH:
- return compose("The hash (%1) of the picture asset %2 does not agree with the PKL file (%3).", note.calculated_hash().get(), filename(), note.reference_hash().get());
+ return compose("The hash ({}) of the picture asset {} does not agree with the PKL file ({}).", note.calculated_hash().get(), filename(), note.reference_hash().get());
case VerificationNote::Code::CORRECT_PICTURE_HASH:
- return compose("The picture asset %1 has the expected hashes in the CPL and PKL.", filename());
+ return compose("The picture asset {} has the expected hashes in the CPL and PKL.", filename());
case VerificationNote::Code::MISMATCHED_PICTURE_HASHES:
- return compose("The PKL and CPL hashes differ for the picture asset %1.", filename());
+ return compose("The PKL and CPL hashes differ for the picture asset {}.", filename());
case VerificationNote::Code::INCORRECT_SOUND_HASH:
- return compose("The hash (%1) of the sound asset %2 does not agree with the PKL file (%3).", note.calculated_hash().get(), filename(), note.reference_hash().get());
+ return compose("The hash ({}) of the sound asset {} does not agree with the PKL file ({}).", note.calculated_hash().get(), filename(), note.reference_hash().get());
case VerificationNote::Code::MISMATCHED_SOUND_HASHES:
- return compose("The PKL and CPL hashes differ for the sound asset %1.", filename());
+ return compose("The PKL and CPL hashes differ for the sound asset {}.", filename());
case VerificationNote::Code::EMPTY_ASSET_PATH:
return process_string("The asset map contains an empty asset path.");
case VerificationNote::Code::MISSING_ASSET:
- return compose("The file %1 for an asset in the asset map cannot be found.", filename());
+ return compose("The file {} for an asset in the asset map cannot be found.", filename());
case VerificationNote::Code::MISMATCHED_STANDARD:
return process_string("The DCP contains both SMPTE and Interop parts.");
case VerificationNote::Code::INVALID_XML:
- return compose("An XML file is badly formed: %1 (%2:%3)", note.note().get(), filename(), note.line().get());
+ return compose("An XML file is badly formed: {} ({}:{})", note.note().get(), filename(), note.line().get());
case VerificationNote::Code::MISSING_ASSETMAP:
return process_string("No valid ASSETMAP or ASSETMAP.xml was found.");
case VerificationNote::Code::INVALID_INTRINSIC_DURATION:
- return compose("The intrinsic duration of the asset %1 is less than 1 second.", note.note().get());
+ return compose("The intrinsic duration of the asset {} is less than 1 second.", note.note().get());
case VerificationNote::Code::INVALID_DURATION:
- return compose("The duration of the asset %1 is less than 1 second.", note.note().get());
+ return compose("The duration of the asset {} is less than 1 second.", note.note().get());
case VerificationNote::Code::VALID_PICTURE_FRAME_SIZES_IN_BYTES:
- return compose("Each frame of the picture asset %1 has a bit rate safely under the limit of 250Mbit/s.", filename());
+ return compose("Each frame of the picture asset {} has a bit rate safely under the limit of 250Mbit/s.", filename());
case VerificationNote::Code::INVALID_PICTURE_FRAME_SIZE_IN_BYTES:
return compose(
- "Frame %1 (timecode %2) in asset %3 has an instantaneous bit rate that is larger than the limit of 250Mbit/s.",
+ "Frame {} (timecode {}) in asset {} has an instantaneous bit rate that is larger than the limit of 250Mbit/s.",
note.frame().get(),
dcp::Time(note.frame().get(), note.frame_rate().get(), note.frame_rate().get()).as_string(dcp::Standard::SMPTE),
filename()
);
case VerificationNote::Code::NEARLY_INVALID_PICTURE_FRAME_SIZE_IN_BYTES:
return compose(
- "Frame %1 (timecode %2) in asset %3 has an instantaneous bit rate that is close to the limit of 250Mbit/s.",
+ "Frame {} (timecode {}) in asset {} has an instantaneous bit rate that is close to the limit of 250Mbit/s.",
note.frame().get(),
dcp::Time(note.frame().get(), note.frame_rate().get(), note.frame_rate().get()).as_string(dcp::Standard::SMPTE),
filename()
);
case VerificationNote::Code::EXTERNAL_ASSET:
- return compose("The asset %1 that this DCP refers to is not included in the DCP. It may be a VF.", note.note().get());
+ return compose("The asset {} that this DCP refers to is not included in the DCP. It may be a VF.", note.note().get());
case VerificationNote::Code::THREED_ASSET_MARKED_AS_TWOD:
- return compose("The asset %1 is 3D but its MXF is marked as 2D.", filename());
+ return compose("The asset {} is 3D but its MXF is marked as 2D.", filename());
case VerificationNote::Code::INVALID_STANDARD:
return "This DCP does not use the SMPTE standard.";
case VerificationNote::Code::INVALID_LANGUAGE:
- return compose("The DCP specifies a language '%1' which does not conform to the RFC 5646 standard.", note.note().get());
+ return compose("The DCP specifies a language '{}' which does not conform to the RFC 5646 standard.", note.note().get());
case VerificationNote::Code::VALID_RELEASE_TERRITORY:
- return compose("Valid release territory %1.", note.note().get());
+ return compose("Valid release territory {}.", note.note().get());
case VerificationNote::Code::INVALID_PICTURE_SIZE_IN_PIXELS:
- return compose("The size %1 of picture asset %2 is not allowed.", note.note().get(), filename());
+ return compose("The size {} of picture asset {} is not allowed.", note.note().get(), filename());
case VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_2K:
- return compose("The frame rate %1 of picture asset %2 is not allowed for 2K DCPs.", note.note().get(), filename());
+ return compose("The frame rate {} of picture asset {} is not allowed for 2K DCPs.", note.note().get(), filename());
case VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_4K:
- return compose("The frame rate %1 of picture asset %2 is not allowed for 4K DCPs.", note.note().get(), filename());
+ return compose("The frame rate {} of picture asset {} is not allowed for 4K DCPs.", note.note().get(), filename());
case VerificationNote::Code::INVALID_PICTURE_ASSET_RESOLUTION_FOR_3D:
return process_string("3D 4K DCPs are not allowed.");
case VerificationNote::Code::INVALID_CLOSED_CAPTION_XML_SIZE_IN_BYTES:
- return compose("The size %1 of the closed caption asset %2 is larger than the 256KB maximum.", note.note().get(), filename());
+ return compose("The size {} of the closed caption asset {} is larger than the 256KB maximum.", note.note().get(), filename());
case VerificationNote::Code::INVALID_TIMED_TEXT_SIZE_IN_BYTES:
- return compose("The size %1 of the timed text asset %2 is larger than the 115MB maximum.", note.note().get(), filename());
+ return compose("The size {} of the timed text asset {} is larger than the 115MB maximum.", note.note().get(), filename());
case VerificationNote::Code::INVALID_TIMED_TEXT_FONT_SIZE_IN_BYTES:
- return compose("The size %1 of the fonts in timed text asset %2 is larger than the 10MB maximum.", note.note().get(), filename());
+ return compose("The size {} of the fonts in timed text asset {} is larger than the 10MB maximum.", note.note().get(), filename());
case VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE:
- return compose("The XML for the SMPTE subtitle asset %1 has no <Language> tag.", filename());
+ return compose("The XML for the SMPTE subtitle asset {} has no <Language> tag.", filename());
case VerificationNote::Code::MISMATCHED_SUBTITLE_LANGUAGES:
return process_string("Some subtitle assets have different <Language> tags than others");
case VerificationNote::Code::MISSING_SUBTITLE_START_TIME:
- return compose("The XML for the SMPTE subtitle asset %1 has no <StartTime> tag.", filename());
+ return compose("The XML for the SMPTE subtitle asset {} has no <StartTime> tag.", filename());
case VerificationNote::Code::INVALID_SUBTITLE_START_TIME:
- return compose("The XML for a SMPTE subtitle asset %1 has a non-zero <StartTime> tag.", filename());
+ return compose("The XML for a SMPTE subtitle asset {} has a non-zero <StartTime> tag.", filename());
case VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME:
return process_string("The first subtitle or closed caption is less than 4 seconds from the start of the DCP.");
case VerificationNote::Code::INVALID_SUBTITLE_DURATION:
@@ -1983,15 +1982,15 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
case VerificationNote::Code::INVALID_CLOSED_CAPTION_LINE_LENGTH:
return process_string("There are more than 32 characters in at least one closed caption line.");
case VerificationNote::Code::INVALID_SOUND_FRAME_RATE:
- return compose("The sound asset %1 has a sampling rate of %2", filename(), note.note().get());
+ return compose("The sound asset {} has a sampling rate of {}", filename(), note.note().get());
case VerificationNote::Code::INVALID_SOUND_BIT_DEPTH:
- return compose("The sound asset %1 has a bit depth of %2", filename(), note.note().get());
+ return compose("The sound asset {} has a bit depth of {}", filename(), note.note().get());
case VerificationNote::Code::MISSING_CPL_ANNOTATION_TEXT:
- return compose("The CPL %1 has no <AnnotationText> tag.", note.cpl_id().get());
+ return compose("The CPL {} has no <AnnotationText> tag.", note.cpl_id().get());
case VerificationNote::Code::MISMATCHED_CPL_ANNOTATION_TEXT:
- return compose("The CPL %1 has an <AnnotationText> which differs from its <ContentTitleText>.", note.cpl_id().get());
+ return compose("The CPL {} has an <AnnotationText> which differs from its <ContentTitleText>.", note.cpl_id().get());
case VerificationNote::Code::VALID_CPL_ANNOTATION_TEXT:
- return compose("Valid CPL annotation text %1", note.note().get());
+ return compose("Valid CPL annotation text {}", note.note().get());
case VerificationNote::Code::MISMATCHED_ASSET_DURATION:
return process_string("All assets in a reel do not have the same duration.");
case VerificationNote::Code::MISSING_MAIN_SUBTITLE_FROM_SOME_REELS:
@@ -1999,15 +1998,15 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
case VerificationNote::Code::MISMATCHED_CLOSED_CAPTION_ASSET_COUNTS:
return process_string("At least one reel has closed captions, but reels have different numbers of closed caption assets.");
case VerificationNote::Code::MISSING_SUBTITLE_ENTRY_POINT:
- return compose("The subtitle asset %1 has no <EntryPoint> tag.", note.note().get());
+ return compose("The subtitle asset {} has no <EntryPoint> tag.", note.note().get());
case VerificationNote::Code::INCORRECT_SUBTITLE_ENTRY_POINT:
- return compose("The subtitle asset %1 has an <EntryPoint> other than 0.", note.note().get());
+ return compose("The subtitle asset {} has an <EntryPoint> other than 0.", note.note().get());
case VerificationNote::Code::MISSING_CLOSED_CAPTION_ENTRY_POINT:
- return compose("The closed caption asset %1 has no <EntryPoint> tag.", note.note().get());
+ return compose("The closed caption asset {} has no <EntryPoint> tag.", note.note().get());
case VerificationNote::Code::INCORRECT_CLOSED_CAPTION_ENTRY_POINT:
- return compose("The closed caption asset %1 has an <EntryPoint> other than 0.", note.note().get());
+ return compose("The closed caption asset {} has an <EntryPoint> other than 0.", note.note().get());
case VerificationNote::Code::MISSING_HASH:
- return compose("The asset %1 has no <Hash> tag in the CPL.", note.note().get());
+ return compose("The asset {} has no <Hash> tag in the CPL.", note.note().get());
case VerificationNote::Code::MISSING_FFEC_IN_FEATURE:
return process_string("The DCP is marked as a Feature but there is no FFEC (first frame of end credits) marker.");
case VerificationNote::Code::MISSING_FFMC_IN_FEATURE:
@@ -2017,23 +2016,23 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
case VerificationNote::Code::MISSING_LFOC:
return process_string("There should be a LFOC (last frame of content) marker.");
case VerificationNote::Code::INCORRECT_FFOC:
- return compose("The FFOC marker is %1 instead of 1", note.note().get());
+ return compose("The FFOC marker is {} instead of 1", note.note().get());
case VerificationNote::Code::INCORRECT_LFOC:
- return compose("The LFOC marker is %1 instead of 1 less than the duration of the last reel.", note.note().get());
+ return compose("The LFOC marker is {} instead of 1 less than the duration of the last reel.", note.note().get());
case VerificationNote::Code::MISSING_CPL_METADATA:
- return compose("The CPL %1 has no <CompositionMetadataAsset> tag.", note.cpl_id().get());
+ return compose("The CPL {} has no <CompositionMetadataAsset> tag.", note.cpl_id().get());
case VerificationNote::Code::MISSING_CPL_METADATA_VERSION_NUMBER:
- return compose("The CPL %1 has no <VersionNumber> in its <CompositionMetadataAsset>.", note.cpl_id().get());
+ return compose("The CPL {} has no <VersionNumber> in its <CompositionMetadataAsset>.", note.cpl_id().get());
case VerificationNote::Code::MISSING_EXTENSION_METADATA:
- return compose("The CPL %1 has no <ExtensionMetadata> in its <CompositionMetadataAsset>.", note.cpl_id().get());
+ return compose("The CPL {} has no <ExtensionMetadata> in its <CompositionMetadataAsset>.", note.cpl_id().get());
case VerificationNote::Code::INVALID_EXTENSION_METADATA:
- return compose("The CPL %1 has a malformed <ExtensionMetadata> (%2).", filename(), note.note().get());
+ return compose("The CPL {} has a malformed <ExtensionMetadata> ({}).", filename(), note.note().get());
case VerificationNote::Code::UNSIGNED_CPL_WITH_ENCRYPTED_CONTENT:
- return compose("The CPL %1, which has encrypted content, is not signed.", note.cpl_id().get());
+ return compose("The CPL {}, which has encrypted content, is not signed.", note.cpl_id().get());
case VerificationNote::Code::UNSIGNED_PKL_WITH_ENCRYPTED_CONTENT:
- return compose("The PKL %1, which has encrypted content, is not signed.", note.note().get());
+ return compose("The PKL {}, which has encrypted content, is not signed.", note.note().get());
case VerificationNote::Code::MISMATCHED_PKL_ANNOTATION_TEXT_WITH_CPL:
- return compose("The PKL %1 has only one CPL but its <AnnotationText> does not match the CPL's <ContentTitleText>.", note.note().get());
+ return compose("The PKL {} has only one CPL but its <AnnotationText> does not match the CPL's <ContentTitleText>.", note.note().get());
case VerificationNote::Code::MATCHING_PKL_ANNOTATION_TEXT_WITH_CPL:
return process_string("The PKL and CPL annotation texts match.");
case VerificationNote::Code::ALL_ENCRYPTED:
@@ -2044,33 +2043,33 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
return process_string("Some assets are encrypted but some are not.");
case VerificationNote::Code::INVALID_JPEG2000_CODESTREAM:
return compose(
- "Frame %1 (timecode %2) has an invalid JPEG2000 codestream (%3).",
+ "Frame {} (timecode {}) has an invalid JPEG2000 codestream ({}).",
note.frame().get(),
dcp::Time(note.frame().get(), note.frame_rate().get(), note.frame_rate().get()).as_string(dcp::Standard::SMPTE),
note.note().get()
);
case VerificationNote::Code::INVALID_JPEG2000_GUARD_BITS_FOR_2K:
- return compose("The JPEG2000 codestream uses %1 guard bits in a 2K image instead of 1.", note.note().get());
+ return compose("The JPEG2000 codestream uses {} guard bits in a 2K image instead of 1.", note.note().get());
case VerificationNote::Code::INVALID_JPEG2000_GUARD_BITS_FOR_4K:
- return compose("The JPEG2000 codestream uses %1 guard bits in a 4K image instead of 2.", note.note().get());
+ return compose("The JPEG2000 codestream uses {} guard bits in a 4K image instead of 2.", note.note().get());
case VerificationNote::Code::INVALID_JPEG2000_TILE_SIZE:
return process_string("The JPEG2000 tile size is not the same as the image size.");
case VerificationNote::Code::INVALID_JPEG2000_CODE_BLOCK_WIDTH:
- return compose("The JPEG2000 codestream uses a code block width of %1 instead of 32.", note.note().get());
+ return compose("The JPEG2000 codestream uses a code block width of {} instead of 32.", note.note().get());
case VerificationNote::Code::INVALID_JPEG2000_CODE_BLOCK_HEIGHT:
- return compose("The JPEG2000 codestream uses a code block height of %1 instead of 32.", note.note().get());
+ return compose("The JPEG2000 codestream uses a code block height of {} instead of 32.", note.note().get());
case VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER_COUNT_FOR_2K:
- return compose("%1 POC markers found in 2K JPEG2000 codestream instead of 0.", note.note().get());
+ return compose("{} POC markers found in 2K JPEG2000 codestream instead of 0.", note.note().get());
case VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER_COUNT_FOR_4K:
- return compose("%1 POC markers found in 4K JPEG2000 codestream instead of 1.", note.note().get());
+ return compose("{} POC markers found in 4K JPEG2000 codestream instead of 1.", note.note().get());
case VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER:
- return compose("Incorrect POC marker content found (%1).", note.note().get());
+ return compose("Incorrect POC marker content found ({}).", note.note().get());
case VerificationNote::Code::INVALID_JPEG2000_POC_MARKER_LOCATION:
return process_string("POC marker found outside main header.");
case VerificationNote::Code::INVALID_JPEG2000_TILE_PARTS_FOR_2K:
- return compose("The JPEG2000 codestream has %1 tile parts in a 2K image instead of 3.", note.note().get());
+ return compose("The JPEG2000 codestream has {} tile parts in a 2K image instead of 3.", note.note().get());
case VerificationNote::Code::INVALID_JPEG2000_TILE_PARTS_FOR_4K:
- return compose("The JPEG2000 codestream has %1 tile parts in a 4K image instead of 6.", note.note().get());
+ return compose("The JPEG2000 codestream has {} tile parts in a 4K image instead of 6.", note.note().get());
case VerificationNote::Code::MISSING_JPEG200_TLM_MARKER:
return process_string("No TLM marker was found in a JPEG2000 codestream.");
case VerificationNote::Code::MISMATCHED_TIMED_TEXT_RESOURCE_ID:
@@ -2082,7 +2081,7 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
vector<string> parts;
boost::split (parts, note.note().get(), boost::is_any_of(" "));
DCP_ASSERT (parts.size() == 2);
- return compose("The reel duration of some timed text (%1) is not the same as the ContainerDuration of its MXF (%2).", parts[0], parts[1]);
+ return compose("The reel duration of some timed text ({}) is not the same as the ContainerDuration of its MXF ({}).", parts[0], parts[1]);
}
case VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED:
return process_string("Some aspect of this DCP could not be checked because it is encrypted.");
@@ -2097,50 +2096,50 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
case VerificationNote::Code::UNEXPECTED_DURATION:
return process_string("There is an <Duration> node inside a <MainMarkers>.");
case VerificationNote::Code::INVALID_CONTENT_KIND:
- return compose("<ContentKind> has an invalid value %1.", note.note().get());
+ return compose("<ContentKind> has an invalid value {}.", note.note().get());
case VerificationNote::Code::VALID_CONTENT_KIND:
- return compose("Valid <ContentKind> %1.", note.note().get());
+ return compose("Valid <ContentKind> {}.", note.note().get());
case VerificationNote::Code::INVALID_MAIN_PICTURE_ACTIVE_AREA:
- return compose("<MainPictureActiveaArea> has an invalid value: %1", note.note().get());
+ return compose("<MainPictureActiveaArea> has an invalid value: {}", note.note().get());
case VerificationNote::Code::VALID_MAIN_PICTURE_ACTIVE_AREA:
- return compose("<MainPictureActiveaArea> %1 is valid", note.note().get());
+ return compose("<MainPictureActiveaArea> {} is valid", note.note().get());
case VerificationNote::Code::DUPLICATE_ASSET_ID_IN_PKL:
- return compose("The PKL %1 has more than one asset with the same ID.", note.note().get());
+ return compose("The PKL {} has more than one asset with the same ID.", note.note().get());
case VerificationNote::Code::DUPLICATE_ASSET_ID_IN_ASSETMAP:
- return compose("The ASSETMAP %1 has more than one asset with the same ID.", note.note().get());
+ return compose("The ASSETMAP {} has more than one asset with the same ID.", note.note().get());
case VerificationNote::Code::MISSING_SUBTITLE:
- return compose("The subtitle asset %1 has no subtitles.", note.note().get());
+ return compose("The subtitle asset {} has no subtitles.", note.note().get());
case VerificationNote::Code::INVALID_SUBTITLE_ISSUE_DATE:
- return compose("<IssueDate> has an invalid value: %1", note.note().get());
+ return compose("<IssueDate> has an invalid value: {}", note.note().get());
case VerificationNote::Code::MISMATCHED_SOUND_CHANNEL_COUNTS:
- return compose("The sound assets do not all have the same channel count; the first to differ is %1", filename());
+ return compose("The sound assets do not all have the same channel count; the first to differ is {}", filename());
case VerificationNote::Code::INVALID_MAIN_SOUND_CONFIGURATION:
- return compose("<MainSoundConfiguration> has an invalid value: %1", note.note().get());
+ return compose("<MainSoundConfiguration> has an invalid value: {}", note.note().get());
case VerificationNote::Code::MISSING_FONT:
- return compose("The font file for font ID \"%1\" was not found, or was not referred to in the ASSETMAP.", note.note().get());
+ return compose("The font file for font ID \"{}\" was not found, or was not referred to in the ASSETMAP.", note.note().get());
case VerificationNote::Code::INVALID_JPEG2000_TILE_PART_SIZE:
return compose(
- "Frame %1 has an image component that is too large (component %2 is %3 bytes in size).",
+ "Frame {} has an image component that is too large (component {} is {} bytes in size).",
note.frame().get(), note.component().get(), note.size().get()
);
case VerificationNote::Code::INCORRECT_SUBTITLE_NAMESPACE_COUNT:
- return compose("The XML in the subtitle asset %1 has more than one namespace declaration.", note.note().get());
+ return compose("The XML in the subtitle asset {} has more than one namespace declaration.", note.note().get());
case VerificationNote::Code::MISSING_LOAD_FONT_FOR_FONT:
- return compose("A subtitle or closed caption refers to a font with ID %1 that does not have a corresponding <LoadFont> node", note.id().get());
+ return compose("A subtitle or closed caption refers to a font with ID {} that does not have a corresponding <LoadFont> node", note.id().get());
case VerificationNote::Code::MISSING_LOAD_FONT:
- return compose("The SMPTE subtitle asset %1 has <Text> nodes but no <LoadFont> node", note.id().get());
+ return compose("The SMPTE subtitle asset {} has <Text> nodes but no <LoadFont> node", note.id().get());
case VerificationNote::Code::MISMATCHED_ASSET_MAP_ID:
- return compose("The asset with ID %1 in the asset map actually has an id of %2", note.id().get(), note.other_id().get());
+ return compose("The asset with ID {} in the asset map actually has an id of {}", note.id().get(), note.other_id().get());
case VerificationNote::Code::EMPTY_CONTENT_VERSION_LABEL_TEXT:
- return compose("The <LabelText> in a <ContentVersion> in CPL %1 is empty", note.cpl_id().get());
+ return compose("The <LabelText> in a <ContentVersion> in CPL {} is empty", note.cpl_id().get());
case VerificationNote::Code::VALID_CONTENT_VERSION_LABEL_TEXT:
- return compose("CPL has valid <ContentVersion> %1", note.note().get());
+ return compose("CPL has valid <ContentVersion> {}", note.note().get());
case VerificationNote::Code::INVALID_CPL_NAMESPACE:
- return compose("The namespace %1 in CPL %2 is invalid", note.note().get(), note.cpl_id().get());
+ return compose("The namespace {} in CPL {} is invalid", note.note().get(), note.cpl_id().get());
case VerificationNote::Code::MISSING_CPL_CONTENT_VERSION:
- return compose("The CPL %1 has no <ContentVersion> tag", note.cpl_id().get());
+ return compose("The CPL {} has no <ContentVersion> tag", note.cpl_id().get());
case VerificationNote::Code::INVALID_PKL_NAMESPACE:
- return compose("The namespace %1 in PKL %2 is invalid", note.note().get(), note.file()->filename());
+ return compose("The namespace {} in PKL {} is invalid", note.note().get(), note.file()->filename().string());
}
return "";
diff --git a/src/verify_j2k.cc b/src/verify_j2k.cc
index 12ea90e6..0a63800f 100644
--- a/src/verify_j2k.cc
+++ b/src/verify_j2k.cc
@@ -37,11 +37,10 @@
*/
-#include "compose.hpp"
#include "data.h"
#include "verify.h"
#include "verify_j2k.h"
-#include <fmt/core.h>
+#include <fmt/format.h>
#include <memory>
#include <vector>
@@ -138,21 +137,21 @@ dcp::verify_j2k(shared_ptr<const Data> j2k, int start_index, int frame_index, in
auto require_8 = [&](uint8_t value, string note) {
auto v = get_8 ();
if (v != value) {
- throw InvalidCodestream (String::compose(note, v));
+ throw InvalidCodestream(fmt::format(note, v));
}
};
auto require_16 = [&](uint16_t value, string note) {
auto v = get_16 ();
if (v != value) {
- throw InvalidCodestream (String::compose(note, v));
+ throw InvalidCodestream(fmt::format(note, v));
}
};
auto require_32 = [&](uint32_t value, string note) {
auto v = get_32 ();
if (v != value) {
- throw InvalidCodestream (String::compose(note, v));
+ throw InvalidCodestream(fmt::format(note, v));
}
};
@@ -167,20 +166,20 @@ dcp::verify_j2k(shared_ptr<const Data> j2k, int start_index, int frame_index, in
auto const image_width = get_32();
auto const image_height = get_32();
auto const fourk = image_width > 2048;
- require_32 (0, "invalid top-left image x coordinate %1");
- require_32 (0, "invalid top-left image y coordinate %1");
+ require_32 (0, "invalid top-left image x coordinate {}");
+ require_32 (0, "invalid top-left image y coordinate {}");
auto const tile_width = get_32();
auto const tile_height = get_32();
if (tile_width != image_width || tile_height != image_height) {
notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_TILE_SIZE });
}
- require_32 (0, "invalid tile anchor x coordinate %1");
- require_32 (0, "invalid tile anchor y coordinate %1");
- require_16 (3, "invalid component count %1");
+ require_32 (0, "invalid tile anchor x coordinate {}");
+ require_32 (0, "invalid tile anchor y coordinate {}");
+ require_16 (3, "invalid component count {}");
for (auto i = 0; i < 3; ++i) {
- require_8 (12 - 1, "invalid bit depth %1");
- require_8 (1, "invalid horizontal subsampling factor %1");
- require_8 (1, "invalid vertical subsampling factor %1");
+ require_8 (12 - 1, "invalid bit depth {}");
+ require_8 (1, "invalid horizontal subsampling factor {}");
+ require_8 (1, "invalid vertical subsampling factor {}");
}
auto num_COD = 0;
@@ -199,10 +198,10 @@ dcp::verify_j2k(shared_ptr<const Data> j2k, int start_index, int frame_index, in
auto marker_name = marker_name_from_id (marker_id);
if (!marker_name) {
char buffer[16];
- snprintf (buffer, 16, "%2x", marker_id);
- throw InvalidCodestream(String::compose("unknown marker %1", buffer));
+ snprintf(buffer, 16, "%2x", marker_id);
+ throw InvalidCodestream(fmt::format("unknown marker {}", buffer));
} else if (*marker_name == "SOT") {
- require_16(10, "invalid SOT size %1");
+ require_16(10, "invalid SOT size {}");
get_16(); // tile index
auto const tile_part_length = get_32();
auto const tile_part_index = get_8();
@@ -231,11 +230,11 @@ dcp::verify_j2k(shared_ptr<const Data> j2k, int start_index, int frame_index, in
} else if (*marker_name == "COD") {
num_COD++;
get_16(); // length
- require_8(1, "invalid coding style %1");
- require_8(4, "invalid progression order %1"); // CPRL
- require_16(1, "invalid quality layers count %1");
- require_8(1, "invalid multi-component transform flag %1");
- require_8(fourk ? 6 : 5, "invalid number of transform levels %1");
+ require_8(1, "invalid coding style {}");
+ require_8(4, "invalid progression order {}"); // CPRL
+ require_16(1, "invalid quality layers count {}");
+ require_8(1, "invalid multi-component transform flag {}");
+ require_8(fourk ? 6 : 5, "invalid number of transform levels {}");
auto log_code_block_width = get_8();
if (log_code_block_width != 3) {
notes.push_back({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_CODE_BLOCK_WIDTH, fmt::to_string(4 * (2 << log_code_block_width)) });
@@ -245,15 +244,15 @@ dcp::verify_j2k(shared_ptr<const Data> j2k, int start_index, int frame_index, in
notes.push_back({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_CODE_BLOCK_HEIGHT, fmt::to_string(4 * (2 << log_code_block_height)) });
}
require_8(0, "invalid mode variations");
- require_8(0, "invalid wavelet transform type %1"); // 9/7 irreversible
- require_8(0x77, "invalid precinct size %1");
- require_8(0x88, "invalid precinct size %1");
- require_8(0x88, "invalid precinct size %1");
- require_8(0x88, "invalid precinct size %1");
- require_8(0x88, "invalid precinct size %1");
- require_8(0x88, "invalid precinct size %1");
+ require_8(0, "invalid wavelet transform type {}"); // 9/7 irreversible
+ require_8(0x77, "invalid precinct size {}");
+ require_8(0x88, "invalid precinct size {}");
+ require_8(0x88, "invalid precinct size {}");
+ require_8(0x88, "invalid precinct size {}");
+ require_8(0x88, "invalid precinct size {}");
+ require_8(0x88, "invalid precinct size {}");
if (fourk) {
- require_8(0x88, "invalid precinct size %1");
+ require_8(0x88, "invalid precinct size {}");
}
} else if (*marker_name == "QCD") {
num_QCD++;
@@ -275,19 +274,19 @@ dcp::verify_j2k(shared_ptr<const Data> j2k, int start_index, int frame_index, in
* like it should be OK.
*/
if (coc_component_number > 2) {
- throw InvalidCodestream(String::compose("invalid COC component number %1", coc_component_number));
+ throw InvalidCodestream(fmt::format("invalid COC component number {}", coc_component_number));
}
- require_8(1, "invalid coding style %1");
- require_8(5, "invalid number of transform levels %1");
- require_8(3, "invalid code block width exponent %1");
- require_8(3, "invalid code block height exponent %1");
+ require_8(1, "invalid coding style {}");
+ require_8(5, "invalid number of transform levels {}");
+ require_8(3, "invalid code block width exponent {}");
+ require_8(3, "invalid code block height exponent {}");
require_8(0, "invalid mode variations");
- require_8(0x77, "invalid precinct size %1");
- require_8(0x88, "invalid precinct size %1");
- require_8(0x88, "invalid precinct size %1");
- require_8(0x88, "invalid precinct size %1");
- require_8(0x88, "invalid precinct size %1");
- require_8(0x88, "invalid precinct size %1");
+ require_8(0x77, "invalid precinct size {}");
+ require_8(0x88, "invalid precinct size {}");
+ require_8(0x88, "invalid precinct size {}");
+ require_8(0x88, "invalid precinct size {}");
+ require_8(0x88, "invalid precinct size {}");
+ require_8(0x88, "invalid precinct size {}");
} else if (*marker_name == "TLM") {
auto const len = get_16();
ptr += len - 2;
@@ -304,29 +303,29 @@ dcp::verify_j2k(shared_ptr<const Data> j2k, int start_index, int frame_index, in
auto require_8_poc = [&](uint16_t value, string note) {
if (get_8() != value) {
- notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER, String::compose(note, value) });
+ notes.push_back({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER, fmt::format(note, value) });
}
};
auto require_16_poc = [&](uint16_t value, string note) {
if (get_16() != value) {
- notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER, String::compose(note, value) });
+ notes.push_back({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER, fmt::format(note, value) });
}
};
- require_16_poc(16, "invalid length %1");
- require_8_poc(0, "invalid RSpoc %1");
- require_8_poc(0, "invalid CSpoc %1");
- require_16_poc(1, "invalid LYEpoc %1");
- require_8_poc(6, "invalid REpoc %1");
- require_8_poc(3, "invalid CEpoc %1");
- require_8_poc(4, "invalid Ppoc %1");
- require_8_poc(6, "invalid RSpoc %1");
- require_8_poc(0, "invalid CSpoc %1");
- require_16_poc(1, "invalid LYEpoc %1");
- require_8_poc(7, "invalid REpoc %1");
- require_8_poc(3, "invalid CEpoc %1");
- require_8_poc(4, "invalid Ppoc %1");
+ require_16_poc(16, "invalid length {}");
+ require_8_poc(0, "invalid RSpoc {}");
+ require_8_poc(0, "invalid CSpoc {}");
+ require_16_poc(1, "invalid LYEpoc {}");
+ require_8_poc(6, "invalid REpoc {}");
+ require_8_poc(3, "invalid CEpoc {}");
+ require_8_poc(4, "invalid Ppoc {}");
+ require_8_poc(6, "invalid RSpoc {}");
+ require_8_poc(0, "invalid CSpoc {}");
+ require_16_poc(1, "invalid LYEpoc {}");
+ require_8_poc(7, "invalid REpoc {}");
+ require_8_poc(3, "invalid CEpoc {}");
+ require_8_poc(4, "invalid Ppoc {}");
}
}
diff --git a/src/verify_report.cc b/src/verify_report.cc
index bcbda1ff..a119fea8 100644
--- a/src/verify_report.cc
+++ b/src/verify_report.cc
@@ -32,7 +32,6 @@
*/
-#include "compose.hpp"
#include "cpl.h"
#include "dcp.h"
#include "file.h"
@@ -42,6 +41,7 @@
#include "reel_text_asset.h"
#include "verify.h"
#include "verify_report.h"
+#include <fmt/format.h>
using std::shared_ptr;
@@ -60,7 +60,7 @@ void write_line(File& file, string format)
template <typename... Args>
void write_line(File& file, string format, Args... args)
{
- file.puts(String::compose(format + "\n", std::forward<Args>(args)...).c_str());
+ file.puts(fmt::format(format + "\n", std::forward<Args>(args)...).c_str());
}
@@ -79,12 +79,12 @@ dcp::verify_report(dcp::VerificationResult const& result, Formatter& formatter)
}
auto reel_asset_details = [&formatter](shared_ptr<dcp::ReelAsset> asset) {
- formatter.list_item(String::compose("UUID: %1", asset->id()));
- formatter.list_item(String::compose("Intrinsic duration: %1", asset->intrinsic_duration()));
- formatter.list_item(String::compose("Entry point: %1", asset->entry_point().get_value_or(0)));
- formatter.list_item(String::compose("Duration: %1", asset->duration().get_value_or(0)));
+ formatter.list_item(fmt::format("UUID: {}", asset->id()));
+ formatter.list_item(fmt::format("Intrinsic duration: {}", asset->intrinsic_duration()));
+ formatter.list_item(fmt::format("Entry point: {}", asset->entry_point().get_value_or(0)));
+ formatter.list_item(fmt::format("Duration: {}", asset->duration().get_value_or(0)));
if (asset->annotation_text()) {
- formatter.list_item(String::compose("Annotation text: %1", *asset->annotation_text()));
+ formatter.list_item(fmt::format("Annotation text: {}", *asset->annotation_text()));
}
};
@@ -113,17 +113,17 @@ dcp::verify_report(dcp::VerificationResult const& result, Formatter& formatter)
for (auto dcp: result.dcps) {
auto ul = formatter.unordered_list();
for (auto cpl: dcp->cpls()) {
- formatter.list_item(String::compose("CPL ID: %1", cpl->id()));
+ formatter.list_item(fmt::format("CPL ID: {}", cpl->id()));
int reel_index = 1;
for (auto reel: cpl->reels()) {
- formatter.list_item(String::compose("Reel: %1", reel_index++));
+ formatter.list_item(fmt::format("Reel: {}", reel_index++));
auto ul2 = formatter.unordered_list();
if (auto pic = reel->main_picture()) {
formatter.list_item("Main picture");
auto ul3 = formatter.unordered_list();
reel_asset_details(pic);
- formatter.list_item(String::compose("Frame rate: %1", pic->frame_rate().numerator));
- formatter.list_item(String::compose("Screen aspect ratio: %1x%2", pic->screen_aspect_ratio().numerator, pic->screen_aspect_ratio().denominator));
+ formatter.list_item(fmt::format("Frame rate: {}", pic->frame_rate().numerator));
+ formatter.list_item(fmt::format("Screen aspect ratio: {}x{}", pic->screen_aspect_ratio().numerator, pic->screen_aspect_ratio().denominator));
}
if (auto sound = reel->main_sound()) {
formatter.list_item("Main sound");
@@ -135,7 +135,7 @@ dcp::verify_report(dcp::VerificationResult const& result, Formatter& formatter)
auto ul3 = formatter.unordered_list();
reel_asset_details(sub);
if (sub->language()) {
- formatter.list_item(String::compose("Language: %1", *sub->language()));
+ formatter.list_item(fmt::format("Language: {}", *sub->language()));
}
}
}
diff --git a/src/verify_report.h b/src/verify_report.h
index a8ea4152..46840dea 100644
--- a/src/verify_report.h
+++ b/src/verify_report.h
@@ -19,9 +19,10 @@
*/
-#include "compose.hpp"
#include "file.h"
+#include "util.h"
#include "verify.h"
+#include <fmt/format.h>
#include <boost/filesystem.hpp>
#include <vector>
@@ -201,9 +202,9 @@ public:
void list_item(std::string const& text, boost::optional<std::string> type = {}) override {
if (type) {
- _file.puts(dcp::String::compose("<li class=\"%1\">%2", *type, text).c_str());
+ _file.puts(fmt::format("<li class=\"{}\">{}", *type, text).c_str());
} else {
- _file.puts(dcp::String::compose("<li>%1", text).c_str());
+ _file.puts(fmt::format("<li>{}", text).c_str());
}
}
@@ -217,18 +218,18 @@ public:
std::function<std::string (std::string)> process_filename() override {
return [](std::string s) {
- return String::compose("<code>%1</code>", s);
+ return fmt::format("<code>{}</code>", s);
};
}
private:
void tagged(std::string tag, std::string content) {
- _file.puts(String::compose("<%1>%2</%3>\n", tag, content, tag).c_str());
+ _file.puts(fmt::format("<{}>{}</{}>\n", tag, content, tag).c_str());
};
Wrap wrapped(std::string const& tag) {
- _file.puts(String::compose("<%1>", tag).c_str());
- return Wrap(this, String::compose("</%1>", tag));
+ _file.puts(fmt::format("<{}>", tag).c_str());
+ return Wrap(this, fmt::format("</{}>", tag));
};
};
diff --git a/src/wscript b/src/wscript
index 96f26c6b..dd1d546e 100644
--- a/src/wscript
+++ b/src/wscript
@@ -151,7 +151,6 @@ def build(bld):
chromaticity.h
colour_conversion.h
combine.h
- compose.hpp
content_kind.h
cpl.h
crypto_context.h
diff --git a/test/combine_test.cc b/test/combine_test.cc
index dc72d2d4..bc2b7a22 100644
--- a/test/combine_test.cc
+++ b/test/combine_test.cc
@@ -45,6 +45,7 @@
#include "verify.h"
#include "reel_interop_text_asset.h"
#include "reel_markers_asset.h"
+#include <fmt/core.h>
#include <boost/algorithm/string.hpp>
#include <boost/optional.hpp>
#include <boost/test/unit_test.hpp>
@@ -162,8 +163,8 @@ BOOST_AUTO_TEST_CASE (combine_single_dcp_test)
dcp::combine (
inputs,
out,
- dcp::String::compose("libdcp %1", dcp::version),
- dcp::String::compose("libdcp %1", dcp::version),
+ fmt::format("libdcp {}", dcp::version),
+ fmt::format("libdcp {}", dcp::version),
dcp::LocalTime().as_string(),
"A Test DCP"
);
diff --git a/test/cpl_metadata_test.cc b/test/cpl_metadata_test.cc
index a24fd7e0..d387c178 100644
--- a/test/cpl_metadata_test.cc
+++ b/test/cpl_metadata_test.cc
@@ -33,7 +33,6 @@
#include "certificate_chain.h"
-#include "compose.hpp"
#include "cpl.h"
#include "exceptions.h"
#include "language_tag.h"
diff --git a/test/dcp_test.cc b/test/dcp_test.cc
index 92569430..c5a16800 100644
--- a/test/dcp_test.cc
+++ b/test/dcp_test.cc
@@ -33,7 +33,6 @@
#include "atmos_asset.h"
-#include "compose.hpp"
#include "cpl.h"
#include "dcp.h"
#include "equality_options.h"
@@ -53,6 +52,7 @@
#include "test.h"
#include <asdcp/KM_util.h>
#include <sndfile.h>
+#include <fmt/core.h>
#include <boost/bind/bind.hpp>
#include <boost/test/unit_test.hpp>
@@ -529,7 +529,7 @@ BOOST_AUTO_TEST_CASE(hashes_preserved_when_loading_corrupted_dcp)
new_hash = 'A' + asset_1_hash.substr(1);
}
- editor.insert(after, dcp::String::compose(" <Hash>%1</Hash>", new_hash));
+ editor.insert(after, fmt::format(" <Hash>{}</Hash>", new_hash));
}
dcp::DCP read_back(dir / "1");
diff --git a/test/mca_test.cc b/test/mca_test.cc
index 1cd95732..66b00a4e 100644
--- a/test/mca_test.cc
+++ b/test/mca_test.cc
@@ -32,7 +32,6 @@
*/
-#include "compose.hpp"
#include "cpl.h"
#include "reel.h"
#include "reel_sound_asset.h"
@@ -45,6 +44,7 @@ LIBDCP_DISABLE_WARNINGS
#include <asdcp/Metadata.h>
#include <libxml++/libxml++.h>
LIBDCP_ENABLE_WARNINGS
+#include <fmt/core.h>
#include <boost/test/unit_test.hpp>
@@ -61,10 +61,10 @@ using std::vector;
BOOST_AUTO_TEST_CASE (parse_mca_descriptors_from_mxf_test)
{
for (int i = 1; i < 3; ++i) {
- auto sound_asset = make_shared<dcp::SoundAsset>(private_test / "data" / dcp::String::compose("51_sound_with_mca_%1.mxf", i));
+ auto sound_asset = make_shared<dcp::SoundAsset>(private_test / "data" / fmt::format("51_sound_with_mca_{}.mxf", i));
auto reel_sound_asset = make_shared<dcp::ReelSoundAsset>(sound_asset, 0);
auto reel = make_shared<dcp::Reel>();
- reel->add (black_picture_asset(dcp::String::compose("build/test/parse_mca_descriptors_from_mxf_test%1", i), 24));
+ reel->add (black_picture_asset(fmt::format("build/test/parse_mca_descriptors_from_mxf_test{}", i), 24));
reel->add (reel_sound_asset);
dcp::CPL cpl("", dcp::ContentKind::FEATURE, dcp::Standard::SMPTE);
@@ -73,10 +73,10 @@ BOOST_AUTO_TEST_CASE (parse_mca_descriptors_from_mxf_test)
cpl.set_main_sound_sample_rate(48000);
cpl.set_main_picture_stored_area(dcp::Size(1998, 1080));
cpl.set_main_picture_active_area(dcp::Size(1998, 1080));
- cpl.write_xml (dcp::String::compose("build/test/parse_mca_descriptors_from_mxf_test%1/cpl.xml", i), shared_ptr<dcp::CertificateChain>());
+ cpl.write_xml(fmt::format("build/test/parse_mca_descriptors_from_mxf_test{}/cpl.xml", i), shared_ptr<dcp::CertificateChain>());
- cxml::Document ref("CompositionPlaylist", private_test / dcp::String::compose("51_sound_with_mca_%1.cpl", i));
- cxml::Document check("CompositionPlaylist", dcp::String::compose("build/test/parse_mca_descriptors_from_mxf_test%1/cpl.xml", i));
+ cxml::Document ref("CompositionPlaylist", private_test / fmt::format("51_sound_with_mca_{}.cpl", i));
+ cxml::Document check("CompositionPlaylist", fmt::format("build/test/parse_mca_descriptors_from_mxf_test{}/cpl.xml", i));
vector<string> ignore;
check_xml (
@@ -148,7 +148,7 @@ static
void
check_mca_descriptors(int suffix, vector<dcp::Channel> extra_active_channels, vector<string> expected_mca_tag_symbols)
{
- auto const dir = boost::filesystem::path(dcp::String::compose("build/test/check_mca_descriptors_%1", suffix));
+ auto const dir = boost::filesystem::path(fmt::format("build/test/check_mca_descriptors_{}", suffix));
boost::filesystem::remove_all(dir);
boost::filesystem::create_directories(dir);
diff --git a/test/test.cc b/test/test.cc
index 65649efd..c11d1fc1 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -34,7 +34,6 @@
#define BOOST_TEST_MODULE libdcp_test
-#include "compose.hpp"
#include "cpl.h"
#include "dcp.h"
#include "interop_text_asset.h"
@@ -67,6 +66,7 @@ LIBDCP_ENABLE_WARNINGS
LIBDCP_DISABLE_WARNINGS
#include <libxml++/libxml++.h>
LIBDCP_ENABLE_WARNINGS
+#include <fmt/format.h>
#include <boost/algorithm/string.hpp>
#include <boost/test/unit_test.hpp>
#include <cstdio>
@@ -244,7 +244,7 @@ check_file (boost::filesystem::path ref, boost::filesystem::path check)
if (ref_buffer[i] != check_buffer[i]) {
BOOST_CHECK_MESSAGE (
false,
- dcp::String::compose("File %1 differs from reference %2 at offset %3", check, ref, pos + i)
+ fmt::format("File {} differs from reference {} at offset {}", check.string(), ref.string(), pos + i)
);
break;
}
@@ -283,7 +283,7 @@ simple_picture (boost::filesystem::path path, string suffix, int frames, optiona
if (key) {
mp->set_key (*key);
}
- auto picture_writer = mp->start_write(path / dcp::String::compose("video%1.mxf", suffix), dcp::Behaviour::MAKE_NEW);
+ auto picture_writer = mp->start_write(path / fmt::format("video{}.mxf", suffix), dcp::Behaviour::MAKE_NEW);
dcp::Size const size (1998, 1080);
auto image = make_shared<dcp::OpenJPEGImage>(size);
@@ -311,7 +311,7 @@ simple_sound(boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_m
}
ms->_language = language;
ms->set_metadata (mxf_meta);
- auto sound_writer = ms->start_write(path / dcp::String::compose("audio%1.mxf", suffix), {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
+ auto sound_writer = ms->start_write(path / fmt::format("audio{}.mxf", suffix), {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
int const samples_per_frame = sample_rate / 24;
@@ -364,7 +364,7 @@ make_simple (boost::filesystem::path path, int reels, int frames, dcp::Standard
cpl->set_version_number(1);
for (int i = 0; i < reels; ++i) {
- string suffix = reels == 1 ? "" : dcp::String::compose("%1", i);
+ string suffix = reels == 1 ? "" : fmt::to_string(i);
auto mp = simple_picture (path, suffix, frames, key);
auto ms = simple_sound (path, suffix, mxf_meta, "en-US", frames, sample_rate, key);
diff --git a/test/verify_test.cc b/test/verify_test.cc
index 608409ee..a78b0ccf 100644
--- a/test/verify_test.cc
+++ b/test/verify_test.cc
@@ -32,7 +32,6 @@
*/
-#include "compose.hpp"
#include "cpl.h"
#include "dcp.h"
#include "file.h"
@@ -56,7 +55,7 @@
#include "verify.h"
#include "verify_internal.h"
#include "verify_j2k.h"
-#include <fmt/core.h>
+#include <fmt/format.h>
#include <boost/algorithm/string.hpp>
#include <boost/random.hpp>
#include <boost/test/unit_test.hpp>
@@ -191,9 +190,9 @@ find_asset_map(path dir)
static path
setup (int reference_number, string verify_test_suffix)
{
- auto const dir = dcp::String::compose("build/test/verify_test%1", verify_test_suffix);
+ auto const dir = fmt::format("build/test/verify_test{}", verify_test_suffix);
prepare_directory (dir);
- for (auto i: directory_iterator(dcp::String::compose("test/ref/DCP/dcp_test%1", reference_number))) {
+ for (auto i: directory_iterator(fmt::format("test/ref/DCP/dcp_test{}", reference_number))) {
copy_file (i.path(), dir / i.path().filename());
}
@@ -236,18 +235,18 @@ static
string
to_string(dcp::VerificationNote const& note)
{
- string s = note_to_string(note) + dcp::String::compose(
- "\n [%1 %2 %3 %4 %5 %6 ",
+ string s = note_to_string(note) + fmt::format(
+ "\n [{} {} {} {} {} {} ",
static_cast<int>(note.type()),
static_cast<int>(note.code()),
note.note().get_value_or("<none>"),
- note.file().get_value_or("<none>"),
+ note.file().get_value_or("<none>").string(),
note.line().get_value_or(0),
note.frame().get_value_or(0)
);
- s += dcp::String::compose(
- "%1 %2 %3 %4 %5]\n",
+ s += fmt::format(
+ "{} {} {} {} {}]\n",
note.id().get_value_or("<none>"),
note.other_id().get_value_or("<none>"),
note.cpl_id().get_value_or("<none>"),
@@ -580,7 +579,7 @@ static
path
dcp_test1_cpl_path(string suffix)
{
- return dcp::String::compose("build/test/verify_test%1/%2", suffix, dcp_test1_cpl());
+ return fmt::format("build/test/verify_test{}/{}", suffix, dcp_test1_cpl().string());
}
@@ -588,7 +587,7 @@ static
path
dcp_test1_pkl_path(string suffix)
{
- return dcp::String::compose("build/test/verify_test%1/%2", suffix, dcp_test1_pkl());
+ return fmt::format("build/test/verify_test{}/{}", suffix, dcp_test1_pkl().string());
}
@@ -596,7 +595,7 @@ static
path
asset_map (string suffix)
{
- return dcp::String::compose("build/test/verify_test%1/ASSETMAP.xml", suffix);
+ return fmt::format("build/test/verify_test{}/ASSETMAP.xml", suffix);
}
@@ -606,7 +605,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_picture_frame_rate)
replace(suffix, &dcp_test1_cpl_path, "<FrameRate>24 1", "<FrameRate>99 1");
- auto const dir = dcp::String::compose("build/test/verify_test%1", suffix);
+ auto const dir = fmt::format("build/test/verify_test{}", suffix);
auto const cpl_path = find_cpl(dir);
auto cpl = std::make_shared<dcp::CPL>(cpl_path);
@@ -671,7 +670,7 @@ BOOST_AUTO_TEST_CASE (verify_empty_asset_path)
replace("empty_asset_path", &asset_map, "<Path>video.mxf</Path>", "<Path></Path>");
- auto const dir = dcp::String::compose("build/test/verify_test%1", suffix);
+ auto const dir = fmt::format("build/test/verify_test{}", suffix);
auto const cpl_path = find_cpl(dir);
auto cpl = std::make_shared<dcp::CPL>(cpl_path);
@@ -701,7 +700,7 @@ BOOST_AUTO_TEST_CASE (verify_mismatched_standard)
replace(suffix, &dcp_test1_cpl_path, "http://www.smpte-ra.org/schemas/429-7/2006/CPL", "http://www.digicine.com/PROTO-ASDCP-CPL-20040511#");
- auto const dir = dcp::String::compose("build/test/verify_test%1", suffix);
+ auto const dir = fmt::format("build/test/verify_test{}", suffix);
auto const cpl_path = find_cpl(dir);
auto cpl = std::make_shared<dcp::CPL>(cpl_path);
@@ -756,7 +755,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_xml_cpl_id)
/* There's no MISMATCHED_CPL_HASHES error here because it can't find the correct hash by ID (since the ID is wrong) */
replace("invalid_xml_cpl_id", &dcp_test1_cpl_path, "<Id>urn:uuid:6affb8ee-0020-4dff-a53c-17652f6358ab", "<Id>urn:uuid:6affb8ee-0020-4dff-a53c-17652f6358a");
- auto const dir = dcp::String::compose("build/test/verify_test%1", suffix);
+ auto const dir = fmt::format("build/test/verify_test{}", suffix);
auto const cpl_path = find_cpl(dir);
auto cpl = std::make_shared<dcp::CPL>(cpl_path);
@@ -792,7 +791,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_xml_issue_date)
replace("invalid_xml_issue_date", &dcp_test1_cpl_path, "<IssueDate>", "<IssueDate>x");
- auto const dir = dcp::String::compose("build/test/verify_test%1", suffix);
+ auto const dir = fmt::format("build/test/verify_test{}", suffix);
auto const cpl_path = find_cpl(dir);
auto cpl = std::make_shared<dcp::CPL>(cpl_path);
@@ -830,7 +829,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_xml_pkl_id)
replace("invalid_xml_pkl_id", &dcp_test1_pkl_path, "<Id>urn:uuid:" + dcp_test1_pkl_id().substr(0, 3), "<Id>urn:uuid:x" + dcp_test1_pkl_id().substr(1, 2));
- auto const dir = dcp::String::compose("build/test/verify_test%1", suffix);
+ auto const dir = fmt::format("build/test/verify_test{}", suffix);
auto const pkl_path = find_pkl(dir);
auto const cpl_path = find_cpl(dir);
auto cpl = std::make_shared<dcp::CPL>(cpl_path);
@@ -868,7 +867,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_xml_asset_map_id)
replace("invalid_xml_asset_map_id", &asset_map, "<Id>urn:uuid:" + dcp_test1_asset_map_id.substr(0, 3), "<Id>urn:uuid:x" + dcp_test1_asset_map_id.substr(1, 2));
- auto const dir = dcp::String::compose("build/test/verify_test%1", suffix);
+ auto const dir = fmt::format("build/test/verify_test{}", suffix);
auto const cpl_path = find_cpl(dir);
auto const asset_map_path = find_asset_map(dir);
auto cpl = std::make_shared<dcp::CPL>(cpl_path);
@@ -1891,7 +1890,7 @@ check_picture_size_ok (int width, int height, int frame_rate, bool three_d)
dcp::VerificationNote(
dcp::VerificationNote::Type::OK,
dcp::VerificationNote::Code::VALID_MAIN_PICTURE_ACTIVE_AREA,
- dcp::String::compose("%1x%2", width, height),
+ fmt::format("{}x{}", width, height),
cpl->file().get()
).set_cpl_id(cpl->id()),
ok(dcp::VerificationNote::Code::CORRECT_PICTURE_HASH, canonical(dir / "video.mxf"), cpl),
@@ -1920,13 +1919,13 @@ check_picture_size_bad_frame_size (int width, int height, int frame_rate, bool t
dcp::VerificationNote(
dcp::VerificationNote::Type::OK,
dcp::VerificationNote::Code::VALID_MAIN_PICTURE_ACTIVE_AREA,
- dcp::String::compose("%1x%2", width, height),
+ fmt::format("{}x{}", width, height),
cpl->file().get()
).set_cpl_id(cpl->id()),
ok(dcp::VerificationNote::Code::CORRECT_PICTURE_HASH, canonical(dir / "video.mxf"), cpl),
ok(dcp::VerificationNote::Code::VALID_PICTURE_FRAME_SIZES_IN_BYTES, canonical(dir / "video.mxf"), cpl),
dcp::VerificationNote(
- dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_SIZE_IN_PIXELS, dcp::String::compose("%1x%2", width, height), canonical(dir / "video.mxf")
+ dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_SIZE_IN_PIXELS, fmt::format("{}x{}", width, height), canonical(dir / "video.mxf")
).set_cpl_id(cpl->id())
};
check_verify_result(notes, expected);
@@ -1952,16 +1951,16 @@ check_picture_size_bad_2k_frame_rate (int width, int height, int frame_rate, boo
dcp::VerificationNote(
dcp::VerificationNote::Type::OK,
dcp::VerificationNote::Code::VALID_MAIN_PICTURE_ACTIVE_AREA,
- dcp::String::compose("%1x%2", width, height),
+ fmt::format("{}x{}", width, height),
cpl->file().get()
).set_cpl_id(cpl->id()),
ok(dcp::VerificationNote::Code::CORRECT_PICTURE_HASH, canonical(dir / "video.mxf"), cpl),
ok(dcp::VerificationNote::Code::VALID_PICTURE_FRAME_SIZES_IN_BYTES, canonical(dir / "video.mxf"), cpl),
dcp::VerificationNote(
- dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE, dcp::String::compose("%1/1", frame_rate * (three_d ? 2 : 1))
+ dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE, fmt::format("{}/1", frame_rate * (three_d ? 2 : 1))
).set_cpl_id(cpl->id()),
dcp::VerificationNote(
- dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_2K, dcp::String::compose("%1/1", frame_rate), canonical(dir / "video.mxf")
+ dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_2K, fmt::format("{}/1", frame_rate), canonical(dir / "video.mxf")
).set_cpl_id(cpl->id())
};
@@ -1988,13 +1987,13 @@ check_picture_size_bad_4k_frame_rate (int width, int height, int frame_rate, boo
dcp::VerificationNote(
dcp::VerificationNote::Type::OK,
dcp::VerificationNote::Code::VALID_MAIN_PICTURE_ACTIVE_AREA,
- dcp::String::compose("%1x%2", width, height),
+ fmt::format("{}x{}", width, height),
cpl->file().get()
).set_cpl_id(cpl->id()),
ok(dcp::VerificationNote::Code::CORRECT_PICTURE_HASH, canonical(dir / "video.mxf"), cpl),
ok(dcp::VerificationNote::Code::VALID_PICTURE_FRAME_SIZES_IN_BYTES, canonical(dir / "video.mxf"), cpl),
dcp::VerificationNote(
- dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_4K, dcp::String::compose("%1/1", frame_rate), canonical(dir / "video.mxf")
+ dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_4K, fmt::format("{}/1", frame_rate), canonical(dir / "video.mxf")
).set_cpl_id(cpl->id())
};
@@ -2154,7 +2153,7 @@ make_large_subtitle_asset (path font_file)
dcp::ArrayData big_fake_font(1024 * 1024);
big_fake_font.write (font_file);
for (int i = 0; i < 116; ++i) {
- asset->add_font (dcp::String::compose("big%1", i), big_fake_font);
+ asset->add_font(fmt::format("big{}", i), big_fake_font);
}
return asset;
}
@@ -4824,10 +4823,10 @@ BOOST_AUTO_TEST_CASE (verify_mismatched_subtitle_resource_id)
auto subs_mxf = dir / "subs.mxf";
auto r = writer.OpenWrite(subs_mxf.string().c_str(), writer_info, descriptor, 4096);
BOOST_REQUIRE (ASDCP_SUCCESS(r));
- writer.WriteTimedTextResource (dcp::String::compose(
+ writer.WriteTimedTextResource(fmt::format(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<SubtitleReel xmlns=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\">"
- "<Id>urn:uuid:%1</Id>"
+ "<Id>urn:uuid:{}</Id>"
"<ContentTitleText>Content</ContentTitleText>"
"<AnnotationText>Annotation</AnnotationText>"
"<IssueDate>2018-10-02T12:25:14</IssueDate>"
@@ -4904,10 +4903,10 @@ BOOST_AUTO_TEST_CASE (verify_incorrect_timed_text_id)
auto subs_mxf = dir / "subs.mxf";
auto r = writer.OpenWrite(subs_mxf.string().c_str(), writer_info, descriptor, 4096);
BOOST_REQUIRE (ASDCP_SUCCESS(r));
- writer.WriteTimedTextResource (dcp::String::compose(
+ writer.WriteTimedTextResource(fmt::format(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<SubtitleReel xmlns=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\">"
- "<Id>urn:uuid:%1</Id>"
+ "<Id>urn:uuid:{}</Id>"
"<ContentTitleText>Content</ContentTitleText>"
"<AnnotationText>Annotation</AnnotationText>"
"<IssueDate>2018-10-02T12:25:14+02:00</IssueDate>"
diff --git a/tools/dcpinfo.cc b/tools/dcpinfo.cc
index 8a7f738e..5277d5cf 100644
--- a/tools/dcpinfo.cc
+++ b/tools/dcpinfo.cc
@@ -33,7 +33,6 @@
#include "common.h"
-#include "compose.hpp"
#include "cpl.h"
#include "dcp.h"
#include "decrypted_kdm.h"
@@ -53,6 +52,7 @@
#include "text_image.h"
#include "text_string.h"
#include <getopt.h>
+#include <fmt/core.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <iostream>
@@ -104,16 +104,16 @@ mbits_per_second (int size, Fraction frame_rate)
return size * 8 * frame_rate.as_float() / 1e6;
}
-#define OUTPUT_DCP_PATH(...) maybe_output(only, "dcp-path", String::compose(__VA_ARGS__));
-#define OUTPUT_CPL_NAME_ID(...) maybe_output(only, "cpl-name-id", String::compose(__VA_ARGS__));
-#define OUTPUT_PICTURE(...) maybe_output(only, "picture", String::compose(__VA_ARGS__));
+#define OUTPUT_DCP_PATH(...) maybe_output(only, "dcp-path", fmt::format(__VA_ARGS__));
+#define OUTPUT_CPL_NAME_ID(...) maybe_output(only, "cpl-name-id", fmt::format(__VA_ARGS__));
+#define OUTPUT_PICTURE(...) maybe_output(only, "picture", fmt::format(__VA_ARGS__));
#define OUTPUT_PICTURE_NC(x) maybe_output(only, "picture", (x));
#define SHOULD_PICTURE should_output(only, "picture")
-#define OUTPUT_SOUND(...) maybe_output(only, "sound", String::compose(__VA_ARGS__));
+#define OUTPUT_SOUND(...) maybe_output(only, "sound", fmt::format(__VA_ARGS__));
#define OUTPUT_SOUND_NC(x) maybe_output(only, "sound", (x));
-#define OUTPUT_SUBTITLE(...) maybe_output(only, "subtitle", String::compose(__VA_ARGS__));
+#define OUTPUT_SUBTITLE(...) maybe_output(only, "subtitle", fmt::format(__VA_ARGS__));
#define OUTPUT_SUBTITLE_NC(x) maybe_output(only, "subtitle", (x));
-#define OUTPUT_TOTAL_TIME(...) maybe_output(only, "total-time", String::compose(__VA_ARGS__));
+#define OUTPUT_TOTAL_TIME(...) maybe_output(only, "total-time", fmt::format(__VA_ARGS__));
static bool
should_output(vector<string> const& only, string t)
@@ -138,24 +138,24 @@ main_picture (vector<string> const& only, shared_ptr<Reel> reel, bool analyse, b
return dcp::Time();
}
- OUTPUT_PICTURE(" Picture ID: %1", mp->id());
+ OUTPUT_PICTURE(" Picture ID: {}", mp->id());
if (mp->entry_point()) {
- OUTPUT_PICTURE(" entry %1", *mp->entry_point());
+ OUTPUT_PICTURE(" entry {}", *mp->entry_point());
}
if (mp->duration()) {
OUTPUT_PICTURE(
- " duration %1 (%2) intrinsic %3",
+ " duration {} ({}) intrinsic {}",
*mp->duration(),
dcp::Time(*mp->duration(), mp->frame_rate().as_float(), mp->frame_rate().as_float()).as_string(dcp::Standard::SMPTE),
mp->intrinsic_duration()
);
} else {
- OUTPUT_PICTURE(" intrinsic duration %1", mp->intrinsic_duration());
+ OUTPUT_PICTURE(" intrinsic duration {}", mp->intrinsic_duration());
}
if (mp->asset_ref().resolved()) {
if (mp->asset()) {
- OUTPUT_PICTURE("\n Picture: %1x%2\n", mp->asset()->size().width, mp->asset()->size().height);
+ OUTPUT_PICTURE("\n Picture: {}x{}\n", mp->asset()->size().width, mp->asset()->size().height);
}
shared_ptr<MonoJ2KPictureAsset> ma = dynamic_pointer_cast<MonoJ2KPictureAsset>(mp->asset());
@@ -216,20 +216,20 @@ main_sound (vector<string> const& only, shared_ptr<Reel> reel)
return;
}
- OUTPUT_SOUND(" Sound ID: %1", ms->id());
+ OUTPUT_SOUND(" Sound ID: {}", ms->id());
if (ms->entry_point()) {
- OUTPUT_SOUND(" entry %1", *ms->entry_point());
+ OUTPUT_SOUND(" entry {}", *ms->entry_point());
}
if (ms->duration()) {
- OUTPUT_SOUND(" duration %1 intrinsic %2", *ms->duration(), ms->intrinsic_duration());
+ OUTPUT_SOUND(" duration {} intrinsic {}", *ms->duration(), ms->intrinsic_duration());
} else {
- OUTPUT_SOUND(" intrinsic duration %1", ms->intrinsic_duration());
+ OUTPUT_SOUND(" intrinsic duration {}", ms->intrinsic_duration());
}
if (ms->asset_ref().resolved()) {
if (ms->asset()) {
OUTPUT_SOUND(
- "\n Sound: %1 channels at %2Hz\n",
+ "\n Sound: {} channels at {}Hz\n",
ms->asset()->channels(),
ms->asset()->sampling_rate()
);
@@ -248,18 +248,18 @@ main_subtitle (vector<string> const& only, shared_ptr<Reel> reel, bool list_subt
return;
}
- OUTPUT_SUBTITLE(" Subtitle ID: %1", ms->id());
+ OUTPUT_SUBTITLE(" Subtitle ID: {}", ms->id());
if (ms->asset_ref().resolved()) {
auto subs = ms->asset()->texts();
- OUTPUT_SUBTITLE("\n Subtitle: %1 subtitles", subs.size());
+ OUTPUT_SUBTITLE("\n Subtitle: {} subtitles", subs.size());
auto iop = dynamic_pointer_cast<InteropTextAsset>(ms->asset());
if (iop) {
- OUTPUT_SUBTITLE(" in %1\n", iop->language());
+ OUTPUT_SUBTITLE(" in {}\n", iop->language());
}
auto smpte = dynamic_pointer_cast<SMPTETextAsset>(ms->asset());
if (smpte && smpte->language ()) {
- OUTPUT_SUBTITLE(" in %1\n", smpte->language().get());
+ OUTPUT_SUBTITLE(" in {}\n", smpte->language().get());
}
if (list_subtitles) {
for (auto k: subs) {
@@ -267,13 +267,13 @@ main_subtitle (vector<string> const& only, shared_ptr<Reel> reel, bool list_subt
if (ks) {
stringstream s;
s << *ks;
- OUTPUT_SUBTITLE("%1\n", s.str());
+ OUTPUT_SUBTITLE("{}\n", s.str());
}
auto is = dynamic_pointer_cast<const TextImage>(k);
if (is) {
stringstream s;
s << *is;
- OUTPUT_SUBTITLE("%1\n", s.str());
+ OUTPUT_SUBTITLE("{}\n", s.str());
}
}
}
@@ -384,7 +384,7 @@ main (int argc, char* argv[])
exit (EXIT_FAILURE);
}
- OUTPUT_DCP_PATH("DCP: %1\n", boost::filesystem::path(argv[optind]).string());
+ OUTPUT_DCP_PATH("DCP: {}\n", boost::filesystem::path(argv[optind]).string());
dcp::filter_notes (notes, ignore_missing_assets);
for (auto i: notes) {
@@ -400,7 +400,7 @@ main (int argc, char* argv[])
dcp::Time total_time;
for (auto i: cpls) {
- OUTPUT_CPL_NAME_ID(" CPL: %1 %2\n", i->annotation_text().get_value_or(""), i->id());
+ OUTPUT_CPL_NAME_ID(" CPL: {} {}\n", i->annotation_text().get_value_or(""), i->id());
int R = 1;
for (auto j: i->reels()) {
@@ -436,7 +436,7 @@ main (int argc, char* argv[])
}
}
- OUTPUT_TOTAL_TIME("Total: %1\n", total_time.as_string(dcp::Standard::SMPTE));
+ OUTPUT_TOTAL_TIME("Total: {}\n", total_time.as_string(dcp::Standard::SMPTE));
return 0;
}
diff --git a/tools/dcpverify.cc b/tools/dcpverify.cc
index 88f0d705..81c3bcf6 100644
--- a/tools/dcpverify.cc
+++ b/tools/dcpverify.cc
@@ -33,7 +33,6 @@
#include "common.h"
-#include "compose.hpp"
#include "filesystem.h"
#include "raw_convert.h"
#include "verify.h"