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 /tools | |
| parent | cbee0d077e698541afcea82a95bafcea5245ab89 (diff) | |
Replace std::list with std::vector in the API.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/common.cc | 23 | ||||
| -rw-r--r-- | tools/common.h | 2 | ||||
| -rw-r--r-- | tools/dcpdiff.cc | 9 | ||||
| -rw-r--r-- | tools/dcpinfo.cc | 6 | ||||
| -rw-r--r-- | tools/dcprecover.cc | 6 | ||||
| -rw-r--r-- | tools/dcpverify.cc | 2 |
6 files changed, 24 insertions, 24 deletions
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; |
