diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-01-11 00:16:40 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-01-17 20:13:23 +0100 |
| commit | d95eacd3851a20e52202465ec22b4f72a4983dc8 (patch) | |
| tree | 1dfc1092ae7d2e6b6b7c313ad808415f578d9712 | |
| parent | cbee0d077e698541afcea82a95bafcea5245ab89 (diff) | |
Replace std::list with std::vector in the API.
49 files changed, 224 insertions, 234 deletions
diff --git a/examples/read_dcp.cc b/examples/read_dcp.cc index 6a36d009..9c6c307a 100644 --- a/examples/read_dcp.cc +++ b/examples/read_dcp.cc @@ -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 */ diff --git a/src/certificate_chain.cc b/src/certificate_chain.cc index 2fb0f651..a4da0931 100644 --- a/src/certificate_chain.cc +++ b/src/certificate_chain.cc @@ -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; diff --git a/src/certificate_chain.h b/src/certificate_chain.h index 63ef8901..c74bc6e2 100644 --- a/src/certificate_chain.h +++ b/src/certificate_chain.h @@ -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; diff --git a/src/combine.cc b/src/combine.cc index 5c9a1087..cd91d5b1 100644 --- a/src/combine.cc +++ b/src/combine.cc @@ -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); @@ -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); @@ -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; @@ -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()) { @@ -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; diff --git a/src/decrypted_kdm.cc b/src/decrypted_kdm.cc index 043eac47..dd6def32 100644 --- a/src/decrypted_kdm.cc +++ b/src/decrypted_kdm.cc @@ -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()); diff --git a/src/decrypted_kdm.h b/src/decrypted_kdm.h index a67fdbfe..867e97ff 100644 --- a/src/decrypted_kdm.h +++ b/src/decrypted_kdm.h @@ -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; }; } diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc index 77345a5d..a124fdf6 100644 --- a/src/encrypted_kdm.cc +++ b/src/encrypted_kdm.cc @@ -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; diff --git a/src/encrypted_kdm.h b/src/encrypted_kdm.h index 175b578f..342bedca 100644 --- a/src/encrypted_kdm.h +++ b/src/encrypted_kdm.h @@ -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; diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc index ac3dcc98..edc51404 100644 --- a/src/interop_subtitle_asset.cc +++ b/src/interop_subtitle_asset.cc @@ -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); diff --git a/src/interop_subtitle_asset.h b/src/interop_subtitle_asset.h index 7ce7d175..87e82633 100644 --- a/src/interop_subtitle_asset.h +++ b/src/interop_subtitle_asset.h @@ -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; }; } @@ -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; }; diff --git a/src/reel.cc b/src/reel.cc index 8b748424..89056cff 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -59,12 +59,12 @@ #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); @@ -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; }; @@ -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. @@ -33,17 +33,17 @@ #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; } @@ -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 { diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc index 0e6c1254..7604fd39 100644 --- a/src/smpte_subtitle_asset.cc +++ b/src/smpte_subtitle_asset.cc @@ -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 ()) { diff --git a/src/smpte_subtitle_asset.h b/src/smpte_subtitle_asset.h index 6d7019a5..3459f559 100644 --- a/src/smpte_subtitle_asset.h +++ b/src/smpte_subtitle_asset.h @@ -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. */ diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc index 570877ab..59aff6be 100644 --- a/src/subtitle_asset.cc +++ b/src/subtitle_asset.cc @@ -49,15 +49,15 @@ #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; diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h index dff31cc6..60ddc357 100644 --- a/src/subtitle_asset.h +++ b/src/subtitle_asset.h @@ -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); }; diff --git a/src/subtitle_asset_internal.h b/src/subtitle_asset_internal.h index 6168ba18..8a9ffe18 100644 --- a/src/subtitle_asset_internal.h +++ b/src/subtitle_asset_internal.h @@ -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 diff --git a/src/util.cc b/src/util.cc index 133f6dc9..f775c507 100644 --- a/src/util.cc +++ b/src/util.cc @@ -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) { @@ -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; diff --git a/src/verify.cc b/src/verify.cc index 6a9967e6..a72fb0d2 100644 --- a/src/verify.cc +++ b/src/verify.cc @@ -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))); } diff --git a/src/verify.h b/src/verify.h index f692e867..88113730 100644 --- a/src/verify.h +++ b/src/verify.h @@ -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, @@ -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); diff --git a/test/combine_test.cc b/test/combine_test.cc index c62f0322..89d2f094 100644 --- a/test/combine_test.cc +++ b/test/combine_test.cc @@ -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)); } diff --git a/test/cpl_metadata_test.cc b/test/cpl_metadata_test.cc index 19b0ef8e..a6dcd834 100644 --- a/test/cpl_metadata_test.cc +++ b/test/cpl_metadata_test.cc @@ -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"), diff --git a/test/cpl_ratings_test.cc b/test/cpl_ratings_test.cc index 1cb6394e..b5bfd389 100644 --- a/test/cpl_ratings_test.cc +++ b/test/cpl_ratings_test.cc @@ -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"); diff --git a/test/mca_test.cc b/test/mca_test.cc index b573daf1..faff3439 100644 --- a/test/mca_test.cc +++ b/test/mca_test.cc @@ -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"); diff --git a/test/read_dcp_test.cc b/test/read_dcp_test.cc index c885523a..7eed18d0 100644 --- a/test/read_dcp_test.cc +++ b/test/read_dcp_test.cc @@ -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"); diff --git a/test/read_interop_subtitle_test.cc b/test/read_interop_subtitle_test.cc index c665bcc2..ba097222 100644 --- a/test/read_interop_subtitle_test.cc +++ b/test/read_interop_subtitle_test.cc @@ -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 ( diff --git a/test/read_smpte_subtitle_test.cc b/test/read_smpte_subtitle_test.cc index 7c367bd4..8fbf0214 100644 --- a/test/read_smpte_subtitle_test.cc +++ b/test/read_smpte_subtitle_test.cc @@ -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 "); diff --git a/test/rewrite_subs.cc b/test/rewrite_subs.cc index a6c708e3..0a6f4c6c 100644 --- a/test/rewrite_subs.cc +++ b/test/rewrite_subs.cc @@ -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()); } } } diff --git a/test/round_trip_test.cc b/test/round_trip_test.cc index 3fa61fd0..f730485b 100644 --- a/test/round_trip_test.cc +++ b/test/round_trip_test.cc @@ -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; diff --git a/test/test.cc b/test/test.cc index a939f571..8d47dac4 100644 --- a/test/test.cc +++ b/test/test.cc @@ -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); diff --git a/test/test.h b/test/test.h index 10f99ce1..fb299d1d 100644 --- a/test/test.h +++ b/test/test.h @@ -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); diff --git a/test/util_test.cc b/test/util_test.cc index b82b3f18..21a0d7bc 100644 --- a/test/util_test.cc +++ b/test/util_test.cc @@ -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")); diff --git a/test/verify_test.cc b/test/verify_test.cc index 98a9cd96..4f0fe6f1 100644 --- a/test/verify_test.cc +++ b/test/verify_test.cc @@ -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; diff --git a/test/write_subtitle_test.cc b/test/write_subtitle_test.cc index deb18339..fee2d841 100644 --- a/test/write_subtitle_test.cc +++ b/test/write_subtitle_test.cc @@ -44,10 +44,10 @@ #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>() ); } diff --git a/tools/common.cc b/tools/common.cc index ca3fd2c5..73d62679 100644 --- a/tools/common.cc +++ b/tools/common.cc @@ -34,22 +34,21 @@ #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; } diff --git a/tools/common.h b/tools/common.h index 0ef0b081..dc8d115c 100644 --- a/tools/common.h +++ b/tools/common.h @@ -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); } diff --git a/tools/dcpdiff.cc b/tools/dcpdiff.cc index 5f9911d4..7da55ccc 100644 --- a/tools/dcpdiff.cc +++ b/tools/dcpdiff.cc @@ -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 (¬es); 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 ())); } diff --git a/tools/dcpinfo.cc b/tools/dcpinfo.cc index 28b67a8d..18ed7886 100644 --- a/tools/dcpinfo.cc +++ b/tools/dcpinfo.cc @@ -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 (¬es); diff --git a/tools/dcprecover.cc b/tools/dcprecover.cc index 9105f2a7..49699f5e 100644 --- a/tools/dcprecover.cc +++ b/tools/dcprecover.cc @@ -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 (¬es, 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 { diff --git a/tools/dcpverify.cc b/tools/dcpverify.cc index b3c93bdd..eaecb0f1 100644 --- a/tools/dcpverify.cc +++ b/tools/dcpverify.cc @@ -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; |
