Assorted c++11 cleanups.
authorCarl Hetherington <cth@carlh.net>
Fri, 22 Jan 2021 00:39:22 +0000 (01:39 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 22 Jan 2021 00:39:22 +0000 (01:39 +0100)
26 files changed:
src/certificate_chain.cc
src/combine.cc
src/decrypted_kdm.cc
src/interop_subtitle_asset.cc
src/language_tag.cc
src/mono_picture_asset.cc
src/mono_picture_asset_writer.h
src/name_format.cc
src/pkl.cc
src/reel.cc
src/reel_markers_asset.cc
src/smpte_subtitle_asset.cc
src/sound_asset_writer.cc
src/subtitle_asset.cc
src/subtitle_asset_internal.cc
src/subtitle_asset_internal.h
src/types.cc
src/util.cc
test/combine_test.cc
test/verify_test.cc
tools/dcpdiff.cc
tools/dcpdumpsub.cc
tools/dcpinfo.cc
tools/dcpkdm.cc
tools/dcprecover.cc
tools/dcpverify.cc

index 2287a805345736b28dfa5489e6cd6bcb0e05891e..9f4c5ea7fa1830b186572c54b70e24bac5b0cfb5 100644 (file)
@@ -54,7 +54,6 @@
 #include <openssl/rsa.h>
 #include <boost/filesystem.hpp>
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 #include <fstream>
 #include <iostream>
 
@@ -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);
        }
 
index cd91d5b19e73916b38a9e588a0b464103dbc98f2..c2cae54758645fcd0349beea201efe05e2bbc2d9 100644 (file)
@@ -42,7 +42,6 @@
 #include "interop_subtitle_asset.h"
 #include "raw_convert.h"
 #include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
 #include <set>
 #include <string>
 #include <vector>
