Replace std::list with std::vector in the API.
authorCarl Hetherington <cth@carlh.net>
Sun, 10 Jan 2021 23:16:40 +0000 (00:16 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 17 Jan 2021 19:13:23 +0000 (20:13 +0100)
49 files changed:
examples/read_dcp.cc
src/certificate_chain.cc
src/certificate_chain.h
src/combine.cc
src/cpl.cc
src/cpl.h
src/dcp.cc
src/dcp.h
src/decrypted_kdm.cc
src/decrypted_kdm.h
src/encrypted_kdm.cc
src/encrypted_kdm.h
src/interop_subtitle_asset.cc
src/interop_subtitle_asset.h
src/pkl.h
src/reel.cc
src/reel.h
src/ref.cc
src/ref.h
src/smpte_subtitle_asset.cc
src/smpte_subtitle_asset.h
src/subtitle_asset.cc
src/subtitle_asset.h
src/subtitle_asset_internal.h
src/util.cc
src/util.h
src/verify.cc
src/verify.h
src/xml.h
test/combine_test.cc
test/cpl_metadata_test.cc
test/cpl_ratings_test.cc
test/mca_test.cc
test/read_dcp_test.cc
test/read_interop_subtitle_test.cc
test/read_smpte_subtitle_test.cc
test/rewrite_subs.cc
test/round_trip_test.cc
test/test.cc
test/test.h
test/util_test.cc
test/verify_test.cc
test/write_subtitle_test.cc
tools/common.cc
tools/common.h
tools/dcpdiff.cc
tools/dcpinfo.cc
tools/dcprecover.cc
tools/dcpverify.cc

index 6a36d00951e29d33ea3b4aa392583bdef03a3092..9c6c307af19570dc1aa74134bf1f6d0cfb6f8be7 100644 (file)
@@ -58,21 +58,21 @@ main ()
        }
 
        std::cout << "DCP has " << dcp.cpls().size() << " CPLs.\n";
-       std::list<std::shared_ptr<dcp::Asset> > assets = dcp.assets ();
+       auto assets = dcp.assets ();
        std::cout << "DCP has " << assets.size() << " assets.\n";
