From: Carl Hetherington Date: Fri, 22 Jan 2021 00:39:22 +0000 (+0100) Subject: Assorted c++11 cleanups. X-Git-Tag: v1.8.0~122 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=5fbcd3a8dc711c6c42efabbac72ab0408f504ea2;p=libdcp.git Assorted c++11 cleanups. --- diff --git a/src/certificate_chain.cc b/src/certificate_chain.cc index 2287a805..9f4c5ea7 100644 --- a/src/certificate_chain.cc +++ b/src/certificate_chain.cc @@ -54,7 +54,6 @@ #include #include #include -#include #include #include @@ -634,14 +633,14 @@ void CertificateChain::add_signature_value (xmlpp::Element* parent, string ns, bool add_indentation) const { cxml::Node cp (parent); - xmlpp::Node* key_info = cp.node_child("KeyInfo")->node (); + auto key_info = cp.node_child("KeyInfo")->node(); /* Add the certificate chain to the KeyInfo child node of parent */ - BOOST_FOREACH (Certificate const & i, leaf_to_root ()) { - xmlpp::Element* data = key_info->add_child("X509Data", ns); + for (auto const& i: leaf_to_root()) { + auto data = key_info->add_child("X509Data", ns); { - xmlpp::Element* serial = data->add_child("X509IssuerSerial", ns); + auto serial = data->add_child("X509IssuerSerial", ns); serial->add_child("X509IssuerName", ns)->add_child_text (i.issuer ()); serial->add_child("X509SerialNumber", ns)->add_child_text (i.serial ()); } @@ -649,7 +648,7 @@ CertificateChain::add_signature_value (xmlpp::Element* parent, string ns, bool a data->add_child("X509Certificate", ns)->add_child_text (i.certificate()); } - xmlSecDSigCtxPtr signature_context = xmlSecDSigCtxCreate (0); + auto signature_context = xmlSecDSigCtxCreate (0); if (signature_context == 0) { throw MiscError ("could not create signature context"); } @@ -677,7 +676,7 @@ string CertificateChain::chain () const { string o; - BOOST_FOREACH (Certificate const &i, root_to_leaf ()) { + for (auto const& i: root_to_leaf()) { o += i.certificate(true); } diff --git a/src/combine.cc b/src/combine.cc index cd91d5b1..c2cae547 100644 --- a/src/combine.cc +++ b/src/combine.cc @@ -42,7 +42,6 @@ #include "interop_subtitle_asset.h" #include "raw_convert.h" #include -#include #include #include #include @@ -110,7 +109,7 @@ dcp::combine ( DCP output_dcp (output); optional standard; - BOOST_FOREACH (path i, inputs) { + for (auto i: inputs) { DCP dcp (i); dcp.read (); if (!standard) { @@ -123,15 +122,15 @@ dcp::combine ( vector paths; vector> assets; - BOOST_FOREACH (path i, inputs) { + for (auto i: inputs) { DCP dcp (i); dcp.read (); - BOOST_FOREACH (shared_ptr j, dcp.cpls()) { + for (auto j: dcp.cpls()) { output_dcp.add (j); } - BOOST_FOREACH (shared_ptr j, dcp.assets(true)) { + for (auto j: dcp.assets(true)) { if (dynamic_pointer_cast(j)) { continue; } diff --git a/src/decrypted_kdm.cc b/src/decrypted_kdm.cc index 10da80e6..0a3eeabd 100644 --- a/src/decrypted_kdm.cc +++ b/src/decrypted_kdm.cc @@ -47,7 +47,6 @@ #include #include #include -#include using std::list; using std::vector; @@ -143,7 +142,7 @@ DecryptedKDM::DecryptedKDM (EncryptedKDM const & kdm, string private_key) /* Use the private key to decrypt the keys */ - BOOST_FOREACH (string const & i, kdm.keys ()) { + for (auto const& i: kdm.keys()) { /* Decode the base-64-encoded cipher value from the KDM */ unsigned char cipher_value[256]; int const cipher_value_len = base64_decode (i, cipher_value, sizeof (cipher_value)); @@ -312,7 +311,7 @@ DecryptedKDM::encrypt ( { DCP_ASSERT (!_keys.empty ()); - BOOST_FOREACH (dcp::Certificate i, signer->leaf_to_root()) { + for (auto i: signer->leaf_to_root()) { if (day_greater_than_or_equal(dcp::LocalTime(i.not_before()), _not_valid_before)) { throw BadKDMDateError (true); } else if (day_less_than_or_equal(dcp::LocalTime(i.not_after()), _not_valid_after)) { @@ -322,7 +321,7 @@ DecryptedKDM::encrypt ( vector> key_ids; vector keys; - BOOST_FOREACH (DecryptedKDMKey const & i, _keys) { + for (auto const& i: _keys) { /* We're making SMPTE keys so we must have a type for each one */ DCP_ASSERT (i.type()); key_ids.push_back (make_pair (i.type().get(), i.id ())); diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc index f93e7cf4..9c977b44 100644 --- a/src/interop_subtitle_asset.cc +++ b/src/interop_subtitle_asset.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2018 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of libdcp. @@ -42,7 +42,6 @@ #include "compose.hpp" #include "subtitle_image.h" #include -#include #include #include #include @@ -55,6 +54,7 @@ using std::map; using std::shared_ptr; using std::dynamic_pointer_cast; using std::vector; +using std::make_shared; using boost::shared_array; using boost::optional; using namespace dcp; @@ -83,8 +83,8 @@ InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file) } } - BOOST_FOREACH (shared_ptr i, _subtitles) { - shared_ptr si = dynamic_pointer_cast(i); + for (auto i: _subtitles) { + auto si = dynamic_pointer_cast(i); if (si) { si->read_png_file (file.parent_path() / String::compose("%1.png", si->id())); } @@ -192,16 +192,16 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const _file = p; /* Image subtitles */ - BOOST_FOREACH (shared_ptr i, _subtitles) { - shared_ptr im = dynamic_pointer_cast (i); + for (auto i: _subtitles) { + auto im = dynamic_pointer_cast (i); if (im) { im->write_png_file(p.parent_path() / String::compose("%1.png", im->id())); } } /* Fonts */ - BOOST_FOREACH (shared_ptr i, _load_font_nodes) { - boost::filesystem::path file = p.parent_path() / i->uri; + for (auto i: _load_font_nodes) { + auto file = p.parent_path() / i->uri; auto j = _fonts.begin(); while (j != _fonts.end() && j->load_id != i->id) { ++j; @@ -220,15 +220,15 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const void InteropSubtitleAsset::resolve_fonts (vector> assets) { - BOOST_FOREACH (shared_ptr i, assets) { - shared_ptr font = dynamic_pointer_cast (i); + for (auto i: assets) { + auto font = dynamic_pointer_cast (i); if (!font) { continue; } - BOOST_FOREACH (shared_ptr j, _load_font_nodes) { + for (auto j: _load_font_nodes) { bool got = false; - BOOST_FOREACH (Font const & k, _fonts) { + for (auto const& k: _fonts) { if (k.load_id == j->id) { got = true; break; @@ -245,9 +245,9 @@ InteropSubtitleAsset::resolve_fonts (vector> assets) void InteropSubtitleAsset::add_font_assets (vector>& assets) { - BOOST_FOREACH (Font const & i, _fonts) { + for (auto const& i: _fonts) { DCP_ASSERT (i.file); - assets.push_back (shared_ptr (new FontAsset (i.uuid, i.file.get ()))); + assets.push_back (make_shared(i.uuid, i.file.get())); } } @@ -256,8 +256,8 @@ InteropSubtitleAsset::write_to_assetmap (xmlpp::Node* node, boost::filesystem::p { Asset::write_to_assetmap (node, root); - BOOST_FOREACH (shared_ptr i, _subtitles) { - shared_ptr im = dynamic_pointer_cast (i); + for (auto i: _subtitles) { + auto im = dynamic_pointer_cast (i); if (im) { DCP_ASSERT (im->file()); write_file_to_assetmap (node, root, im->file().get(), im->id()); @@ -270,10 +270,10 @@ InteropSubtitleAsset::add_to_pkl (shared_ptr pkl, boost::filesystem::path r { Asset::add_to_pkl (pkl, root); - BOOST_FOREACH (shared_ptr i, _subtitles) { - shared_ptr im = dynamic_pointer_cast (i); + for (auto i: _subtitles) { + auto im = dynamic_pointer_cast (i); if (im) { - ArrayData png_image = im->png_image (); + auto png_image = im->png_image (); pkl->add_asset (im->id(), optional(), make_digest(png_image), png_image.size(), "image/png"); } } @@ -283,13 +283,13 @@ InteropSubtitleAsset::add_to_pkl (shared_ptr pkl, boost::filesystem::path r void InteropSubtitleAsset::set_font_file (string load_id, boost::filesystem::path file) { - BOOST_FOREACH (Font& i, _fonts) { + for (auto& i: _fonts) { if (i.load_id == load_id) { i.file = file; } } - BOOST_FOREACH (shared_ptr i, _load_font_nodes) { + for (auto i: _load_font_nodes) { if (i->id == load_id) { i->uri = file.filename().string(); } diff --git a/src/language_tag.cc b/src/language_tag.cc index 148e054b..07e95564 100644 --- a/src/language_tag.cc +++ b/src/language_tag.cc @@ -37,7 +37,6 @@ #include "exceptions.h" #include "language_tag.h" #include -#include #include @@ -62,7 +61,7 @@ static optional find_in_list (vector const& list, string subtag) { - BOOST_FOREACH (LanguageTag::SubtagData const& i, list) { + for (auto const& i: list) { if (boost::iequals(i.subtag, subtag)) { return i; } @@ -158,11 +157,11 @@ LanguageTag::to_string () const s += "-" + _region->subtag(); } - BOOST_FOREACH (VariantSubtag i, _variants) { + for (auto i: _variants) { s += "-" + i.subtag(); } - BOOST_FOREACH (ExtlangSubtag i, _extlangs) { + for (auto i: _extlangs) { s += "-" + i.subtag(); } @@ -254,13 +253,13 @@ LanguageTag::description () const string d; - BOOST_FOREACH (VariantSubtag const& i, _variants) { + for (auto const& i: _variants) { optional variant = get_subtag_data (SubtagType::VARIANT, i.subtag()); DCP_ASSERT (variant); d += variant->description + " dialect of "; } - optional language = get_subtag_data (SubtagType::LANGUAGE, _language->subtag()); + auto language = get_subtag_data (SubtagType::LANGUAGE, _language->subtag()); DCP_ASSERT (language); d += language->description; @@ -276,7 +275,7 @@ LanguageTag::description () const d += " for " + region->description; } - BOOST_FOREACH (ExtlangSubtag const& i, _extlangs) { + for (auto const& i: _extlangs) { optional extlang = get_subtag_data (SubtagType::EXTLANG, i.subtag()); DCP_ASSERT (extlang); d += ", " + extlang->description; @@ -371,7 +370,7 @@ dcp::operator<< (ostream& os, dcp::LanguageTag const& tag) vector > LanguageTag::subtags () const { - vector > s; + vector> s; if (_language) { s.push_back (make_pair(SubtagType::LANGUAGE, *get_subtag_data(SubtagType::LANGUAGE, _language->subtag()))); @@ -385,11 +384,11 @@ LanguageTag::subtags () const s.push_back (make_pair(SubtagType::REGION, *get_subtag_data(SubtagType::REGION, _region->subtag()))); } - BOOST_FOREACH (VariantSubtag const& i, _variants) { + for (auto const& i: _variants) { s.push_back (make_pair(SubtagType::VARIANT, *get_subtag_data(SubtagType::VARIANT, i.subtag()))); } - BOOST_FOREACH (ExtlangSubtag const& i, _extlangs) { + for (auto const& i: _extlangs) { s.push_back (make_pair(SubtagType::EXTLANG, *get_subtag_data(SubtagType::EXTLANG, i.subtag()))); } diff --git a/src/mono_picture_asset.cc b/src/mono_picture_asset.cc index 4524c85d..89661061 100644 --- a/src/mono_picture_asset.cc +++ b/src/mono_picture_asset.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of libdcp. @@ -47,6 +47,7 @@ using std::list; using std::pair; using std::shared_ptr; using std::dynamic_pointer_cast; +using std::make_shared; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif @@ -56,21 +57,21 @@ MonoPictureAsset::MonoPictureAsset (boost::filesystem::path file) : PictureAsset (file) { ASDCP::JP2K::MXFReader reader; - Kumu::Result_t r = reader.OpenRead (file.string().c_str()); - if (ASDCP_FAILURE (r)) { - boost::throw_exception (MXFFileError ("could not open MXF file for reading", file.string(), r)); + auto r = reader.OpenRead (file.string().c_str()); + if (ASDCP_FAILURE(r)) { + boost::throw_exception (MXFFileError("could not open MXF file for reading", file.string(), r)); } ASDCP::JP2K::PictureDescriptor desc; - if (ASDCP_FAILURE (reader.FillPictureDescriptor (desc))) { - boost::throw_exception (ReadError ("could not read video MXF information")); + if (ASDCP_FAILURE (reader.FillPictureDescriptor(desc))) { + boost::throw_exception (ReadError("could not read video MXF information")); } read_picture_descriptor (desc); ASDCP::WriterInfo info; if (ASDCP_FAILURE (reader.FillWriterInfo (info))) { - boost::throw_exception (ReadError ("could not read video MXF information")); + boost::throw_exception (ReadError("could not read video MXF information")); } _id = read_writer_info (info); @@ -91,15 +92,15 @@ storing_note_handler (list >& notes, NoteType t, string s bool MonoPictureAsset::equals (shared_ptr other, EqualityOptions opt, NoteHandler note) const { - if (!dynamic_pointer_cast (other)) { + if (!dynamic_pointer_cast(other)) { return false; } ASDCP::JP2K::MXFReader reader_A; DCP_ASSERT (_file); - Kumu::Result_t r = reader_A.OpenRead (_file->string().c_str()); - if (ASDCP_FAILURE (r)) { - boost::throw_exception (MXFFileError ("could not open MXF file for reading", _file->string(), r)); + auto r = reader_A.OpenRead (_file->string().c_str()); + if (ASDCP_FAILURE(r)) { + boost::throw_exception (MXFFileError("could not open MXF file for reading", _file->string(), r)); } ASDCP::JP2K::MXFReader reader_B; @@ -122,13 +123,13 @@ MonoPictureAsset::equals (shared_ptr other, EqualityOptions opt, No return false; } - shared_ptr other_picture = dynamic_pointer_cast (other); + auto other_picture = dynamic_pointer_cast (other); DCP_ASSERT (other_picture); bool result = true; - shared_ptr reader = start_read (); - shared_ptr other_reader = other_picture->start_read (); + auto reader = start_read (); + auto other_reader = other_picture->start_read (); #ifdef LIBDCP_OPENMP #pragma omp parallel for @@ -141,8 +142,8 @@ MonoPictureAsset::equals (shared_ptr other, EqualityOptions opt, No if (result || opt.keep_going) { - shared_ptr frame_A = reader->get_frame (i); - shared_ptr frame_B = other_reader->get_frame (i); + auto frame_A = reader->get_frame (i); + auto frame_B = other_reader->get_frame (i); list > notes; @@ -159,8 +160,8 @@ MonoPictureAsset::equals (shared_ptr other, EqualityOptions opt, No #endif { note (NoteType::PROGRESS, String::compose("Compared video frame %1 of %2", i, _intrinsic_duration)); - for (list >::const_iterator i = notes.begin(); i != notes.end(); ++i) { - note (i->first, i->second); + for (auto const& i: notes) { + note (i.first, i.second); } } } @@ -172,14 +173,13 @@ MonoPictureAsset::equals (shared_ptr other, EqualityOptions opt, No shared_ptr MonoPictureAsset::start_write (boost::filesystem::path file, bool overwrite) { - /* XXX: can't we use shared_ptr here? */ - return shared_ptr (new MonoPictureAssetWriter (this, file, overwrite)); + return make_shared(this, file, overwrite); } shared_ptr MonoPictureAsset::start_read () const { - return shared_ptr (new MonoPictureAssetReader (this, key(), standard())); + return make_shared(this, key(), standard()); } string diff --git a/src/mono_picture_asset_writer.h b/src/mono_picture_asset_writer.h index 2dce922e..a5799d27 100644 --- a/src/mono_picture_asset_writer.h +++ b/src/mono_picture_asset_writer.h @@ -59,6 +59,8 @@ namespace dcp { class MonoPictureAssetWriter : public PictureAssetWriter { public: + MonoPictureAssetWriter (PictureAsset *, boost::filesystem::path file, bool); + FrameInfo write (uint8_t const *, int); void fake_write (int size); bool finalize (); @@ -66,13 +68,11 @@ public: private: friend class MonoPictureAsset; - MonoPictureAssetWriter (PictureAsset *, boost::filesystem::path file, bool); void start (uint8_t const *, int); /* do this with an opaque pointer so we don't have to include ASDCP headers */ - struct ASDCPState; std::shared_ptr _state; }; diff --git a/src/name_format.cc b/src/name_format.cc index 76cca3fd..11b68e19 100644 --- a/src/name_format.cc +++ b/src/name_format.cc @@ -33,7 +33,6 @@ #include "name_format.h" #include -#include using std::string; using std::map; diff --git a/src/pkl.cc b/src/pkl.cc index b439e8bd..0f62b4a2 100644 --- a/src/pkl.cc +++ b/src/pkl.cc @@ -37,7 +37,6 @@ #include "raw_convert.h" #include "dcp_assert.h" #include -#include #include using std::string; diff --git a/src/reel.cc b/src/reel.cc index efb161bb..25019d35 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -50,7 +50,6 @@ #include "reel_atmos_asset.h" #include "reel_closed_caption_asset.h" #include -#include #include /* Centos 6 does not have this */ diff --git a/src/reel_markers_asset.cc b/src/reel_markers_asset.cc index ba0021cf..1f9282fa 100644 --- a/src/reel_markers_asset.cc +++ b/src/reel_markers_asset.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019 Carl Hetherington + Copyright (C) 2019-2021 Carl Hetherington This file is part of libdcp. @@ -35,7 +35,6 @@ #include "raw_convert.h" #include "dcp_assert.h" #include -#include using std::string; using std::map; @@ -53,9 +52,9 @@ ReelMarkersAsset::ReelMarkersAsset (Fraction edit_rate, int64_t intrinsic_durati ReelMarkersAsset::ReelMarkersAsset (cxml::ConstNodePtr node) : ReelAsset (node) { - cxml::ConstNodePtr list = node->node_child ("MarkerList"); + auto list = node->node_child ("MarkerList"); DCP_ASSERT (list); - BOOST_FOREACH (cxml::ConstNodePtr i, list->node_children("Marker")) { + for (auto i: list->node_children("Marker")) { set (marker_from_string(i->string_child("Label")), dcp::Time(i->number_child("Offset"), edit_rate().as_float(), edit_rate().numerator)); } } diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc index 49ccc5a9..2c53cbb3 100644 --- a/src/smpte_subtitle_asset.cc +++ b/src/smpte_subtitle_asset.cc @@ -49,7 +49,6 @@ #include #include #include -#include #include using std::string; @@ -126,11 +125,11 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file) /* Try to read PNG files from the same folder that the XML is in; the wisdom of this is debatable, at best... */ - BOOST_FOREACH (shared_ptr i, _subtitles) { - shared_ptr im = dynamic_pointer_cast(i); + for (auto i: _subtitles) { + auto im = dynamic_pointer_cast(i); if (im && im->png_image().size() == 0) { /* Even more dubious; allow .png or urn:uuid:.png */ - boost::filesystem::path p = file.parent_path() / String::compose("%1.png", im->id()); + auto p = file.parent_path() / String::compose("%1.png", im->id()); if (boost::filesystem::is_regular_file(p)) { im->read_png_file (p); } else if (starts_with (im->id(), "urn:uuid:")) { @@ -145,8 +144,8 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file) } /* Check that all required image data have been found */ - BOOST_FOREACH (shared_ptr i, _subtitles) { - shared_ptr im = dynamic_pointer_cast(i); + for (auto i: _subtitles) { + auto im = dynamic_pointer_cast(i); if (im && im->png_image().size() == 0) { throw MissingSubtitleImageError (im->id()); } @@ -166,7 +165,7 @@ SMPTESubtitleAsset::parse_xml (shared_ptr xml) _language = xml->optional_string_child ("Language"); /* This is supposed to be two numbers, but a single number has been seen in the wild */ - string const er = xml->string_child ("EditRate"); + auto const er = xml->string_child ("EditRate"); vector er_parts; split (er_parts, er, is_any_of (" ")); if (er_parts.size() == 1) { @@ -185,9 +184,8 @@ SMPTESubtitleAsset::parse_xml (shared_ptr xml) /* Now we need to drop down to xmlpp */ vector ps; - xmlpp::Node::NodeList c = xml->node()->get_children (); - for (xmlpp::Node::NodeList::const_iterator i = c.begin(); i != c.end(); ++i) { - xmlpp::Element const * e = dynamic_cast (*i); + for (auto i: xml->node()->get_children()) { + auto const e = dynamic_cast(i); if (e && e->get_name() == "SubtitleList") { parse_subtitles (e, ps, _time_code_rate, Standard::SMPTE); } @@ -206,7 +204,7 @@ SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr /* Load fonts and images */ for ( - ASDCP::TimedText::ResourceList_t::const_iterator i = descriptor.ResourceList.begin(); + auto i = descriptor.ResourceList.begin(); i != descriptor.ResourceList.end(); ++i) { @@ -274,8 +272,8 @@ SMPTESubtitleAsset::set_key (Key key) /* Our data was encrypted; now we can decrypt it */ - shared_ptr reader (new ASDCP::TimedText::MXFReader ()); - Kumu::Result_t r = reader->OpenRead (_file->string().c_str ()); + auto reader = make_shared(); + auto r = reader->OpenRead (_file->string().c_str ()); if (ASDCP_FAILURE (r)) { boost::throw_exception ( ReadError ( @@ -336,8 +334,8 @@ SMPTESubtitleAsset::xml_as_string () const root->add_child("StartTime", "dcst")->add_child_text(_start_time.get().as_string(Standard::SMPTE)); } - BOOST_FOREACH (shared_ptr i, _load_font_nodes) { - xmlpp::Element* load_font = root->add_child("LoadFont", "dcst"); + for (auto i: _load_font_nodes) { + auto load_font = root->add_child("LoadFont", "dcst"); load_font->add_child_text ("urn:uuid:" + i->urn); load_font->set_attribute ("ID", i->id); } @@ -362,7 +360,7 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const /* Font references */ - BOOST_FOREACH (shared_ptr i, _load_font_nodes) { + for (auto i: _load_font_nodes) { auto j = _fonts.begin(); while (j != _fonts.end() && j->load_id != i->id) { ++j; @@ -379,8 +377,8 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const /* Image subtitle references */ - BOOST_FOREACH (shared_ptr i, _subtitles) { - shared_ptr si = dynamic_pointer_cast(i); + for (auto i: _subtitles) { + auto si = dynamic_pointer_cast(i); if (si) { ASDCP::TimedText::TimedTextResourceDescriptor res; unsigned int c; @@ -413,7 +411,7 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const /* Font payload */ - BOOST_FOREACH (shared_ptr i, _load_font_nodes) { + for (auto i: _load_font_nodes) { auto j = _fonts.begin(); while (j != _fonts.end() && j->load_id != i->id) { ++j; @@ -432,8 +430,8 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const /* Image subtitle payload */ - BOOST_FOREACH (shared_ptr i, _subtitles) { - shared_ptr si = dynamic_pointer_cast(i); + for (auto i: _subtitles) { + auto si = dynamic_pointer_cast(i); if (si) { ASDCP::TimedText::FrameBuffer buffer; buffer.SetData (si->png_image().data(), si->png_image().size()); diff --git a/src/sound_asset_writer.cc b/src/sound_asset_writer.cc index 87de1b18..5c5bcdec 100644 --- a/src/sound_asset_writer.cc +++ b/src/sound_asset_writer.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2020 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of libdcp. @@ -40,7 +40,6 @@ #include "crypto_context.h" #include #include -#include #include using std::min; @@ -142,7 +141,7 @@ SoundAssetWriter::start () _state->mxf_writer.OP1aHeader().AddChildObject(soundfield); essence_descriptor->SubDescriptors.push_back(soundfield->InstanceUID); - BOOST_FOREACH (Channel i, _active_channels) { + for (auto i: _active_channels) { ASDCP::MXF::AudioChannelLabelSubDescriptor* channel = new ASDCP::MXF::AudioChannelLabelSubDescriptor(asdcp_smpte_dict); GenRandomValue (channel->MCALinkID); channel->SoundfieldGroupLinkID = soundfield->MCALinkID; diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc index 9d46cb5c..52ef7ac2 100644 --- a/src/subtitle_asset.cc +++ b/src/subtitle_asset.cc @@ -48,7 +48,6 @@ #include #include #include -#include using std::dynamic_pointer_cast; using std::string; @@ -292,7 +291,7 @@ SubtitleAsset::maybe_add_subtitle (string text, vector const & parse } ParseState ps; - BOOST_FOREACH (ParseState const & i, parse_state) { + for (auto const& i: parse_state) { if (i.font_id) { ps.font_id = i.font_id.get(); } @@ -548,12 +547,12 @@ SubtitleAsset::pull_fonts (shared_ptr part) these features go into part's font. */ part->font = part->children.front()->font; - BOOST_FOREACH (shared_ptr i, part->children) { + for (auto i: part->children) { part->font.take_intersection (i->font); } /* Remove common values from part's children's fonts */ - BOOST_FOREACH (shared_ptr i, part->children) { + for (auto i: part->children) { i->font.take_difference (part->font); } } @@ -685,7 +684,7 @@ map SubtitleAsset::font_data () const { map out; - BOOST_FOREACH (Font const & i, _fonts) { + for (auto const& i: _fonts) { out[i.load_id] = i.data; } return out; @@ -696,7 +695,7 @@ map SubtitleAsset::font_filenames () const { map out; - BOOST_FOREACH (Font const& i, _fonts) { + for (auto const& i: _fonts) { if (i.file) { out[i.load_id] = *i.file; } @@ -714,7 +713,7 @@ SubtitleAsset::fix_empty_font_ids () { bool have_empty = false; vector ids; - BOOST_FOREACH (shared_ptr i, load_font_nodes()) { + for (auto i: load_font_nodes()) { if (i->id == "") { have_empty = true; } else { @@ -728,14 +727,14 @@ SubtitleAsset::fix_empty_font_ids () string const empty_id = unique_string (ids, "font"); - BOOST_FOREACH (shared_ptr i, load_font_nodes()) { + for (auto i: load_font_nodes()) { if (i->id == "") { i->id = empty_id; } } - BOOST_FOREACH (shared_ptr i, _subtitles) { - shared_ptr j = dynamic_pointer_cast (i); + for (auto i: _subtitles) { + auto j = dynamic_pointer_cast (i); if (j && j->font() && j->font().get() == "") { j->set_font (empty_id); } diff --git a/src/subtitle_asset_internal.cc b/src/subtitle_asset_internal.cc index 25a41944..d7b16cbd 100644 --- a/src/subtitle_asset_internal.cc +++ b/src/subtitle_asset_internal.cc @@ -141,7 +141,7 @@ order::Part::write_xml (xmlpp::Element* parent, order::Context& context) const parent = as_xml (parent, context); - BOOST_FOREACH (std::shared_ptr i, children) { + for (auto i: children) { i->write_xml (parent, context); } } diff --git a/src/subtitle_asset_internal.h b/src/subtitle_asset_internal.h index 8a9ffe18..0af16238 100644 --- a/src/subtitle_asset_internal.h +++ b/src/subtitle_asset_internal.h @@ -40,7 +40,6 @@ #include "types.h" #include "dcp_time.h" #include -#include struct take_intersection_test; struct take_difference_test; diff --git a/src/types.cc b/src/types.cc index 6058ea10..099512c6 100644 --- a/src/types.cc +++ b/src/types.cc @@ -38,7 +38,6 @@ #include "dcp_assert.h" #include #include -#include #include #include #include @@ -570,7 +569,7 @@ MainSoundConfiguration::MainSoundConfiguration (string s) throw MainSoundConfigurationError (s); } - BOOST_FOREACH (string i, channels) { + for (auto i: channels) { if (i == "-") { _channels.push_back(optional()); } else { diff --git a/src/util.cc b/src/util.cc index f775c507..2aaeddb5 100644 --- a/src/util.cc +++ b/src/util.cc @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include @@ -389,8 +388,8 @@ void dcp::indent (xmlpp::Element* element, int initial) { xmlpp::Node* last = 0; - BOOST_FOREACH (xmlpp::Node * n, element->get_children()) { - xmlpp::Element* e = dynamic_cast(n); + for (auto n: element->get_children()) { + auto e = dynamic_cast(n); if (e) { element->add_child_text_before (e, "\n" + spaces(initial + 2)); indent (e, initial + 2); diff --git a/test/combine_test.cc b/test/combine_test.cc index fc34109b..09a45770 100644 --- a/test/combine_test.cc +++ b/test/combine_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of libdcp. @@ -44,7 +44,6 @@ #include "verify.h" #include "reel_markers_asset.h" #include -#include #include #include #include @@ -74,7 +73,7 @@ static void dump_notes (vector const & notes) { - BOOST_FOREACH (dcp::VerificationNote i, notes) { + for (auto i: notes) { std::cout << dcp::note_to_string(i) << "\n"; } } @@ -100,7 +99,7 @@ template shared_ptr pointer_to_id_in_vector (shared_ptr needle, vector > haystack) { - BOOST_FOREACH (shared_ptr i, haystack) { + for (auto i: haystack) { if (i->id() == needle->id()) { return i; } diff --git a/test/verify_test.cc b/test/verify_test.cc index a9d5c0a7..a6f71b49 100644 --- a/test/verify_test.cc +++ b/test/verify_test.cc @@ -54,7 +54,6 @@ #include "raw_convert.h" #include "stream_operators.h" #include -#include #include #include #include diff --git a/tools/dcpdiff.cc b/tools/dcpdiff.cc index a9d78712..336d09a5 100644 --- a/tools/dcpdiff.cc +++ b/tools/dcpdiff.cc @@ -99,14 +99,14 @@ load_dcp (boost::filesystem::path path, bool ignore_missing_assets, optional notes; dcp->read (¬es); filter_notes (notes, ignore_missing_assets); - BOOST_FOREACH (dcp::VerificationNote i, notes) { + for (auto i: notes) { cerr << dcp::note_to_string(i) << "\n"; } if (key) { auto assets = dcp->assets (); for (auto i: assets) { - shared_ptr mxf = dynamic_pointer_cast(i); + auto mxf = dynamic_pointer_cast(i); if (mxf) { mxf->set_key (Key (key.get ())); } diff --git a/tools/dcpdumpsub.cc b/tools/dcpdumpsub.cc index 5d6668af..8117f0c6 100644 --- a/tools/dcpdumpsub.cc +++ b/tools/dcpdumpsub.cc @@ -115,7 +115,7 @@ main (int argc, char* argv[]) dcp::EncryptedKDM encrypted_kdm (dcp::file_to_string (kdm_file.get ())); dcp::DecryptedKDM decrypted_kdm (encrypted_kdm, dcp::file_to_string (private_key_file.get())); bool done = false; - BOOST_FOREACH (dcp::DecryptedKDMKey const & i, decrypted_kdm.keys()) { + for (auto const& i: decrypted_kdm.keys()) { if (i.id() == *sub.key_id()) { sub.set_key (i.key ()); done = true; diff --git a/tools/dcpinfo.cc b/tools/dcpinfo.cc index 18272dcf..c8519858 100644 --- a/tools/dcpinfo.cc +++ b/tools/dcpinfo.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2020 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of libdcp. @@ -52,7 +52,6 @@ #include "compose.hpp" #include #include -#include #include #include #include @@ -384,7 +383,7 @@ main (int argc, char* argv[]) OUTPUT_DCP_PATH("DCP: %1\n", boost::filesystem::path(argv[optind]).string()); dcp::filter_notes (notes, ignore_missing_assets); - BOOST_FOREACH (dcp::VerificationNote i, notes) { + for (auto i: notes) { cerr << "Error: " << note_to_string(i) << "\n"; } @@ -396,11 +395,11 @@ main (int argc, char* argv[]) dcp::Time total_time; - BOOST_FOREACH (shared_ptr i, cpls) { + for (auto i: cpls) { OUTPUT_CPL_NAME_ID(" CPL: %1 %2\n", i->annotation_text().get_value_or(""), i->id()); int R = 1; - BOOST_FOREACH (shared_ptr j, i->reels()) { + for (auto j: i->reels()) { if (should_output(only, "picture") || should_output(only, "sound") || should_output(only, "subtitle")) { cout << " Reel " << R << "\n"; } diff --git a/tools/dcpkdm.cc b/tools/dcpkdm.cc index 60fcf902..d1421ed1 100644 --- a/tools/dcpkdm.cc +++ b/tools/dcpkdm.cc @@ -112,7 +112,7 @@ try cout << "Signer chain:\n"; dcp::CertificateChain signer = enc_kdm.signer_certificate_chain (); - BOOST_FOREACH (dcp::Certificate const & i, signer.root_to_leaf()) { + for (auto const& i: signer.root_to_leaf()) { cout << "\tCertificate:\n"; cout << "\t\tSubject: " << i.subject() << "\n"; cout << "\t\tSubject common name: " << i.subject_common_name() << "\n"; @@ -129,7 +129,7 @@ try try { dcp::DecryptedKDM dec_kdm (enc_kdm, dcp::file_to_string (private_key_file.get())); cout << "\nKeys:"; - BOOST_FOREACH (dcp::DecryptedKDMKey i, dec_kdm.keys ()) { + for (auto i: dec_kdm.keys()) { cout << "\n"; cout << "\tID: " << i.id() << "\n"; cout << "\tStandard: " << (i.standard() == dcp::Standard::SMPTE ? "SMPTE" : "Interop") << "\n"; diff --git a/tools/dcprecover.cc b/tools/dcprecover.cc index b5790992..f9e08087 100644 --- a/tools/dcprecover.cc +++ b/tools/dcprecover.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of libdcp. @@ -39,7 +39,6 @@ #include #include #include -#include #include using std::cerr; @@ -109,7 +108,7 @@ main (int argc, char* argv[]) cout << "Error:" << e.what() << "\n"; } - BOOST_FOREACH (dcp::VerificationNote i, notes) { + for (auto i: notes) { cout << "Error: " << dcp::note_to_string(i) << "\n"; } diff --git a/tools/dcpverify.cc b/tools/dcpverify.cc index b3ac5f06..2ba4f5c8 100644 --- a/tools/dcpverify.cc +++ b/tools/dcpverify.cc @@ -142,7 +142,7 @@ main (int argc, char* argv[]) dcp::filter_notes (notes, ignore_missing_assets); bool failed = false; - BOOST_FOREACH (dcp::VerificationNote i, notes) { + for (auto i: notes) { if (ignore_bv21_smpte && i.code() == dcp::VerificationNote::Code::INVALID_STANDARD) { continue; }