@@ -110,7 +109,7 @@ dcp::combine (
        DCP output_dcp (output);
        optional<dcp::Standard> standard;
 
-       BOOST_FOREACH (path i, inputs) {
+       for (auto i: inputs) {
                DCP dcp (i);
                dcp.read ();
                if (!standard) {
@@ -123,15 +122,15 @@ dcp::combine (
        vector<path> paths;
        vector<shared_ptr<dcp::Asset>> assets;
 
-       BOOST_FOREACH (path i, inputs) {
+       for (auto i: inputs) {
                DCP dcp (i);
                dcp.read ();
 
-               BOOST_FOREACH (shared_ptr<dcp::CPL> j, dcp.cpls()) {
+               for (auto j: dcp.cpls()) {
                        output_dcp.add (j);
                }
 
-               BOOST_FOREACH (shared_ptr<dcp::Asset> j, dcp.assets(true)) {
+               for (auto j: dcp.assets(true)) {
                        if (dynamic_pointer_cast<dcp::CPL>(j)) {
                                continue;
                        }
index 10da80e634bfeb0feed56a3c153f93608baa6beb..0a3eeabd41e6fc388b78f52ccbbdf7e8ae5087ca 100644 (file)
@@ -47,7 +47,6 @@
 #include <openssl/rsa.h>
 #include <openssl/pem.h>
 #include <openssl/err.h>
-#include <boost/foreach.hpp>
 
 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<pair<string, string>> key_ids;
        vector<string> 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 ()));
index f93e7cf42ec6252961aca47e31974f66c8567c15..9c977b4472a822f39995c5438c18870708b4e044 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -42,7 +42,6 @@
 #include "compose.hpp"
 #include "subtitle_image.h"
 #include <libxml++/libxml++.h>
-#include <boost/foreach.hpp>
 #include <boost/weak_ptr.hpp>
 #include <cmath>
 #include <cstdio>
@@ -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<Subtitle> i, _subtitles) {
-               shared_ptr<SubtitleImage> si = dynamic_pointer_cast<SubtitleImage>(i);
+       for (auto i: _subtitles) {
+               auto si = dynamic_pointer_cast<SubtitleImage>(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<dcp::Subtitle> i, _subtitles) {
-               shared_ptr<dcp::SubtitleImage> im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
+       for (auto i: _subtitles) {
+               auto im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
                if (im) {
                        im->write_png_file(p.parent_path() / String::compose("%1.png", im->id()));
                }
        }
 
        /* Fonts */
-       BOOST_FOREACH (shared_ptr<InteropLoadFontNode> 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<shared_ptr<Asset>> assets)
 {
-       BOOST_FOREACH (shared_ptr<Asset> i, assets) {
-               shared_ptr<FontAsset> font = dynamic_pointer_cast<FontAsset> (i);
+       for (auto i: assets) {
+               auto font = dynamic_pointer_cast<FontAsset> (i);
                if (!font) {
                        continue;
                }
 
-               BOOST_FOREACH (shared_ptr<InteropLoadFontNode> 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<shared_ptr<Asset>> assets)
 void
 InteropSubtitleAsset::add_font_assets (vector<shared_ptr<Asset>>& assets)
 {
-       BOOST_FOREACH (Font const & i, _fonts) {
+       for (auto const& i: _fonts) {
                DCP_ASSERT (i.file);
-               assets.push_back (shared_ptr<FontAsset> (new FontAsset (i.uuid, i.file.get ())));
+               assets.push_back (make_shared<FontAsset>(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<dcp::Subtitle> i, _subtitles) {
-               shared_ptr<dcp::SubtitleImage> im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
+       for (auto i: _subtitles) {
+               auto im = dynamic_pointer_cast<dcp::SubtitleImage> (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> pkl, boost::filesystem::path r
 {
        Asset::add_to_pkl (pkl, root);
 
-       BOOST_FOREACH (shared_ptr<dcp::Subtitle> i, _subtitles) {
-               shared_ptr<dcp::SubtitleImage> im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
+       for (auto i: _subtitles) {
+               auto im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
                if (im) {
-                       ArrayData png_image = im->png_image ();
+                       auto png_image = im->png_image ();
                        pkl->add_asset (im->id(), optional<string>(), make_digest(png_image), png_image.size(), "image/png");
                }
        }
@@ -283,13 +283,13 @@ InteropSubtitleAsset::add_to_pkl (shared_ptr<PKL> 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<InteropLoadFontNode> i, _load_font_nodes) {
+       for (auto i: _load_font_nodes) {
                if (i->id == load_id) {
                        i->uri = file.filename().string();
                }
index 148e054be35c20af6028b5bddf3271b71e94cb26..07e95564c315d28d3705ca7ccd56dbbc6acd2a81 100644 (file)
@@ -37,7 +37,6 @@
 #include "exceptions.h"
 #include "language_tag.h"
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 #include <string>
 
 
@@ -62,7 +61,7 @@ static
 optional<LanguageTag::SubtagData>
 find_in_list (vector<LanguageTag::SubtagData> 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<SubtagData> variant = get_subtag_data (SubtagType::VARIANT, i.subtag());
                DCP_ASSERT (variant);
                d += variant->description + " dialect of ";
        }
 
-       optional<SubtagData> 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<SubtagData> 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<pair<LanguageTag::SubtagType, LanguageTag::SubtagData> >
 LanguageTag::subtags () const
 {
-       vector<pair<SubtagType, SubtagData> > s;
+       vector<pair<SubtagType, SubtagData>> 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())));
        }
 
index 4524c85da5eadafa2b57af0ea0da1da337d4821f..89661061c482f544c3ebfb09237361bae7ce2b3b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     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<pair<NoteType, string> >& notes, NoteType t, string s
 bool
 MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler note) const
 {
-       if (!dynamic_pointer_cast<const MonoPictureAsset> (other)) {
+       if (!dynamic_pointer_cast<const MonoPictureAsset>(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<const Asset> other, EqualityOptions opt, No
                return false;
        }
 
-       shared_ptr<const MonoPictureAsset> other_picture = dynamic_pointer_cast<const MonoPictureAsset> (other);
+       auto other_picture = dynamic_pointer_cast<const MonoPictureAsset> (other);
        DCP_ASSERT (other_picture);
 
        bool result = true;
 
-       shared_ptr<MonoPictureAssetReader> reader = start_read ();
-       shared_ptr<MonoPictureAssetReader> 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<const Asset> other, EqualityOptions opt, No
 
                if (result || opt.keep_going) {
 
-                       shared_ptr<const MonoPictureFrame> frame_A = reader->get_frame (i);
-                       shared_ptr<const MonoPictureFrame> frame_B = other_reader->get_frame (i);
+                       auto frame_A = reader->get_frame (i);
+                       auto frame_B = other_reader->get_frame (i);
 
                        list<pair<NoteType, string> > notes;
 
@@ -159,8 +160,8 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, No
 #endif
                        {
                                note (NoteType::PROGRESS, String::compose("Compared video frame %1 of %2", i, _intrinsic_duration));
-                               for (list<pair<NoteType, string> >::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<const Asset> other, EqualityOptions opt, No
 shared_ptr<PictureAssetWriter>
 MonoPictureAsset::start_write (boost::filesystem::path file, bool overwrite)
 {
-       /* XXX: can't we use shared_ptr here? */
-       return shared_ptr<MonoPictureAssetWriter> (new MonoPictureAssetWriter (this, file, overwrite));
+       return make_shared<MonoPictureAssetWriter>(this, file, overwrite);
 }
 
 shared_ptr<MonoPictureAssetReader>
 MonoPictureAsset::start_read () const
 {
-       return shared_ptr<MonoPictureAssetReader> (new MonoPictureAssetReader (this, key(), standard()));
+       return make_shared<MonoPictureAssetReader>(this, key(), standard());
 }
 
 string
index 2dce922ef460b40b0e603564c5e1ade98a4973e0..a5799d2737ce6319bd55429d37d6fbf69ed4a9f8 100644 (file)
@@ -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<ASDCPState> _state;
 };
index 76cca3fd3d45e2edbba4fc8d74df256d9f8e15b5..11b68e19e97d4af358e4866d83dab6387ee4fccb 100644 (file)
@@ -33,7 +33,6 @@
 
 #include "name_format.h"
 #include <boost/optional.hpp>
-#include <boost/foreach.hpp>
 
 using std::string;
 using std::map;
index b439e8bd99f9da7d5044ae9e6c055c69fa701400..0f62b4a2b678355f44e5a5ce59de96378cdcbe67 100644 (file)
@@ -37,7 +37,6 @@
 #include "raw_convert.h"
 #include "dcp_assert.h"
 #include <libxml++/libxml++.h>
-#include <boost/foreach.hpp>
 #include <iostream>
 
 using std::string;
index efb161bb0f8c445ef5c6ccfa483f781da018c9bb..25019d359a511d5f249ea81d362806871a54e77f 100644 (file)
@@ -50,7 +50,6 @@
 #include "reel_atmos_asset.h"
 #include "reel_closed_caption_asset.h"
 #include <libxml++/nodes/element.h>
-#include <boost/foreach.hpp>
 #include <stdint.h>
 
 /* Centos 6 does not have this */
index ba0021cfc156fb7c13fef27befc3973f74744493..1f9282fa72a8796c27047cb2a1d720458bf9abe4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2019-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -35,7 +35,6 @@
 #include "raw_convert.h"
 #include "dcp_assert.h"
 #include <libxml++/libxml++.h>
-#include <boost/foreach.hpp>
 
 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<int64_t>("Offset"), edit_rate().as_float(), edit_rate().numerator));
        }
 }
index 49ccc5a9984c9fe4e992c19a5de4882647c34348..2c53cbb3b0f86042ae83e128aa644762bc72d4f6 100644 (file)
@@ -49,7 +49,6 @@
 #include <asdcp/KM_util.h>
 #include <asdcp/KM_log.h>
 #include <libxml++/libxml++.h>
-#include <boost/foreach.hpp>
 #include <boost/algorithm/string.hpp>
 
 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<Subtitle> i, _subtitles) {
-                       shared_ptr<SubtitleImage> im = dynamic_pointer_cast<SubtitleImage>(i);
+               for (auto i: _subtitles) {
+                       auto im = dynamic_pointer_cast<SubtitleImage>(i);
                        if (im && im->png_image().size() == 0) {
                                /* Even more dubious; allow <id>.png or urn:uuid:<id>.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<Subtitle> i, _subtitles) {
-               shared_ptr<SubtitleImage> im = dynamic_pointer_cast<SubtitleImage>(i);
+       for (auto i: _subtitles) {
+               auto im = dynamic_pointer_cast<SubtitleImage>(i);
                if (im && im->png_image().size() == 0) {
                        throw MissingSubtitleImageError (im->id());
                }
@@ -166,7 +165,7 @@ SMPTESubtitleAsset::parse_xml (shared_ptr<cxml::Document> 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<string> er_parts;
        split (er_parts, er, is_any_of (" "));
        if (er_parts.size() == 1) {
@@ -185,9 +184,8 @@ SMPTESubtitleAsset::parse_xml (shared_ptr<cxml::Document> xml)
        /* Now we need to drop down to xmlpp */
 
        vector<ParseState> 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<xmlpp::Element const *> (*i);
+       for (auto i: xml->node()->get_children()) {
+               auto const e = dynamic_cast<xmlpp::Element const *>(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<ASDCP::TimedText::MXFReader>
        /* 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<ASDCP::TimedText::MXFReader> reader (new ASDCP::TimedText::MXFReader ());
-       Kumu::Result_t r = reader->OpenRead (_file->string().c_str ());
+       auto reader = make_shared<ASDCP::TimedText::MXFReader>();
+       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<SMPTELoadFontNode> 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<dcp::SMPTELoadFontNode> 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<Subtitle> i, _subtitles) {
-               shared_ptr<SubtitleImage> si = dynamic_pointer_cast<SubtitleImage>(i);
+       for (auto i: _subtitles) {
+               auto si = dynamic_pointer_cast<SubtitleImage>(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<dcp::SMPTELoadFontNode> 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<Subtitle> i, _subtitles) {
-               shared_ptr<SubtitleImage> si = dynamic_pointer_cast<SubtitleImage>(i);
+       for (auto i: _subtitles) {
+               auto si = dynamic_pointer_cast<SubtitleImage>(i);
                if (si) {
                        ASDCP::TimedText::FrameBuffer buffer;
                        buffer.SetData (si->png_image().data(), si->png_image().size());
index 87de1b182aae4a3194ec844fecbc246380de3e78..5c5bcdec71165e6e6a472596f15e4f5b288918be 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -40,7 +40,6 @@
 #include "crypto_context.h"
 #include <asdcp/AS_DCP.h>
 #include <asdcp/Metadata.h>
-#include <boost/foreach.hpp>
 #include <iostream>
 
 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;
index 9d46cb5ce3fddc3355d8571b2bd71a4e2b211bb9..52ef7ac2fdd844cbc2fe81946a7d2c1c350c4f27 100644 (file)
@@ -48,7 +48,6 @@
 #include <boost/algorithm/string.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/shared_array.hpp>
-#include <boost/foreach.hpp>
 
 using std::dynamic_pointer_cast;
 using std::string;
@@ -292,7 +291,7 @@ SubtitleAsset::maybe_add_subtitle (string text, vector<ParseState> 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<order::Part> part)
                   these features go into part's font.
                */
                part->font = part->children.front()->font;
-               BOOST_FOREACH (shared_ptr<order::Part> 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<order::Part> i, part->children) {
+               for (auto i: part->children) {
                        i->font.take_difference (part->font);
                }
        }
@@ -685,7 +684,7 @@ map<string, ArrayData>
 SubtitleAsset::font_data () const
 {
        map<string, ArrayData> 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<string, boost::filesystem::path>
 SubtitleAsset::font_filenames () const
 {
        map<string, boost::filesystem::path> 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<string> ids;
-       BOOST_FOREACH (shared_ptr<LoadFontNode> 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<LoadFontNode> i, load_font_nodes()) {
+       for (auto i: load_font_nodes()) {
                if (i->id == "") {
                        i->id = empty_id;
                }
        }
 
-       BOOST_FOREACH (shared_ptr<Subtitle> i, _subtitles) {
-               shared_ptr<SubtitleString> j = dynamic_pointer_cast<SubtitleString> (i);
+       for (auto i: _subtitles) {
+               auto j = dynamic_pointer_cast<SubtitleString> (i);
                if (j && j->font() && j->font().get() == "") {
                        j->set_font (empty_id);
                }
index 25a419440ce15ea39e4e37fbcb2365702043f9a4..d7b16cbdb74ba534b7df507e41f04ef0041bf74b 100644 (file)
@@ -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<order::Part> i, children) {
+       for (auto i: children) {
                i->write_xml (parent, context);
        }
 }
index 8a9ffe18980679a5d80a48e153e3f8181a8226bc..0af1623887fecdab84c40eddc21dedb9a38cf684 100644 (file)
@@ -40,7 +40,6 @@
 #include "types.h"
 #include "dcp_time.h"
 #include <libxml++/libxml++.h>
-#include <boost/foreach.hpp>
 
 struct take_intersection_test;
 struct take_difference_test;
index 6058ea10ae616760d911b7a4d01bc5afc03317ce..099512c62e3635261a0cb5663bc5c46c04a7fc1b 100644 (file)
@@ -38,7 +38,6 @@
 #include "dcp_assert.h"
 #include <libxml++/libxml++.h>
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 #include <string>
 #include <vector>
 #include <cmath>
@@ -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<Channel>());
                } else {
index f775c5074d317907c96c6c41c21da7ed634f9592..2aaeddb57e5501ee9c01769c302a08b96ddf7da3 100644 (file)
@@ -56,7 +56,6 @@
 #include <openssl/sha.h>
 #include <boost/filesystem.hpp>
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 #include <stdexcept>
 #include <iostream>
 #include <iomanip>
@@ -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<xmlpp::Element*>(n);
+       for (auto n: element->get_children()) {
+               auto e = dynamic_cast<xmlpp::Element*>(n);
                if (e) {
                        element->add_child_text_before (e, "\n" + spaces(initial + 2));
                        indent (e, initial + 2);
index fc34109ba2f2284fa7b01c283152b40436cceba3..09a4577021ea314f09dbf909960b762e040688ea 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -44,7 +44,6 @@
 #include "verify.h"
 #include "reel_markers_asset.h"
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 #include <boost/optional.hpp>
 #include <boost/test/unit_test.hpp>
 #include <iostream>
@@ -74,7 +73,7 @@ static
 void
 dump_notes (vector<dcp::VerificationNote> 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 <class T>
 shared_ptr<T>
 pointer_to_id_in_vector (shared_ptr<T> needle, vector<shared_ptr<T> > haystack)
 {
-       BOOST_FOREACH (shared_ptr<T> i, haystack) {
+       for (auto i: haystack) {
                if (i->id() == needle->id()) {
                        return i;
                }
index a9d5c0a72711e4e443e4658aab8af488e1aa4ff3..a6f71b49714834e70ab29b7324c4b62efd5c7404 100644 (file)
@@ -54,7 +54,6 @@
 #include "raw_convert.h"
 #include "stream_operators.h"
 #include <boost/test/unit_test.hpp>
-#include <boost/foreach.hpp>
 #include <boost/algorithm/string.hpp>
 #include <cstdio>
 #include <iostream>
index a9d7871269bb2463a693f6919f70775798cae641..336d09a5828fe718ef8492465898154c9c2cb5a1 100644 (file)
@@ -99,14 +99,14 @@ load_dcp (boost::filesystem::path path, bool ignore_missing_assets, optional<str
                vector<dcp::VerificationNote> notes;
                dcp->read (&notes);
                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> mxf = dynamic_pointer_cast<MXF>(i);
+                               auto mxf = dynamic_pointer_cast<MXF>(i);
                                if (mxf) {
                                        mxf->set_key (Key (key.get ()));
                                }
index 5d6668af70a3c958f4a6d05a8627d6cec54f2c5f..8117f0c66931fd12a61d37f2bc93698d8ad49651 100644 (file)
@@ -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;
index 18272dcfdcedc55df575de85eb2f12e6c45d2c98..c85198587947ce876f73bbace97ccafae09a7af4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -52,7 +52,6 @@
 #include "compose.hpp"
 #include <getopt.h>
 #include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
 #include <boost/algorithm/string.hpp>
 #include <iostream>
 #include <cstdlib>
@@ -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<CPL> 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<Reel> 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";
                        }
index 60fcf902a13e0833b029be9d55eac75475b724f4..d1421ed165b74a94ca56e9890b8914222d1ab073 100644 (file)
@@ -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";
index b5790992817549647091eed3bc6c862550ca1423..f9e08087ad6873844d4d3c1fd307ab0c9d4d7d6e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -39,7 +39,6 @@
 #include <getopt.h>
 #include <libxml++/libxml++.h>
 #include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
 #include <iostream>
 
 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";
        }
 
index b3ac5f067f0c96808d166635cdceab0af679410e..2ba4f5c885fd9ece3840c9972440bbc29d8e6dbc 100644 (file)
@@ -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;
                }