summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-01-11 00:16:40 +0100
committerCarl Hetherington <cth@carlh.net>2021-01-17 20:13:23 +0100
commitd95eacd3851a20e52202465ec22b4f72a4983dc8 (patch)
tree1dfc1092ae7d2e6b6b7c313ad808415f578d9712 /src
parentcbee0d077e698541afcea82a95bafcea5245ab89 (diff)
Replace std::list with std::vector in the API.
Diffstat (limited to 'src')
-rw-r--r--src/certificate_chain.cc9
-rw-r--r--src/certificate_chain.h2
-rw-r--r--src/combine.cc7
-rw-r--r--src/cpl.cc10
-rw-r--r--src/cpl.h13
-rw-r--r--src/dcp.cc16
-rw-r--r--src/dcp.h16
-rw-r--r--src/decrypted_kdm.cc4
-rw-r--r--src/decrypted_kdm.h4
-rw-r--r--src/encrypted_kdm.cc14
-rw-r--r--src/encrypted_kdm.h6
-rw-r--r--src/interop_subtitle_asset.cc25
-rw-r--r--src/interop_subtitle_asset.h8
-rw-r--r--src/pkl.h2
-rw-r--r--src/reel.cc8
-rw-r--r--src/reel.h11
-rw-r--r--src/ref.cc8
-rw-r--r--src/ref.h6
-rw-r--r--src/smpte_subtitle_asset.cc18
-rw-r--r--src/smpte_subtitle_asset.h4
-rw-r--r--src/subtitle_asset.cc30
-rw-r--r--src/subtitle_asset.h14
-rw-r--r--src/subtitle_asset_internal.h2
-rw-r--r--src/util.cc4
-rw-r--r--src/util.h2
-rw-r--r--src/verify.cc25
-rw-r--r--src/verify.h3
-rw-r--r--src/xml.h10
28 files changed, 140 insertions, 141 deletions
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);
diff --git a/src/cpl.cc b/src/cpl.cc
index 22abfb69..04bc9f5c 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -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);
diff --git a/src/cpl.h b/src/cpl.h
index 6805cc89..c2a8b07d 100644
--- 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;
diff --git a/src/dcp.cc b/src/dcp.cc
index 17d5c88d..ca7313a5 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -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()) {
diff --git a/src/dcp.h b/src/dcp.h
index 3eab743e..73f154c7 100644
--- 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;
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;
};
}
diff --git a/src/pkl.h b/src/pkl.h
index a27a9a33..0ea87219 100644
--- 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;
};
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);
diff --git a/src/reel.h b/src/reel.h
index 041e1ca1..083ecd0e 100644
--- a/src/reel.h
+++ b/src/reel.h
@@ -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;
};
diff --git a/src/ref.cc b/src/ref.cc
index 7512d32c..8527150d 100644
--- a/src/ref.cc
+++ b/src/ref.cc
@@ -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;
}
diff --git a/src/ref.h b/src/ref.h
index 9ebe19b8..94add1c8 100644
--- 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 {
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) {
diff --git a/src/util.h b/src/util.h
index 9cca8136..232b91cc 100644
--- a/src/util.h
+++ b/src/util.h
@@ -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,
diff --git a/src/xml.h b/src/xml.h
index e698eea0..154ec210 100644
--- 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);