-       for (std::list<std::shared_ptr<dcp::Asset> >::const_iterator i = assets.begin(); i != assets.end(); ++i) {
-               if (std::dynamic_pointer_cast<dcp::MonoPictureAsset> (*i)) {
+       for (auto i: assets) {
+               if (std::dynamic_pointer_cast<dcp::MonoPictureAsset>(i)) {
                        std::cout << "2D picture\n";
-               } else if (std::dynamic_pointer_cast<dcp::StereoPictureAsset> (*i)) {
+               } else if (std::dynamic_pointer_cast<dcp::StereoPictureAsset>(i)) {
                        std::cout << "3D picture\n";
-               } else if (std::dynamic_pointer_cast<dcp::SoundAsset> (*i)) {
+               } else if (std::dynamic_pointer_cast<dcp::SoundAsset>(i)) {
                        std::cout << "Sound\n";
-               } else if (std::dynamic_pointer_cast<dcp::SubtitleAsset> (*i)) {
+               } else if (std::dynamic_pointer_cast<dcp::SubtitleAsset>(i)) {
                        std::cout << "Subtitle\n";
-               } else if (std::dynamic_pointer_cast<dcp::CPL> (*i)) {
+               } else if (std::dynamic_pointer_cast<dcp::CPL>(i)) {
                        std::cout << "CPL\n";
                }
-               std::cout << "\t" << (*i)->file()->leaf().string() << "\n";
+               std::cout << "\t" << i->file()->leaf().string() << "\n";
        }
 
        /* Take the first CPL */
index 2fb0f651bb07ad8aa626ebffb11c66c30a7da8e4..a4da0931bd8bacb9a129f3a8790bb3b25ede5d60 100644 (file)
@@ -362,7 +362,7 @@ CertificateChain::List
 CertificateChain::leaf_to_root () const
 {
        List l = root_to_leaf ();
-       l.reverse ();
+       std::reverse (l.begin(), l.end());
        return l;
 }
 
@@ -387,7 +387,10 @@ CertificateChain::add (Certificate c)
 void
 CertificateChain::remove (Certificate c)
 {
-       _certificates.remove (c);
+       auto i = std::find(_certificates.begin(), _certificates.end(), c);
+       if (i != _certificates.end()) {
+               _certificates.erase (i);
+       }
 }
 
 /** Remove the i'th certificate in the list, as listed
@@ -557,7 +560,7 @@ CertificateChain::List
 CertificateChain::root_to_leaf () const
 {
        List rtl = _certificates;
-       rtl.sort ();
+       std::sort (rtl.begin(), rtl.end());
        do {
                if (chain_valid (rtl)) {
                        return rtl;
index 63ef89015eee80e7cc6dd8822759d82865fc6e66..c74bc6e24b45967b9c0458c8ba5f8e72cfc9366c 100644 (file)
@@ -92,7 +92,7 @@ public:
        Certificate root () const;
        Certificate leaf () const;
 
-       typedef std::list<Certificate> List;
+       typedef std::vector<Certificate> List;
 
        List leaf_to_root () const;
        List root_to_leaf () const;
index 5c9a10877500788e5371a39cfb4f175ed8eba448..cd91d5b19e73916b38a9e588a0b464103dbc98f2 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.
 
@@ -48,7 +48,6 @@
 #include <vector>
 
 
-using std::list;
 using std::map;
 using std::set;
 using std::string;
@@ -121,8 +120,8 @@ dcp::combine (
                }
        }
 
-       list<path> paths;
-       list<shared_ptr<dcp::Asset> > assets;
+       vector<path> paths;
+       vector<shared_ptr<dcp::Asset>> assets;
 
        BOOST_FOREACH (path i, inputs) {
                DCP dcp (i);
index 22abfb69b824348ccaf463861b9b7431771cdcfc..04bc9f5c11c235256bb267e85338e7367036282d 100644 (file)
@@ -487,10 +487,10 @@ CPL::maybe_write_composition_metadata_asset (xmlpp::Element* node) const
 }
 
 
-list<shared_ptr<ReelMXF>>
+vector<shared_ptr<ReelMXF>>
 CPL::reel_mxfs ()
 {
-       list<shared_ptr<ReelMXF>> c;
+       vector<shared_ptr<ReelMXF>> c;
 
        for (auto i: _reels) {
                if (i->main_picture ()) {
@@ -513,10 +513,10 @@ CPL::reel_mxfs ()
        return c;
 }
 
-list<shared_ptr<const ReelMXF>>
+vector<shared_ptr<const ReelMXF>>
 CPL::reel_mxfs () const
 {
-       list<shared_ptr<const ReelMXF>> c;
+       vector<shared_ptr<const ReelMXF>> c;
 
        for (auto i: _reels) {
                if (i->main_picture ()) {
@@ -603,7 +603,7 @@ CPL::add (DecryptedKDM const & kdm)
 }
 
 void
-CPL::resolve_refs (list<shared_ptr<Asset>> assets)
+CPL::resolve_refs (vector<shared_ptr<Asset>> assets)
 {
        for (auto i: _reels) {
                i->resolve_refs (assets);
index 6805cc8949ba3479feede6232d7873b75e03619e..c2a8b07d6c8406d77ec0507e76517ba1d01abf3d 100644 (file)
--- a/src/cpl.h
+++ b/src/cpl.h
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014-2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -50,7 +50,6 @@
 #include <boost/function.hpp>
 #include <boost/optional.hpp>
 #include <memory>
-#include <list>
 #include <vector>
 
 
@@ -86,13 +85,13 @@ public:
        void add (DecryptedKDM const &);
 
        /** @return the reels in this CPL */
-       std::list<std::shared_ptr<Reel> > reels () const {
+       std::vector<std::shared_ptr<Reel>> reels () const {
                return _reels;
        }
 
        /** @return the ReelMXFs in this CPL in all reels */
-       std::list<std::shared_ptr<const ReelMXF> > reel_mxfs () const;
-       std::list<std::shared_ptr<ReelMXF> > reel_mxfs ();
+       std::vector<std::shared_ptr<const ReelMXF>> reel_mxfs () const;
+       std::vector<std::shared_ptr<ReelMXF>> reel_mxfs ();
 
        bool encrypted () const;
 
@@ -102,7 +101,7 @@ public:
                std::shared_ptr<const CertificateChain>
                ) const;
 
-       void resolve_refs (std::list<std::shared_ptr<Asset> >);
+       void resolve_refs (std::vector<std::shared_ptr<Asset>>);
 
        int64_t duration () const;
 
@@ -316,7 +315,7 @@ private:
        /* See note for _release_territory above */
        std::vector<std::string> _additional_subtitle_languages;
 
-       std::list<std::shared_ptr<Reel> > _reels;
+       std::vector<std::shared_ptr<Reel>> _reels;
 
        /** Standard of CPL that was read in */
        boost::optional<Standard> _standard;
index 17d5c88d0c6c07832a6f5bbb88dd9dfe21b1d7ec..ca7313a535cee7784d923a39b5d4099010de9daf 100644 (file)
@@ -105,10 +105,10 @@ DCP::DCP (boost::filesystem::path directory)
  *
  *  Errors that are not fatal will be added to notes, if it's non-0.  For example,
  *  if the DCP contains a mixture of Interop and SMPTE elements this will result
- *  in a note being added to the list.
+ *  in a note being added to the vector.
  */
 void
-DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf_type)
+DCP::read (vector<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf_type)
 {
        /* Read the ASSETMAP and PKL */
 
@@ -133,7 +133,7 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf
 
        auto asset_nodes = asset_map.node_child("AssetList")->node_children ("Asset");
        map<string, boost::filesystem::path> paths;
-       list<boost::filesystem::path> pkl_paths;
+       vector<boost::filesystem::path> pkl_paths;
        for (auto i: asset_nodes) {
                if (i->node_child("ChunkList")->node_children("Chunk").size() != 1) {
                        boost::throw_exception (XMLError ("unsupported asset chunk count"));
@@ -181,7 +181,7 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf
        /* Make a list of non-CPL/PKL assets so that we can resolve the references
           from the CPLs.
        */
-       list<shared_ptr<Asset>> other_assets;
+       vector<shared_ptr<Asset>> other_assets;
 
        for (auto i: paths) {
                auto path = _directory / i.second;
@@ -276,7 +276,7 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf
 }
 
 void
-DCP::resolve_refs (list<shared_ptr<Asset>> assets)
+DCP::resolve_refs (vector<shared_ptr<Asset>> assets)
 {
        for (auto i: cpls()) {
                i->resolve_refs (assets);
@@ -498,7 +498,7 @@ DCP::write_xml (
        write_assetmap (standard, pkl->id(), pkl_path, issuer, creator, issue_date, annotation_text);
 }
 
-list<shared_ptr<CPL>>
+vector<shared_ptr<CPL>>
 DCP::cpls () const
 {
        return _cpls;
@@ -508,10 +508,10 @@ DCP::cpls () const
  *  an exception is thrown if they are found.
  *  @return All assets (including CPLs).
  */
-list<shared_ptr<Asset>>
+vector<shared_ptr<Asset>>
 DCP::assets (bool ignore_unresolved) const
 {
-       list<shared_ptr<Asset>> assets;
+       vector<shared_ptr<Asset>> assets;
        for (auto i: cpls()) {
                assets.push_back (i);
                for (auto j: i->reel_mxfs()) {
index 3eab743ec8453560dd3e825ee786640a6932e9d0..73f154c707a78c1f60da06a7255c9d0b7dffa926 100644 (file)
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -91,7 +91,7 @@ public:
         *  as stereoscopic if the monoscopic load fails; fixes problems some 3D DCPs that (I think)
         *  have an incorrect descriptor in their MXF.
         */
-       void read (std::list<VerificationNote>* notes = 0, bool ignore_incorrect_picture_mxf_type = false);
+       void read (std::vector<VerificationNote>* notes = 0, bool ignore_incorrect_picture_mxf_type = false);
 
        /** Compare this DCP with another, according to various options.
         *  @param other DCP to compare this one to.
@@ -103,8 +103,8 @@ public:
 
        void add (std::shared_ptr<CPL> cpl);
 
-       std::list<std::shared_ptr<CPL> > cpls () const;
-       std::list<std::shared_ptr<Asset> > assets (bool ignore_unresolved = false) const;
+       std::vector<std::shared_ptr<CPL>> cpls () const;
+       std::vector<std::shared_ptr<Asset>> assets (bool ignore_unresolved = false) const;
 
        bool encrypted () const;
 
@@ -120,7 +120,7 @@ public:
                NameFormat name_format = NameFormat("%t")
        );
 
-       void resolve_refs (std::list<std::shared_ptr<Asset> > assets);
+       void resolve_refs (std::vector<std::shared_ptr<Asset>> assets);
 
        /** @return Standard of a DCP that was read in */
        boost::optional<Standard> standard () const {
@@ -132,9 +132,9 @@ public:
        }
 
        /** @return PKLs if this DCP was read from an existing one, or if write_xml() has been called on it.
-        *  If neither is true, this method returns an empty list.
+        *  If neither is true, this method returns an empty vector.
         */
-       std::list<std::shared_ptr<PKL> > pkls () const {
+       std::vector<std::shared_ptr<PKL>> pkls () const {
                return _pkls;
        }
 
@@ -160,9 +160,9 @@ private:
        /** The directory that we are writing to */
        boost::filesystem::path _directory;
        /** The CPLs that make up this DCP */
-       std::list<std::shared_ptr<CPL> > _cpls;
+       std::vector<std::shared_ptr<CPL>> _cpls;
        /** The PKLs that make up this DCP */
-       std::list<std::shared_ptr<PKL> > _pkls;
+       std::vector<std::shared_ptr<PKL>> _pkls;
        /** File that the ASSETMAP was read from or last written to */
        mutable boost::optional<boost::filesystem::path> _asset_map;
 
index 043eac4715186845316f69a59e98996f9b1ddf71..dd6def32d5d8d50152bcbc27dd8257fe930a6157 100644 (file)
@@ -320,8 +320,8 @@ DecryptedKDM::encrypt (
                }
        }
 
-       list<pair<string, string> > key_ids;
-       list<string> keys;
+       vector<pair<string, string>> key_ids;
+       vector<string> keys;
        BOOST_FOREACH (DecryptedKDMKey const & i, _keys) {
                /* We're making SMPTE keys so we must have a type for each one */
                DCP_ASSERT (i.type());
index a67fdbfe2981951466183b500b397d9567621baf..867e97ff442e8b500d826baa146284b54835c5b0 100644 (file)
@@ -142,7 +142,7 @@ public:
        void add_key (DecryptedKDMKey key);
 
        /** @return This KDM's (decrypted) keys, which could be used to decrypt assets. */
-       std::list<DecryptedKDMKey> keys () const {
+       std::vector<DecryptedKDMKey> keys () const {
                return _keys;
        }
 
@@ -170,7 +170,7 @@ private:
        boost::optional<std::string> _annotation_text;
        std::string _content_title_text;
        std::string _issue_date;
-       std::list<DecryptedKDMKey> _keys;
+       std::vector<DecryptedKDMKey> _keys;
 };
 
 }
index 77345a5d9fb3a8f60b96e4943bfcda3a4d1ca1f4..a124fdf65bf92619216b5ccdb1bcddd9cddf0ab0 100644 (file)
@@ -198,7 +198,7 @@ public:
 
        SignedInfo signed_info;
        string signature_value;
-       list<X509Data> x509_data;
+       vector<X509Data> x509_data;
 };
 
 class AuthenticatedPrivate
@@ -232,7 +232,7 @@ public:
                }
        }
 
-       list<string> encrypted_key;
+       vector<string> encrypted_key;
 };
 
 class TypedKeyId
@@ -288,7 +288,7 @@ public:
                }
        }
 
-       list<TypedKeyId> typed_key_id;
+       vector<TypedKeyId> typed_key_id;
 };
 
 class AuthorizedDeviceInfo
@@ -320,7 +320,7 @@ public:
        /** DeviceListIdentifier without the urn:uuid: prefix */
        string device_list_identifier;
        boost::optional<string> device_list_description;
-       std::list<string> certificate_thumbprints;
+       std::vector<string> certificate_thumbprints;
 };
 
 class X509IssuerSerial
@@ -586,8 +586,8 @@ EncryptedKDM::EncryptedKDM (
        Formulation formulation,
        bool disable_forensic_marking_picture,
        optional<int> disable_forensic_marking_audio,
-       list<pair<string, string> > key_ids,
-       list<string> keys
+       vector<pair<string, string>> key_ids,
+       vector<string> keys
        )
        : _data (new data::EncryptedKDMData)
 {
@@ -719,7 +719,7 @@ EncryptedKDM::as_xml () const
        return _data->as_xml()->write_to_string ("UTF-8");
 }
 
-list<string>
+vector<string>
 EncryptedKDM::keys () const
 {
        return _data->authenticated_private.encrypted_key;
index 175b578f2a73e4f37e31632e0663e74fefca4fc7..342bedca4e6b4b2565ba5cd6c0cff796c2977e36 100644 (file)
@@ -84,7 +84,7 @@ public:
         *  Note that the returned `keys' contain more than just the asset decryption
         *  keys (also key id, CPL id etc.)
         */
-       std::list<std::string> keys () const;
+       std::vector<std::string> keys () const;
 
        std::string id () const;
        boost::optional<std::string> annotation_text () const;
@@ -113,8 +113,8 @@ private:
                Formulation formulation,
                bool disable_forensic_marking_picture,
                boost::optional<int> disable_forensic_marking_audio,
-               std::list<std::pair<std::string, std::string> > key_ids,
-               std::list<std::string> keys
+               std::vector<std::pair<std::string, std::string>> key_ids,
+               std::vector<std::string> keys
                );
 
        data::EncryptedKDMData* _data;
index ac3dcc98e943e7aa077e99b0c7a6963117be9ebd..edc51404bbdccd581355e043e9d1be10cc6a36e8 100644 (file)
@@ -53,9 +53,10 @@ using std::cout;
 using std::cerr;
 using std::map;
 using std::shared_ptr;
+using std::dynamic_pointer_cast;
+using std::vector;
 using boost::shared_array;
 using boost::optional;
-using std::dynamic_pointer_cast;
 using namespace dcp;
 
 InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file)
@@ -73,7 +74,7 @@ InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file)
 
        /* Now we need to drop down to xmlpp */
 
-       list<ParseState> ps;
+       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);
@@ -107,10 +108,10 @@ InteropSubtitleAsset::xml_as_string () const
        root->add_child("ReelNumber")->add_child_text (raw_convert<string> (_reel_number));
        root->add_child("Language")->add_child_text (_language);
 
-       for (list<shared_ptr<InteropLoadFontNode> >::const_iterator i = _load_font_nodes.begin(); i != _load_font_nodes.end(); ++i) {
+       for (auto i: _load_font_nodes) {
                xmlpp::Element* load_font = root->add_child("LoadFont");
-               load_font->set_attribute ("Id", (*i)->id);
-               load_font->set_attribute ("URI", (*i)->uri);
+               load_font->set_attribute ("Id", i->id);
+               load_font->set_attribute ("URI", i->uri);
        }
 
        subtitles_as_xml (root, 250, INTEROP);
@@ -139,8 +140,8 @@ InteropSubtitleAsset::equals (shared_ptr<const Asset> other_asset, EqualityOptio
        }
 
        if (!options.load_font_nodes_can_differ) {
-               list<shared_ptr<InteropLoadFontNode> >::const_iterator i = _load_font_nodes.begin ();
-               list<shared_ptr<InteropLoadFontNode> >::const_iterator j = other->_load_font_nodes.begin ();
+               auto i = _load_font_nodes.begin();
+               auto j = other->_load_font_nodes.begin();
 
                while (i != _load_font_nodes.end ()) {
                        if (j == other->_load_font_nodes.end ()) {
@@ -166,10 +167,10 @@ InteropSubtitleAsset::equals (shared_ptr<const Asset> other_asset, EqualityOptio
        return true;
 }
 
-list<shared_ptr<LoadFontNode> >
+vector<shared_ptr<LoadFontNode>>
 InteropSubtitleAsset::load_font_nodes () const
 {
-       list<shared_ptr<LoadFontNode> > lf;
+       vector<shared_ptr<LoadFontNode>> lf;
        copy (_load_font_nodes.begin(), _load_font_nodes.end(), back_inserter (lf));
        return lf;
 }
@@ -201,7 +202,7 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const
        /* Fonts */
        BOOST_FOREACH (shared_ptr<InteropLoadFontNode> i, _load_font_nodes) {
                boost::filesystem::path file = p.parent_path() / i->uri;
-               list<Font>::const_iterator j = _fonts.begin ();
+               auto j = _fonts.begin();
                while (j != _fonts.end() && j->load_id != i->id) {
                        ++j;
                }
@@ -217,7 +218,7 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const
  *  a list of font ID, load ID and data.
  */
 void
-InteropSubtitleAsset::resolve_fonts (list<shared_ptr<Asset> > assets)
+InteropSubtitleAsset::resolve_fonts (vector<shared_ptr<Asset>> assets)
 {
        BOOST_FOREACH (shared_ptr<Asset> i, assets) {
                shared_ptr<FontAsset> font = dynamic_pointer_cast<FontAsset> (i);
@@ -242,7 +243,7 @@ InteropSubtitleAsset::resolve_fonts (list<shared_ptr<Asset> > assets)
 }
 
 void
-InteropSubtitleAsset::add_font_assets (list<shared_ptr<Asset> >& assets)
+InteropSubtitleAsset::add_font_assets (vector<shared_ptr<Asset>>& assets)
 {
        BOOST_FOREACH (Font const & i, _fonts) {
                DCP_ASSERT (i.file);
index 7ce7d175d5cb176fa1b786c07c0470365e22d6e6..87e82633aa65ae891799b5dd9ba7629a29a43618 100644 (file)
@@ -62,14 +62,14 @@ public:
        void write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const;
        void add_to_pkl (std::shared_ptr<PKL> pkl, boost::filesystem::path root) const;
 
-       std::list<std::shared_ptr<LoadFontNode> > load_font_nodes () const;
+       std::vector<std::shared_ptr<LoadFontNode>> load_font_nodes () const;
 
        void add_font (std::string load_id, dcp::ArrayData data);
 
        std::string xml_as_string () const;
        void write (boost::filesystem::path path) const;
-       void resolve_fonts (std::list<std::shared_ptr<Asset> > assets);
-       void add_font_assets (std::list<std::shared_ptr<Asset> >& assets);
+       void resolve_fonts (std::vector<std::shared_ptr<Asset>> assets);
+       void add_font_assets (std::vector<std::shared_ptr<Asset>>& assets);
        void set_font_file (std::string load_id, boost::filesystem::path file);
 
        /** Set the reel number or sub-element identifier
@@ -123,7 +123,7 @@ private:
        std::string _reel_number;
        std::string _language;
        std::string _movie_title;
-       std::list<std::shared_ptr<InteropLoadFontNode> > _load_font_nodes;
+       std::vector<std::shared_ptr<InteropLoadFontNode>> _load_font_nodes;
 };
 
 }
index a27a9a33aca7a1ccfd3222aac4dd4307fa6d09dd..0ea87219ce944c7b436d8b219a8808b8b70b2ea5 100644 (file)
--- a/src/pkl.h
+++ b/src/pkl.h
@@ -103,7 +103,7 @@ private:
        std::string _issue_date;
        std::string _issuer;
        std::string _creator;
-       std::list<std::shared_ptr<Asset> > _asset_list;
+       std::vector<std::shared_ptr<Asset>> _asset_list;
        /** The most recent disk file used to read or write this PKL */
        mutable boost::optional<boost::filesystem::path> _file;
 };
index 8b7484241ff189076445445cb0d7e4441ad1c796..89056cffef26f68db9b81a4bde791597ba999112 100644 (file)
 #endif
 
 using std::string;
-using std::list;
 using std::cout;
 using std::min;
 using std::make_shared;
 using std::shared_ptr;
 using std::dynamic_pointer_cast;
+using std::vector;
 using namespace dcp;
 
 Reel::Reel (std::shared_ptr<const cxml::Node> node)
@@ -297,10 +297,10 @@ Reel::add (shared_ptr<ReelAsset> asset)
        }
 }
 
-list<shared_ptr<ReelAsset>>
+vector<shared_ptr<ReelAsset>>
 Reel::assets () const
 {
-       list<shared_ptr<ReelAsset>> a;
+       vector<shared_ptr<ReelAsset>> a;
        if (_main_picture) {
                a.push_back (_main_picture);
        }
@@ -318,7 +318,7 @@ Reel::assets () const
 }
 
 void
-Reel::resolve_refs (list<shared_ptr<Asset>> assets)
+Reel::resolve_refs (vector<shared_ptr<Asset>> assets)
 {
        if (_main_picture) {
                _main_picture->asset_ref().resolve (assets);
index 041e1ca117e5cb1180e75e1b516e87c04efa6c70..083ecd0e8f5a7c814e154d8f6bdaf3709abb0611 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.
 
@@ -39,7 +39,6 @@
 #include "ref.h"
 #include <memory>
 #include <boost/function.hpp>
-#include <list>
 
 namespace cxml {
        class Node;
@@ -99,7 +98,7 @@ public:
                return _main_markers;
        }
 
-       std::list<std::shared_ptr<ReelClosedCaptionAsset> > closed_captions () const {
+       std::vector<std::shared_ptr<ReelClosedCaptionAsset>> closed_captions () const {
                return _closed_captions;
        }
 
@@ -111,7 +110,7 @@ public:
 
        void add (std::shared_ptr<ReelAsset> asset);
 
-       std::list<std::shared_ptr<ReelAsset> > assets () const;
+       std::vector<std::shared_ptr<ReelAsset>> assets () const;
 
        xmlpp::Element* write_to_cpl (xmlpp::Element* node, Standard standard) const;
 
@@ -121,14 +120,14 @@ public:
 
        void add (DecryptedKDM const &);
 
-       void resolve_refs (std::list<std::shared_ptr<Asset> >);
+       void resolve_refs (std::vector<std::shared_ptr<Asset>>);
 
 private:
        std::shared_ptr<ReelPictureAsset> _main_picture;
        std::shared_ptr<ReelSoundAsset> _main_sound;
        std::shared_ptr<ReelSubtitleAsset> _main_subtitle;
        std::shared_ptr<ReelMarkersAsset> _main_markers;
-       std::list<std::shared_ptr<ReelClosedCaptionAsset> > _closed_captions;
+       std::vector<std::shared_ptr<ReelClosedCaptionAsset>> _closed_captions;
        std::shared_ptr<ReelAtmosAsset> _atmos;
 };
 
index 7512d32c45891341adebceb8ef7c04a79b437317..8527150d7e552013ae18ee33c9b89d4777f027df 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
 
 #include "ref.h"
 
-using std::list;
 using std::shared_ptr;
+using std::vector;
 using namespace dcp;
 
 /** Look through a list of assets and copy a shared_ptr to any asset
  *  which matches the ID of this one.
  */
 void
-Ref::resolve (list<shared_ptr<Asset> > assets)
+Ref::resolve (vector<shared_ptr<Asset>> assets)
 {
-       list<shared_ptr<Asset> >::iterator i = assets.begin();
+       auto i = assets.begin();
        while (i != assets.end() && !ids_equal ((*i)->id(), _id)) {
                ++i;
        }
index 9ebe19b8d3d168ba34ff249aa697056266f1567e..94add1c8b58a2cdad495e0595ae4fb1a6b1b060c 100644 (file)
--- a/src/ref.h
+++ b/src/ref.h
@@ -54,8 +54,8 @@ namespace dcp {
  *  which represents the thing.
  *
  *  If the Ref does not have a shared_ptr it may be given one by
- *  calling resolve() with a list of assets.  The shared_ptr will be
- *  set up using any object on the list which has a matching ID.
+ *  calling resolve() with a vector of assets.  The shared_ptr will be
+ *  set up using any object on the vector which has a matching ID.
  */
 class Ref
 {
@@ -77,7 +77,7 @@ public:
                _id = id;
        }
 
-       void resolve (std::list<std::shared_ptr<Asset> > assets);
+       void resolve (std::vector<std::shared_ptr<Asset>> assets);
 
        /** @return the ID of the thing that we are pointing to */
        std::string id () const {
index 0e6c1254cb65d5abc8341754f61227e8b788d70e..7604fd397ee50a8f553c5ba8d4d2bf5e2b0f6b12 100644 (file)
@@ -183,7 +183,7 @@ SMPTESubtitleAsset::parse_xml (shared_ptr<cxml::Document> xml)
 
        /* Now we need to drop down to xmlpp */
 
-       list<ParseState> ps;
+       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);
@@ -222,7 +222,7 @@ SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader>
                switch (i->Type) {
                case ASDCP::TimedText::MT_OPENTYPE:
                {
-                       list<shared_ptr<SMPTELoadFontNode> >::const_iterator j = _load_font_nodes.begin ();
+                       auto j = _load_font_nodes.begin();
                        while (j != _load_font_nodes.end() && (*j)->urn != id) {
                                ++j;
                        }
@@ -234,7 +234,7 @@ SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader>
                }
                case ASDCP::TimedText::MT_PNG:
                {
-                       list<shared_ptr<Subtitle> >::const_iterator j = _subtitles.begin ();
+                       auto j = _subtitles.begin();
                        while (j != _subtitles.end() && ((!dynamic_pointer_cast<SubtitleImage>(*j)) || dynamic_pointer_cast<SubtitleImage>(*j)->id() != id)) {
                                ++j;
                        }
@@ -291,10 +291,10 @@ SMPTESubtitleAsset::set_key (Key key)
        read_mxf_descriptor (reader, dec);
 }
 
-list<shared_ptr<LoadFontNode> >
+vector<shared_ptr<LoadFontNode>>
 SMPTESubtitleAsset::load_font_nodes () const
 {
-       list<shared_ptr<LoadFontNode> > lf;
+       vector<shared_ptr<LoadFontNode>> lf;
        copy (_load_font_nodes.begin(), _load_font_nodes.end(), back_inserter (lf));
        return lf;
 }
@@ -362,7 +362,7 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const
        /* Font references */
 
        BOOST_FOREACH (shared_ptr<dcp::SMPTELoadFontNode> i, _load_font_nodes) {
-               list<Font>::const_iterator j = _fonts.begin ();
+               auto j = _fonts.begin();
                while (j != _fonts.end() && j->load_id != i->id) {
                        ++j;
                }
@@ -413,7 +413,7 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const
        /* Font payload */
 
        BOOST_FOREACH (shared_ptr<dcp::SMPTELoadFontNode> i, _load_font_nodes) {
-               list<Font>::const_iterator j = _fonts.begin ();
+               auto j = _fonts.begin();
                while (j != _fonts.end() && j->load_id != i->id) {
                        ++j;
                }
@@ -462,8 +462,8 @@ SMPTESubtitleAsset::equals (shared_ptr<const Asset> other_asset, EqualityOptions
                return false;
        }
 
-       list<shared_ptr<SMPTELoadFontNode> >::const_iterator i = _load_font_nodes.begin ();
-       list<shared_ptr<SMPTELoadFontNode> >::const_iterator j = other->_load_font_nodes.begin ();
+       auto i = _load_font_nodes.begin();
+       auto j = other->_load_font_nodes.begin();
 
        while (i != _load_font_nodes.end ()) {
                if (j == other->_load_font_nodes.end ()) {
index 6d7019a5f8ad569ba008dc2e03eb9d573d136d03..3459f559aaa1aceee366428f46d45214df1790d3 100644 (file)
@@ -73,7 +73,7 @@ public:
                NoteHandler note
                ) const;
 
-       std::list<std::shared_ptr<LoadFontNode> > load_font_nodes () const;
+       std::vector<std::shared_ptr<LoadFontNode>> load_font_nodes () const;
 
        std::string xml_as_string () const;
        void write (boost::filesystem::path path) const;
@@ -199,7 +199,7 @@ private:
        int _time_code_rate;
        boost::optional<Time> _start_time;
 
-       std::list<std::shared_ptr<SMPTELoadFontNode> > _load_font_nodes;
+       std::vector<std::shared_ptr<SMPTELoadFontNode>> _load_font_nodes;
        /** UUID for the XML inside the MXF, which should be different to the ID of the MXF according to
         *  Doremi's 2.8.18 release notes.
         */
index 570877ab6d9c9a8cbf86686b3f959d2cd3189f07..59aff6befaf5771a219c48d43344e52cd1f5e7ab 100644 (file)
 #include <boost/shared_array.hpp>
 #include <boost/foreach.hpp>
 
+using std::dynamic_pointer_cast;
 using std::string;
-using std::list;
 using std::cout;
 using std::cerr;
 using std::map;
 using std::shared_ptr;
+using std::vector;
 using boost::shared_array;
 using boost::optional;
-using std::dynamic_pointer_cast;
 using boost::lexical_cast;
 using namespace dcp;
 
@@ -251,7 +251,7 @@ SubtitleAsset::fade_time (xmlpp::Element const * node, string name, optional<int
 }
 
 void
-SubtitleAsset::parse_subtitles (xmlpp::Element const * node, list<ParseState>& state, optional<int> tcr, Standard standard)
+SubtitleAsset::parse_subtitles (xmlpp::Element const * node, vector<ParseState>& state, optional<int> tcr, Standard standard)
 {
        if (node->get_name() == "Font") {
                state.push_back (font_node_state (node, standard));
@@ -283,7 +283,7 @@ SubtitleAsset::parse_subtitles (xmlpp::Element const * node, list<ParseState>& s
 }
 
 void
-SubtitleAsset::maybe_add_subtitle (string text, list<ParseState> const & parse_state, Standard standard)
+SubtitleAsset::maybe_add_subtitle (string text, vector<ParseState> const & parse_state, Standard standard)
 {
        if (empty_or_white_space (text)) {
                return;
@@ -407,10 +407,10 @@ SubtitleAsset::maybe_add_subtitle (string text, list<ParseState> const & parse_s
        }
 }
 
-list<shared_ptr<Subtitle> >
+vector<shared_ptr<Subtitle>>
 SubtitleAsset::subtitles_during (Time from, Time to, bool starting) const
 {
-       list<shared_ptr<Subtitle> > s;
+       vector<shared_ptr<Subtitle> > s;
        BOOST_FOREACH (shared_ptr<Subtitle> i, _subtitles) {
                if ((starting && from <= i->in() && i->in() < to) || (!starting && i->out() >= from && i->in() <= to)) {
                        s.push_back (i);
@@ -456,8 +456,8 @@ SubtitleAsset::equals (shared_ptr<const Asset> other_asset, EqualityOptions opti
                return false;
        }
 
-       list<shared_ptr<Subtitle> >::const_iterator i = _subtitles.begin ();
-       list<shared_ptr<Subtitle> >::const_iterator j = other->_subtitles.begin ();
+       auto i = _subtitles.begin();
+       auto j = other->_subtitles.begin();
 
        while (i != _subtitles.end()) {
                shared_ptr<SubtitleString> string_i = dynamic_pointer_cast<SubtitleString> (*i);
@@ -524,8 +524,8 @@ SubtitleAsset::pull_fonts (shared_ptr<order::Part> part)
        }
 
        /* Merge adjacent children with the same font */
-       list<shared_ptr<order::Part> >::const_iterator i = part->children.begin();
-       list<shared_ptr<order::Part> > merged;
+       auto i = part->children.begin();
+       vector<shared_ptr<order::Part>> merged;
 
        while (i != part->children.end()) {
 
@@ -533,7 +533,7 @@ SubtitleAsset::pull_fonts (shared_ptr<order::Part> part)
                        merged.push_back (*i);
                        ++i;
                } else {
-                       list<shared_ptr<order::Part> >::const_iterator j = i;
+                       auto j = i;
                        ++j;
                        while (j != part->children.end() && (*i)->font == (*j)->font) {
                                ++j;
@@ -543,7 +543,7 @@ SubtitleAsset::pull_fonts (shared_ptr<order::Part> part)
                                ++i;
                        } else {
                                shared_ptr<order::Part> group (new order::Part (part, (*i)->font));
-                               for (list<shared_ptr<order::Part> >::const_iterator k = i; k != j; ++k) {
+                               for (auto k = i; k != j; ++k) {
                                        (*k)->font.clear ();
                                        group->children.push_back (*k);
                                }
@@ -562,8 +562,8 @@ SubtitleAsset::pull_fonts (shared_ptr<order::Part> part)
 void
 SubtitleAsset::subtitles_as_xml (xmlpp::Element* xml_root, int time_code_rate, Standard standard) const
 {
-       list<shared_ptr<Subtitle> > sorted = _subtitles;
-       sorted.sort (SubtitleSorter ());
+       vector<shared_ptr<Subtitle> > sorted = _subtitles;
+       std::stable_sort(sorted.begin(), sorted.end(), SubtitleSorter());
 
        /* Gather our subtitles into a hierarchy of Subtitle/Text/String objects, writing
           font information into the bottom level (String) objects.
@@ -678,7 +678,7 @@ void
 SubtitleAsset::fix_empty_font_ids ()
 {
        bool have_empty = false;
-       list<string> ids;
+       vector<string> ids;
        BOOST_FOREACH (shared_ptr<LoadFontNode> i, load_font_nodes()) {
                if (i->id == "") {
                        have_empty = true;
index dff31cc69d91b78ee37d0077e89699c26cc667d8..60ddc357d72da3d7bd58e191030677ec023fe151 100644 (file)
@@ -88,8 +88,8 @@ public:
                NoteHandler note
                ) const;
 
-       std::list<std::shared_ptr<Subtitle> > subtitles_during (Time from, Time to, bool starting) const;
-       std::list<std::shared_ptr<Subtitle> > const & subtitles () const {
+       std::vector<std::shared_ptr<Subtitle>> subtitles_during (Time from, Time to, bool starting) const;
+       std::vector<std::shared_ptr<Subtitle>> const & subtitles () const {
                return _subtitles;
        }
 
@@ -105,7 +105,7 @@ public:
 
        void fix_empty_font_ids ();
 
-       virtual std::list<std::shared_ptr<LoadFontNode> > load_font_nodes () const = 0;
+       virtual std::vector<std::shared_ptr<LoadFontNode>> load_font_nodes () const = 0;
 
        std::string raw_xml () const {
                return _raw_xml;
@@ -141,7 +141,7 @@ protected:
                boost::optional<Type> type;
        };
 
-       void parse_subtitles (xmlpp::Element const * node, std::list<ParseState>& state, boost::optional<int> tcr, Standard standard);
+       void parse_subtitles (xmlpp::Element const * node, std::vector<ParseState>& state, boost::optional<int> tcr, Standard standard);
        ParseState font_node_state (xmlpp::Element const * node, Standard standard) const;
        ParseState text_node_state (xmlpp::Element const * node) const;
        ParseState image_node_state (xmlpp::Element const * node) const;
@@ -152,7 +152,7 @@ protected:
        void subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Standard standard) const;
 
        /** All our subtitles, in no particular order */
-       std::list<std::shared_ptr<Subtitle> > _subtitles;
+       std::vector<std::shared_ptr<Subtitle>> _subtitles;
 
        class Font
        {
@@ -178,7 +178,7 @@ protected:
        };
 
        /** TTF font data that we need */
-       std::list<Font> _fonts;
+       std::vector<Font> _fonts;
 
        /** The raw XML data that we read from our asset; useful for validation */
        std::string _raw_xml;
@@ -188,7 +188,7 @@ private:
        friend struct ::pull_fonts_test2;
        friend struct ::pull_fonts_test3;
 
-       void maybe_add_subtitle (std::string text, std::list<ParseState> const & parse_state, Standard standard);
+       void maybe_add_subtitle (std::string text, std::vector<ParseState> const & parse_state, Standard standard);
 
        static void pull_fonts (std::shared_ptr<order::Part> part);
 };
index 6168ba18e4d60d6d6c84c9d2ed797a801bc35739..8a9ffe18980679a5d80a48e153e3f8181a8226bc 100644 (file)
@@ -107,7 +107,7 @@ public:
 
        std::shared_ptr<Part> parent;
        Font font;
-       std::list<std::shared_ptr<Part> > children;
+       std::vector<std::shared_ptr<Part>> children;
 };
 
 class String : public Part
index 133f6dc945ec2f69b59362cd975747bd83648ae1..f775c5074d317907c96c6c41c21da7ed634f9592 100644 (file)
@@ -66,11 +66,11 @@ using std::wstring;
 using std::cout;
 using std::min;
 using std::max;
-using std::list;
 using std::setw;
 using std::setfill;
 using std::ostream;
 using std::shared_ptr;
+using std::vector;
 using boost::shared_array;
 using boost::optional;
 using boost::function;
@@ -440,7 +440,7 @@ dcp::day_greater_than_or_equal (LocalTime a, LocalTime b)
  *  not in \ref existing.
  */
 string
-dcp::unique_string (list<string> existing, string base)
+dcp::unique_string (vector<string> existing, string base)
 {
        int const max_tries = existing.size() + 1;
        for (int i = 0; i < max_tries; ++i) {
index 9cca8136a558a1c3b142af780800caa48092ff92..232b91ccb44a80b13883fc0a29bd12754716a0f7 100644 (file)
@@ -82,7 +82,7 @@ extern std::string spaces (int n);
 extern void indent (xmlpp::Element* element, int initial);
 extern bool day_less_than_or_equal (LocalTime a, LocalTime b);
 extern bool day_greater_than_or_equal (LocalTime a, LocalTime b);
-extern std::string unique_string (std::list<std::string> existing, std::string base);
+extern std::string unique_string (std::vector<std::string> existing, std::string base);
 extern ASDCP::Dictionary const* asdcp_smpte_dict;
 
 
index 6a9967e60f4d35096c3cd382aa2458f571317d42..a72fb0d276bb02dbf28a737e8204ce2abf0ca36d 100644 (file)
@@ -69,7 +69,6 @@
 #include <boost/noncopyable.hpp>
 #include <boost/algorithm/string.hpp>
 #include <map>
-#include <list>
 #include <vector>
 #include <iostream>
 
@@ -271,7 +270,7 @@ parse (XercesDOMParser& parser, std::string xml)
 
 template <class T>
 void
-validate_xml (T xml, boost::filesystem::path xsd_dtd_directory, list<VerificationNote>& notes)
+validate_xml (T xml, boost::filesystem::path xsd_dtd_directory, vector<VerificationNote>& notes)
 {
        try {
                XMLPlatformUtils::Initialize ();
@@ -396,7 +395,7 @@ verify_asset (shared_ptr<const DCP> dcp, shared_ptr<const ReelMXF> reel_mxf, fun
 
 
 void
-verify_language_tag (string tag, list<VerificationNote>& notes)
+verify_language_tag (string tag, vector<VerificationNote>& notes)
 {
        try {
                dcp::LanguageTag test (tag);
@@ -476,7 +475,7 @@ verify_main_picture_asset (
        shared_ptr<const ReelPictureAsset> reel_asset,
        function<void (string, optional<boost::filesystem::path>)> stage,
        function<void (float)> progress,
-       list<VerificationNote>& notes
+       vector<VerificationNote>& notes
        )
 {
        auto asset = reel_asset->asset();
@@ -588,7 +587,7 @@ verify_main_sound_asset (
        shared_ptr<const ReelSoundAsset> reel_asset,
        function<void (string, optional<boost::filesystem::path>)> stage,
        function<void (float)> progress,
-       list<VerificationNote>& notes
+       vector<VerificationNote>& notes
        )
 {
        auto asset = reel_asset->asset();
@@ -620,7 +619,7 @@ verify_main_sound_asset (
 
 
 static void
-verify_main_subtitle_reel (shared_ptr<const ReelSubtitleAsset> reel_asset, list<VerificationNote>& notes)
+verify_main_subtitle_reel (shared_ptr<const ReelSubtitleAsset> reel_asset, vector<VerificationNote>& notes)
 {
        /* XXX: is Language compulsory? */
        if (reel_asset->language()) {
@@ -630,7 +629,7 @@ verify_main_subtitle_reel (shared_ptr<const ReelSubtitleAsset> reel_asset, list<
 
 
 static void
-verify_closed_caption_reel (shared_ptr<const ReelClosedCaptionAsset> reel_asset, list<VerificationNote>& notes)
+verify_closed_caption_reel (shared_ptr<const ReelClosedCaptionAsset> reel_asset, vector<VerificationNote>& notes)
 {
        /* XXX: is Language compulsory? */
        if (reel_asset->language()) {
@@ -650,7 +649,7 @@ verify_subtitle_asset (
        shared_ptr<const SubtitleAsset> asset,
        function<void (string, optional<boost::filesystem::path>)> stage,
        boost::filesystem::path xsd_dtd_directory,
-       list<VerificationNote>& notes,
+       vector<VerificationNote>& notes,
        State& state,
        bool first_reel
        )
@@ -719,7 +718,7 @@ verify_subtitle_asset (
 
                if (first_reel) {
                        auto subs = smpte->subtitles();
-                       subs.sort ([](shared_ptr<Subtitle> a, shared_ptr<Subtitle> b) {
+                       sort (subs.begin(), subs.end(), [](shared_ptr<Subtitle> a, shared_ptr<Subtitle> b) {
                                return a->in() < b->in();
                        });
                        if (!subs.empty() && subs.front()->in() < dcp::Time(0, 0, 4, 0, 24)) {
@@ -739,7 +738,7 @@ verify_closed_caption_asset (
        shared_ptr<const SubtitleAsset> asset,
        function<void (string, optional<boost::filesystem::path>)> stage,
        boost::filesystem::path xsd_dtd_directory,
-       list<VerificationNote>& notes,
+       vector<VerificationNote>& notes,
        State& state,
        bool first_reel
        )
@@ -756,7 +755,7 @@ verify_closed_caption_asset (
 }
 
 
-list<VerificationNote>
+vector<VerificationNote>
 dcp::verify (
        vector<boost::filesystem::path> directories,
        function<void (string, optional<boost::filesystem::path>)> stage,
@@ -766,10 +765,10 @@ dcp::verify (
 {
        xsd_dtd_directory = boost::filesystem::canonical (xsd_dtd_directory);
 
-       list<VerificationNote> notes;
+       vector<VerificationNote> notes;
        State state;
 
-       list<shared_ptr<DCP>> dcps;
+       vector<shared_ptr<DCP>> dcps;
        for (auto i: directories) {
                dcps.push_back (shared_ptr<DCP> (new DCP (i)));
        }
index f692e867ed288bf852adb4a2889930f802c265dc..8811373036c622f615da73ebf7017406a1e17c7b 100644 (file)
@@ -38,7 +38,6 @@
 #include <boost/function.hpp>
 #include <boost/optional.hpp>
 #include <string>
-#include <list>
 #include <vector>
 
 namespace dcp {
@@ -183,7 +182,7 @@ private:
        uint64_t _line;
 };
 
-std::list<VerificationNote> verify (
+std::vector<VerificationNote> verify (
        std::vector<boost::filesystem::path> directories,
        boost::function<void (std::string, boost::optional<boost::filesystem::path>)> stage,
        boost::function<void (float)> progress,
index e698eea00f7fad1f9cb93af77aae91a5ccab9a27..154ec2105e3865250067b49a4fa68f3b78bd189b 100644 (file)
--- a/src/xml.h
+++ b/src/xml.h
@@ -67,10 +67,10 @@ optional_type_child (std::shared_ptr<const cxml::Node> node, std::string name)
 }
 
 template <class T>
-std::list<std::shared_ptr<T>>
+std::vector<std::shared_ptr<T>>
 type_children (cxml::Node const & node, std::string name)
 {
-        std::list<std::shared_ptr<T> > r;
+        std::vector<std::shared_ptr<T>> r;
        for (auto i: node.node_children(name)) {
                r.push_back (std::make_shared<T>(i));
        }
@@ -78,21 +78,21 @@ type_children (cxml::Node const & node, std::string name)
 }
 
 template <class T>
-std::list<std::shared_ptr<T>>
+std::vector<std::shared_ptr<T>>
 type_children (std::shared_ptr<const cxml::Node> node, std::string name)
 {
        return type_children<T> (*node.get(), name);
 }
 
 template <class T>
-std::list<std::shared_ptr<T>>
+std::vector<std::shared_ptr<T>>
 type_grand_children (cxml::Node const & node, std::string name, std::string sub)
 {
        return type_children<T> (node.node_child(name), sub);
 }
 
 template <class T>
-std::list<std::shared_ptr<T>>
+std::vector<std::shared_ptr<T>>
 type_grand_children (std::shared_ptr<const cxml::Node> node, std::string name, std::string sub)
 {
        return type_grand_children<T> (*node.get(), name, sub);
index c62f0322b687da4459dc49966c798af7c9c46967..89d2f0942022741d10e7d1c0ed9bb797bd85a4eb 100644 (file)
@@ -70,7 +70,7 @@ progress (float)
 
 static
 void
-dump_notes (list<dcp::VerificationNote> const & notes)
+dump_notes (vector<dcp::VerificationNote> const & notes)
 {
        BOOST_FOREACH (dcp::VerificationNote i, notes) {
                std::cout << dcp::note_to_string(i) << "\n";
@@ -84,23 +84,19 @@ check_no_errors (boost::filesystem::path path)
 {
        vector<boost::filesystem::path> directories;
        directories.push_back (path);
-       list<dcp::VerificationNote> notes = dcp::verify (directories, &stage, &progress, xsd_test);
-       for (list<dcp::VerificationNote>::iterator i = notes.begin(); i != notes.end(); ) {
-               list<dcp::VerificationNote>::iterator tmp = i;
-               ++tmp;
-               if (i->code() == dcp::VerificationNote::NOT_SMPTE) {
-                       notes.erase (i);
-               }
-               i = tmp;
-       }
-       dump_notes (notes);
-       BOOST_CHECK (notes.empty());
+       auto notes = dcp::verify (directories, &stage, &progress, xsd_test);
+       vector<dcp::VerificationNote> filtered_notes;
+       std::copy_if (notes.begin(), notes.end(), std::back_inserter(filtered_notes), [](dcp::VerificationNote const& i) {
+               return i.code() != dcp::VerificationNote::NOT_SMPTE;
+       });
+       dump_notes (filtered_notes);
+       BOOST_CHECK (filtered_notes.empty());
 }
 
 
 template <class T>
 shared_ptr<T>
-pointer_to_id_in_list (shared_ptr<T> needle, list<shared_ptr<T> > haystack)
+pointer_to_id_in_vector (shared_ptr<T> needle, vector<shared_ptr<T> > haystack)
 {
        BOOST_FOREACH (shared_ptr<T> i, haystack) {
                if (i->id() == needle->id()) {
@@ -138,11 +134,11 @@ check_combined (vector<boost::filesystem::path> inputs, boost::filesystem::path
                BOOST_REQUIRE (input_dcp.cpls().size() == 1);
                shared_ptr<dcp::CPL> input_cpl = input_dcp.cpls().front();
 
-               shared_ptr<dcp::CPL> output_cpl = pointer_to_id_in_list (input_cpl, output_dcp.cpls());
+               shared_ptr<dcp::CPL> output_cpl = pointer_to_id_in_vector (input_cpl, output_dcp.cpls());
                BOOST_REQUIRE (output_cpl);
 
                BOOST_FOREACH (shared_ptr<dcp::Asset> i, input_dcp.assets(true)) {
-                       shared_ptr<dcp::Asset> o = pointer_to_id_in_list(i, output_dcp.assets());
+                       shared_ptr<dcp::Asset> o = pointer_to_id_in_vector(i, output_dcp.assets());
                        BOOST_REQUIRE_MESSAGE (o, "Could not find " << i->id() << " in combined DCP.");
                        BOOST_CHECK (i->equals(o, options, note_handler));
                }
index 19b0ef8ef036f70adad02bceb29a95be0b3b21df..a6dcd834b4276e977f1da4c76e45c501f098dffc 100644 (file)
@@ -231,7 +231,7 @@ BOOST_AUTO_TEST_CASE (cpl_metadata_read_test1)
        BOOST_CHECK (cpl.main_picture_stored_area().get() == dcp::Size(1998, 1080));
        BOOST_CHECK (cpl.main_picture_active_area().get() == dcp::Size(1440, 1080));
 
-       list<shared_ptr<dcp::Reel> > reels = cpl.reels ();
+       auto reels = cpl.reels ();
        BOOST_REQUIRE_EQUAL (reels.size(), 1);
        BOOST_REQUIRE (reels.front()->main_subtitle()->language());
        BOOST_CHECK_EQUAL (reels.front()->main_subtitle()->language().get(), "de-DE");
@@ -312,7 +312,7 @@ BOOST_AUTO_TEST_CASE (cpl_metadata_write_test1)
        check_xml (
                dcp::file_to_string("test/ref/cpl_metadata_test1.xml"),
                dcp::file_to_string("build/test/cpl_metadata_write_test1.xml"),
-               list<string>()
+               vector<string>()
                );
 }
 
@@ -322,7 +322,7 @@ BOOST_AUTO_TEST_CASE (cpl_metadata_roundtrip_test_1)
 {
        dcp::CPL cpl ("test/ref/cpl_metadata_test1.xml");
        cpl.write_xml ("build/test/cpl_metadata_roundtrip_test1.xml", dcp::SMPTE, shared_ptr<dcp::CertificateChain>());
-       list<string> ignore;
+       vector<string> ignore;
        ignore.push_back ("Id");
        check_xml (
                dcp::file_to_string("test/ref/cpl_metadata_test1.xml"),
@@ -363,7 +363,7 @@ BOOST_AUTO_TEST_CASE (cpl_metadata_write_test2)
        check_xml (
                dcp::file_to_string("test/ref/cpl_metadata_test2.xml"),
                dcp::file_to_string("build/test/cpl_metadata_write_test2.xml"),
-               list<string>()
+               vector<string>()
                );
 }
 
@@ -403,7 +403,7 @@ BOOST_AUTO_TEST_CASE (cpl_metadata_read_test2)
        BOOST_CHECK (cpl.main_picture_stored_area().get() == dcp::Size(1998, 1080));
        BOOST_CHECK (cpl.main_picture_active_area().get() == dcp::Size(1440, 1080));
 
-       list<shared_ptr<dcp::Reel> > reels = cpl.reels ();
+       auto reels = cpl.reels ();
        BOOST_REQUIRE_EQUAL (reels.size(), 1);
 }
 
@@ -413,7 +413,7 @@ BOOST_AUTO_TEST_CASE (cpl_metadata_roundtrip_test_2)
 {
        dcp::CPL cpl ("test/ref/cpl_metadata_test2.xml");
        cpl.write_xml ("build/test/cpl_metadata_roundtrip_test2.xml", dcp::SMPTE, shared_ptr<dcp::CertificateChain>());
-       list<string> ignore;
+       vector<string> ignore;
        ignore.push_back ("Id");
        check_xml (
                dcp::file_to_string("test/ref/cpl_metadata_test2.xml"),
index 1cb6394eb34e3d611e47a5c92dca52c4e5bf949e..b5bfd389155f8b41c298f84bd4a5b232713f4c92 100644 (file)
@@ -54,7 +54,7 @@ BOOST_AUTO_TEST_CASE (cpl_ratings)
 
        cpl.write_xml ("build/test/cpl_ratings.xml", dcp::SMPTE, std::shared_ptr<dcp::CertificateChain>());
 
-       list<string> ignore;
+       vector<string> ignore;
        ignore.push_back ("Id");
        ignore.push_back ("Issuer");
        ignore.push_back ("Creator");
index b573daf1771c20b267306123e9b4b05c181fcaff..faff34390b62d0ae710ea429d1aaf9792469d365 100644 (file)
@@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE (parse_mca_descriptors_from_mxf_test)
                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));
 
-               list<string> ignore;
+               vector<string> ignore;
                check_xml (
                        dynamic_cast<xmlpp::Element*>(
                                ref.node_child("ReelList")->node_children("Reel").front()->node_child("AssetList")->node_child("CompositionMetadataAsset")->node_child("MCASubDescriptors")->node()
@@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE (write_mca_descriptors_to_mxf_test)
        cxml::Document ref("CompositionPlaylist", private_test / "51_sound_with_mca_1.cpl");
        cxml::Document check("CompositionPlaylist", "build/test/write_mca_descriptors_to_mxf_test/cpl.xml");
 
-       list<string> ignore;
+       vector<string> ignore;
        ignore.push_back ("InstanceID");
        ignore.push_back ("MCALinkID");
        ignore.push_back ("SoundfieldGroupLinkID");
index c885523ad2bebe2a4079a08bb863d7af3948dec1..7eed18d0aa82c159218f7101d69c842259b9402d 100644 (file)
@@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE (read_dcp_test1)
        dcp::DCP d ("test/ref/DCP/dcp_test1");
        d.read ();
 
-       list<shared_ptr<dcp::CPL> > cpls = d.cpls ();
+       auto cpls = d.cpls ();
        BOOST_CHECK_EQUAL (cpls.size(), 1);
 
        BOOST_CHECK_EQUAL (cpls.front()->annotation_text(), "A Test DCP");
@@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE (read_dcp_test2)
        dcp::DCP d ("test/ref/DCP/dcp_test3");
        d.read ();
 
-       list<shared_ptr<dcp::CPL> > cpls = d.cpls ();
+       auto cpls = d.cpls ();
        BOOST_CHECK_EQUAL (cpls.size(), 1);
 
        BOOST_CHECK_EQUAL (cpls.front()->annotation_text(), "Test_FTR-1_F-119_10_2K_20160524_IOP_OV");
index c665bcc21d66690e8ce6d10d88ddea4a97eda840..ba09722226756ff91fda9f4c7207d7484ef5385b 100644 (file)
@@ -53,14 +53,14 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
        BOOST_CHECK_EQUAL (subs.reel_number(), "1");
        BOOST_CHECK_EQUAL (subs.language(), "French");
 
-       list<shared_ptr<dcp::LoadFontNode> > lfn = subs.load_font_nodes ();
+       auto lfn = subs.load_font_nodes ();
        BOOST_REQUIRE_EQUAL (lfn.size(), 1);
        shared_ptr<dcp::InteropLoadFontNode> interop_lfn = dynamic_pointer_cast<dcp::InteropLoadFontNode> (lfn.front ());
        BOOST_REQUIRE (interop_lfn);
        BOOST_CHECK_EQUAL (interop_lfn->id, "theFontId");
        BOOST_CHECK_EQUAL (interop_lfn->uri, "arial.ttf");
 
-       list<shared_ptr<dcp::Subtitle> > s = subs.subtitles_during (dcp::Time (0, 0, 6, 1, 250), dcp::Time (0, 0, 6, 2, 250), false);
+       auto s = subs.subtitles_during (dcp::Time (0, 0, 6, 1, 250), dcp::Time (0, 0, 6, 2, 250), false);
        BOOST_REQUIRE_EQUAL (s.size(), 1);
        BOOST_REQUIRE (dynamic_pointer_cast<dcp::SubtitleString>(s.front()));
        BOOST_CHECK_EQUAL (*dynamic_pointer_cast<dcp::SubtitleString>(s.front()), dcp::SubtitleString (
@@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
 {
        dcp::InteropSubtitleAsset subs ("test/data/subs2.xml");
 
-       list<shared_ptr<dcp::Subtitle> > s = subs.subtitles_during (dcp::Time (0, 0, 42, 100, 250), dcp::Time (0, 0, 42, 101, 250), false);
+       auto s = subs.subtitles_during (dcp::Time (0, 0, 42, 100, 250), dcp::Time (0, 0, 42, 101, 250), false);
        BOOST_REQUIRE_EQUAL (s.size(), 2);
        BOOST_REQUIRE (dynamic_pointer_cast<dcp::SubtitleString>(s.front()));
        BOOST_CHECK_EQUAL (*dynamic_pointer_cast<dcp::SubtitleString>(s.front()), dcp::SubtitleString (
index 7c367bd43baf6f7ec6fd5442d762320b182aa310..8fbf02144dad494d5d028d3d132f083d72304e24 100644 (file)
@@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test)
        BOOST_CHECK_EQUAL (sc.edit_rate(), dcp::Fraction (25, 1));
        BOOST_CHECK_EQUAL (sc.time_code_rate(), 25);
        BOOST_CHECK_EQUAL (sc.start_time(), dcp::Time (0, 0, 0, 0, 25));
-       list<shared_ptr<dcp::LoadFontNode> > lfn = sc.load_font_nodes ();
+       auto lfn = sc.load_font_nodes ();
        BOOST_REQUIRE_EQUAL (lfn.size(), 1);
        shared_ptr<dcp::SMPTELoadFontNode> smpte_lfn = dynamic_pointer_cast<dcp::SMPTELoadFontNode> (lfn.front ());
        BOOST_REQUIRE (smpte_lfn);
@@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test2)
        dcp::SMPTESubtitleAsset sc (private_test / "olsson.xml");
 
        BOOST_REQUIRE_EQUAL (sc.subtitles().size(), 6);
-       list<shared_ptr<dcp::Subtitle> >::const_iterator i = sc.subtitles().begin();
+       auto i = sc.subtitles().begin();
        shared_ptr<dcp::SubtitleString> is = dynamic_pointer_cast<dcp::SubtitleString>(*i);
        BOOST_REQUIRE (is);
        BOOST_CHECK_EQUAL (is->text(), "Testing is ");
index a6c708e3bd87185249ac38262aee93769176a4b9..0a6f4c6cc171e64e676665ede800dd7966d3d6ec 100644 (file)
@@ -61,14 +61,10 @@ main (int argc, char* argv[])
                DCP* dcp = new DCP (argv[1]);
                dcp->read ();
 
-               list<shared_ptr<CPL> > cpls = dcp->cpls ();
-               for (list<std::shared_ptr<CPL> >::iterator i = cpls.begin(); i != cpls.end(); ++i) {
-
-                       list<shared_ptr<Reel> > reels = (*i)->reels ();
-                       for (list<shared_ptr<Reel> >::iterator j = reels.begin(); j != reels.end(); ++j) {
-
-                               if ((*j)->main_subtitle()) {
-                                       (*j)->main_subtitle()->asset()->write ((*j)->main_subtitle()->asset()->file().get());
+               for (auto i: dcp->cpls()) {
+                       for (auto j: i->reels()) {
+                               if (j->main_subtitle()) {
+                                       j->main_subtitle()->asset()->write(j->main_subtitle()->asset()->file().get());
                                }
                        }
                }
index 3fa61fd0bd62ddf239280337f9f3ff7b1bcfd235..f730485bc65adb72783ebd4d572282b7d3578753 100644 (file)
@@ -109,10 +109,10 @@ BOOST_AUTO_TEST_CASE (round_trip_test)
 
        /* Check that the decrypted KDMKeys are the same as the ones we started with */
        BOOST_CHECK_EQUAL (kdm_A.keys().size(), kdm_B.keys().size());
-       list<dcp::DecryptedKDMKey> keys_A = kdm_A.keys ();
-       list<dcp::DecryptedKDMKey> keys_B = kdm_B.keys ();
-       list<dcp::DecryptedKDMKey>::const_iterator i = keys_A.begin();
-       list<dcp::DecryptedKDMKey>::const_iterator j = keys_B.begin();
+       auto keys_A = kdm_A.keys ();
+       auto keys_B = kdm_B.keys ();
+       auto i = keys_A.begin();
+       auto j = keys_B.begin();
        while (i != keys_A.end ()) {
                BOOST_CHECK (*i == *j);
                ++i;
index a939f57129d609bead3acf26e08e8964b943c5d0..8d47dac4df0c03e70b06e6ef9b42e5aa15bb65cd 100644 (file)
@@ -65,7 +65,6 @@
 
 using std::string;
 using std::min;
-using std::list;
 using std::vector;
 using std::shared_ptr;
 using boost::optional;
@@ -95,7 +94,7 @@ struct TestConfig
 };
 
 void
-check_xml (xmlpp::Element* ref, xmlpp::Element* test, list<string> ignore_tags, bool ignore_whitespace)
+check_xml (xmlpp::Element* ref, xmlpp::Element* test, vector<string> ignore_tags, bool ignore_whitespace)
 {
        BOOST_CHECK_EQUAL (ref->get_name (), test->get_name ());
        BOOST_CHECK_EQUAL (ref->get_namespace_prefix (), test->get_namespace_prefix ());
@@ -183,7 +182,7 @@ check_xml (xmlpp::Element* ref, xmlpp::Element* test, list<string> ignore_tags,
 }
 
 void
-check_xml (string ref, string test, list<string> ignore, bool ignore_whitespace)
+check_xml (string ref, string test, vector<string> ignore, bool ignore_whitespace)
 {
        xmlpp::DomParser* ref_parser = new xmlpp::DomParser ();
        ref_parser->parse_memory (ref);
index 10f99ce1f30785f2d77fee9b5ab05662c445c426..fb299d1de83b54b00fe0a4eaa2d6d61c34773193 100644 (file)
@@ -40,8 +40,8 @@ namespace dcp {
 extern boost::filesystem::path private_test;
 extern boost::filesystem::path xsd_test;
 
-extern void check_xml (xmlpp::Element* ref, xmlpp::Element* test, std::list<std::string> ignore_tags, bool ignore_whitespace = false);
-extern void check_xml (std::string ref, std::string test, std::list<std::string> ignore, bool ignore_whitespace = false);
+extern void check_xml (xmlpp::Element* ref, xmlpp::Element* test, std::vector<std::string> ignore_tags, bool ignore_whitespace = false);
+extern void check_xml (std::string ref, std::string test, std::vector<std::string> ignore, bool ignore_whitespace = false);
 extern void check_file (boost::filesystem::path ref, boost::filesystem::path check);
 extern std::shared_ptr<dcp::MonoPictureAsset> simple_picture (boost::filesystem::path path, std::string suffix);
 extern std::shared_ptr<dcp::SoundAsset> simple_sound (boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language);
index b82b3f18622924bd09144fe898b55c6bbc660617..21a0d7bc64688d0a0f739cc86b41c6f1d4ca5cab 100644 (file)
@@ -38,7 +38,7 @@
 
 using std::ifstream;
 using std::string;
-using std::list;
+using std::vector;
 
 /** Test dcp::base64_decode */
 BOOST_AUTO_TEST_CASE (base64_decode_test)
@@ -266,7 +266,7 @@ BOOST_AUTO_TEST_CASE (day_greater_than_or_equal_test)
 
 BOOST_AUTO_TEST_CASE (unique_string_test)
 {
-       list<string> existing;
+       vector<string> existing;
        for (int i = 0; i < 16; i++) {
                string s;
                BOOST_CHECK_NO_THROW (s = dcp::unique_string(existing, "foo"));
index 98a9cd96f84a2ab5d6a37063e346a1a13c23ce40..4f0fe6f1b74013409e483d00fec4eeee6554c2c4 100644 (file)
@@ -149,7 +149,7 @@ private:
 
 static
 void
-dump_notes (list<dcp::VerificationNote> const & notes)
+dump_notes (vector<dcp::VerificationNote> const & notes)
 {
        for (auto i: notes) {
                std::cout << dcp::note_to_string(i) << "\n";
@@ -900,7 +900,7 @@ BOOST_AUTO_TEST_CASE (verify_various_invalid_languages)
 
 
 static
-list<dcp::VerificationNote>
+vector<dcp::VerificationNote>
 check_picture_size (int width, int height, int frame_rate, bool three_d)
 {
        using namespace boost::filesystem;
index deb18339746bab96fb78a3c0012e2bcc06260556..fee2d84176248cbc31c2ac022ade79873104fe38 100644 (file)
 #include "util.h"
 #include <boost/test/unit_test.hpp>
 
-using std::list;
 using std::string;
-using boost::optional;
 using std::shared_ptr;
+using std::vector;
+using boost::optional;
 
 /** Test dcp::order::Font::take_intersection */
 BOOST_AUTO_TEST_CASE (take_intersection_test)
@@ -238,7 +238,7 @@ BOOST_AUTO_TEST_CASE (write_interop_subtitle_test)
                  "</Font>"
                "</DCSubtitle>",
                c.xml_as_string (),
-               list<string> ()
+               vector<string>()
                );
 }
 
@@ -324,7 +324,7 @@ BOOST_AUTO_TEST_CASE (write_interop_subtitle_test2)
                  "</Font>"
                "</DCSubtitle>",
                c.xml_as_string (),
-               list<string> ()
+               vector<string>()
                );
 }
 
@@ -385,20 +385,20 @@ BOOST_AUTO_TEST_CASE (write_interop_subtitle_test3)
        check_xml (
                dcp::file_to_string("test/ref/write_interop_subtitle_test3/subs.xml"),
                dcp::file_to_string("build/test/write_interop_subtitle_test3/subs.xml"),
-               list<string>()
+               vector<string>()
                );
        check_file ("build/test/write_interop_subtitle_test3/d36f4bb3-c4fa-4a95-9915-6fec3110cd71.png", "test/data/sub.png");
 
        check_xml (
                dcp::file_to_string("test/ref/write_interop_subtitle_test3/ASSETMAP"),
                dcp::file_to_string("build/test/write_interop_subtitle_test3/ASSETMAP"),
-               list<string>()
+               vector<string>()
                );
 
        check_xml (
                dcp::file_to_string("test/ref/write_interop_subtitle_test3/pkl.xml"),
                dcp::file_to_string("build/test/write_interop_subtitle_test3/pkl_6a9e31a6-50a4-4ecb-8683-fa667848470a.xml"),
-               list<string>()
+               vector<string>()
                );
 }
 
@@ -489,7 +489,7 @@ BOOST_AUTO_TEST_CASE (write_smpte_subtitle_test)
                  "</dcst:SubtitleList>"
                "</dcst:SubtitleReel>",
                c.xml_as_string (),
-               list<string> ()
+               vector<string>()
                );
 }
 
@@ -690,7 +690,7 @@ BOOST_AUTO_TEST_CASE (write_smpte_subtitle_test2)
                    "</dcst:Font>"
                  "</dcst:SubtitleList>"
                "</dcst:SubtitleReel>",
-               list<string> ()
+               vector<string>()
                );
 }
 
index ca3fd2c5afd226cc93332a860da66e03a08ef832..73d6267930a82890e16fde77574ba78cca45f85b 100644 (file)
 #include "common.h"
 #include "dcp.h"
 
-using std::list;
-using std::shared_ptr;
 using std::dynamic_pointer_cast;
+using std::shared_ptr;
+using std::vector;
 
 void
-dcp::filter_notes (list<dcp::VerificationNote>& notes, bool ignore_missing_assets)
+dcp::filter_notes (vector<dcp::VerificationNote>& notes, bool ignore_missing_assets)
 {
-       for (list<dcp::VerificationNote>::iterator i = notes.begin(); i != notes.end(); ) {
-
-               list<dcp::VerificationNote>::iterator tmp = i;
-               ++tmp;
+       if (!ignore_missing_assets) {
+               return;
+       }
 
-               if (ignore_missing_assets && (i->code() == dcp::VerificationNote::MISSING_ASSET || i->code() == dcp::VerificationNote::EXTERNAL_ASSET)) {
-                       notes.erase (i);
-               }
+       vector<dcp::VerificationNote> filtered;
+       std::copy_if (notes.begin(), notes.end(), std::back_inserter(filtered), [](dcp::VerificationNote const& i) {
+               return i.code() != dcp::VerificationNote::MISSING_ASSET && i.code() != dcp::VerificationNote::EXTERNAL_ASSET;
+       });
 
-               i = tmp;
-       }
+       notes = filtered;
 }
index 0ef0b0813fead07922708754cd9030f70c839434..dc8d115c0f1b292cd88d225d2ea4d175d5e0cff9 100644 (file)
@@ -21,6 +21,6 @@
 
 namespace dcp {
 
-extern void filter_notes (std::list<dcp::VerificationNote>& notes, bool ignore_missing_assets);
+extern void filter_notes (std::vector<dcp::VerificationNote>& notes, bool ignore_missing_assets);
 
 }
index 5f9911d449bce0ca4de8d4991a92a473e009e9a4..7da55ccc2677de2dd6184d9a2200b2bcc47835ed 100644 (file)
@@ -48,6 +48,7 @@ using std::cerr;
 using std::cout;
 using std::string;
 using std::shared_ptr;
+using std::vector;
 using boost::optional;
 using std::dynamic_pointer_cast;
 #if BOOST_VERSION >= 106100
@@ -95,7 +96,7 @@ load_dcp (boost::filesystem::path path, bool ignore_missing_assets, optional<str
        DCP* dcp = 0;
        try {
                dcp = new DCP (path);
-               list<dcp::VerificationNote> notes;
+               vector<dcp::VerificationNote> notes;
                dcp->read (&notes);
                filter_notes (notes, ignore_missing_assets);
                BOOST_FOREACH (dcp::VerificationNote i, notes) {
@@ -103,9 +104,9 @@ load_dcp (boost::filesystem::path path, bool ignore_missing_assets, optional<str
                }
 
                if (key) {
-                       list<shared_ptr<Asset> > assets = dcp->assets ();
-                       for (list<shared_ptr<Asset> >::const_iterator i = assets.begin(); i != assets.end(); ++i) {
-                               shared_ptr<MXF> mxf = dynamic_pointer_cast<MXF> (*i);
+                       auto assets = dcp->assets ();
+                       for (auto i: assets) {
+                               shared_ptr<MXF> mxf = dynamic_pointer_cast<MXF>(i);
                                if (mxf) {
                                        mxf->set_key (Key (key.get ()));
                                }
index 28b67a8dd9712f2bb581f1714c671c4b349609c3..18ed788681c254cbdb5aa004aa92fea29530995a 100644 (file)
@@ -248,7 +248,7 @@ main_subtitle (vector<string> const& only, shared_ptr<Reel> reel, bool list_subt
        OUTPUT_SUBTITLE("      Subtitle ID: %1", ms->id());
 
        if (ms->asset_ref().resolved()) {
-               list<shared_ptr<Subtitle> > subs = ms->asset()->subtitles ();
+               auto subs = ms->asset()->subtitles ();
                OUTPUT_SUBTITLE("\n      Subtitle:    %1 subtitles", subs.size());
                shared_ptr<InteropSubtitleAsset> iop = dynamic_pointer_cast<InteropSubtitleAsset> (ms->asset());
                if (iop) {
@@ -360,10 +360,10 @@ main (int argc, char* argv[])
                only = boost::split(only, *only_string, boost::is_any_of(","));
        }
 
-       list<shared_ptr<CPL> > cpls;
+       vector<shared_ptr<CPL> > cpls;
        if (boost::filesystem::is_directory(argv[optind])) {
                DCP* dcp = 0;
-               list<dcp::VerificationNote> notes;
+               vector<dcp::VerificationNote> notes;
                try {
                        dcp = new DCP (argv[optind]);
                        dcp->read (&notes);
index 9105f2a7f6d77e15e22f5bc541e6ab8144dcd2bb..49699f5e54108cf6347892217474590a9c2d1fa0 100644 (file)
@@ -45,8 +45,8 @@
 using std::cerr;
 using std::cout;
 using std::string;
-using std::list;
 using std::shared_ptr;
+using std::vector;
 using boost::optional;
 
 static void
@@ -102,7 +102,7 @@ main (int argc, char* argv[])
        /* Try to read it and report errors */
 
        dcp::DCP dcp (dcp_dir);
-       list<dcp::VerificationNote> notes;
+       vector<dcp::VerificationNote> notes;
        try {
                dcp.read (&notes, true);
        } catch (dcp::ReadError& e) {
@@ -137,7 +137,7 @@ main (int argc, char* argv[])
                }
 
                /* Read all MXF assets */
-               list<shared_ptr<dcp::Asset> > assets;
+               vector<shared_ptr<dcp::Asset>> assets;
                for (boost::filesystem::directory_iterator i(dcp_dir); i != boost::filesystem::directory_iterator(); ++i) {
                        if (i->path().extension() == ".mxf") {
                                try {
index b3c93bdd297d53eb0144e39b445fe6680259542c..eaecb0f17bf7fbde5bc6c671cbd4c30a50a7962c 100644 (file)
@@ -138,7 +138,7 @@ main (int argc, char* argv[])
 
        vector<boost::filesystem::path> directories;
        directories.push_back (argv[optind]);
-       list<dcp::VerificationNote> notes = dcp::verify (directories, bind(&stage, quiet, _1, _2), bind(&progress), "xsd");
+       auto notes = dcp::verify (directories, bind(&stage, quiet, _1, _2), bind(&progress), "xsd");
        dcp::filter_notes (notes, ignore_missing_assets);
 
        bool failed = false;