summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-01-22 01:39:22 +0100
committerCarl Hetherington <cth@carlh.net>2021-01-22 01:39:22 +0100
commit5fbcd3a8dc711c6c42efabbac72ab0408f504ea2 (patch)
treedfc84a000b2e2c67b6c73c2b8809b5da3137ecc4
parentbebe2f996176113a527bf2492fd179420493d0ff (diff)
Assorted c++11 cleanups.
-rw-r--r--src/certificate_chain.cc13
-rw-r--r--src/combine.cc9
-rw-r--r--src/decrypted_kdm.cc7
-rw-r--r--src/interop_subtitle_asset.cc42
-rw-r--r--src/language_tag.cc19
-rw-r--r--src/mono_picture_asset.cc42
-rw-r--r--src/mono_picture_asset_writer.h4
-rw-r--r--src/name_format.cc1
-rw-r--r--src/pkl.cc1
-rw-r--r--src/reel.cc1
-rw-r--r--src/reel_markers_asset.cc7
-rw-r--r--src/smpte_subtitle_asset.cc40
-rw-r--r--src/sound_asset_writer.cc5
-rw-r--r--src/subtitle_asset.cc19
-rw-r--r--src/subtitle_asset_internal.cc2
-rw-r--r--src/subtitle_asset_internal.h1
-rw-r--r--src/types.cc3
-rw-r--r--src/util.cc5
-rw-r--r--test/combine_test.cc7
-rw-r--r--test/verify_test.cc1
-rw-r--r--tools/dcpdiff.cc4
-rw-r--r--tools/dcpdumpsub.cc2
-rw-r--r--tools/dcpinfo.cc9
-rw-r--r--tools/dcpkdm.cc4
-rw-r--r--tools/dcprecover.cc5
-rw-r--r--tools/dcpverify.cc2
26 files changed, 118 insertions, 137 deletions
diff --git a/src/certificate_chain.cc b/src/certificate_chain.cc
index 2287a805..9f4c5ea7 100644
--- a/src/certificate_chain.cc
+++ b/src/certificate_chain.cc
@@ -54,7 +54,6 @@
#include <openssl/rsa.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <fstream>
#include <iostream>
@@ -634,14 +633,14 @@ void
CertificateChain::add_signature_value (xmlpp::Element* parent, string ns, bool add_indentation) const
{
cxml::Node cp (parent);
- xmlpp::Node* key_info = cp.node_child("KeyInfo")->node ();
+ auto key_info = cp.node_child("KeyInfo")->node();
/* Add the certificate chain to the KeyInfo child node of parent */
- BOOST_FOREACH (Certificate const & i, leaf_to_root ()) {
- xmlpp::Element* data = key_info->add_child("X509Data", ns);
+ for (auto const& i: leaf_to_root()) {
+ auto data = key_info->add_child("X509Data", ns);
{
- xmlpp::Element* serial = data->add_child("X509IssuerSerial", ns);
+ auto serial = data->add_child("X509IssuerSerial", ns);
serial->add_child("X509IssuerName", ns)->add_child_text (i.issuer ());
serial->add_child("X509SerialNumber", ns)->add_child_text (i.serial ());
}
@@ -649,7 +648,7 @@ CertificateChain::add_signature_value (xmlpp::Element* parent, string ns, bool a
data->add_child("X509Certificate", ns)->add_child_text (i.certificate());
}
- xmlSecDSigCtxPtr signature_context = xmlSecDSigCtxCreate (0);
+ auto signature_context = xmlSecDSigCtxCreate (0);
if (signature_context == 0) {
throw MiscError ("could not create signature context");
}
@@ -677,7 +676,7 @@ string
CertificateChain::chain () const
{
string o;
- BOOST_FOREACH (Certificate const &i, root_to_leaf ()) {
+ for (auto const& i: root_to_leaf()) {
o += i.certificate(true);
}
diff --git a/src/combine.cc b/src/combine.cc
index cd91d5b1..c2cae547 100644
--- a/src/combine.cc
+++ b/src/combine.cc
@@ -42,7 +42,6 @@
#include "interop_subtitle_asset.h"
#include "raw_convert.h"
#include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
#include <set>
#include <string>
#include <vector>
@@ -110,7 +109,7 @@ dcp::combine (
DCP output_dcp (output);
optional<dcp::Standard> standard;
- BOOST_FOREACH (path i, inputs) {
+ for (auto i: inputs) {
DCP dcp (i);
dcp.read ();
if (!standard) {
@@ -123,15 +122,15 @@ dcp::combine (
vector<path> paths;
vector<shared_ptr<dcp::Asset>> assets;
- BOOST_FOREACH (path i, inputs) {
+ for (auto i: inputs) {
DCP dcp (i);
dcp.read ();
- BOOST_FOREACH (shared_ptr<dcp::CPL> j, dcp.cpls()) {
+ for (auto j: dcp.cpls()) {
output_dcp.add (j);
}
- BOOST_FOREACH (shared_ptr<dcp::Asset> j, dcp.assets(true)) {
+ for (auto j: dcp.assets(true)) {
if (dynamic_pointer_cast<dcp::CPL>(j)) {
continue;
}
diff --git a/src/decrypted_kdm.cc b/src/decrypted_kdm.cc
index 10da80e6..0a3eeabd 100644
--- a/src/decrypted_kdm.cc
+++ b/src/decrypted_kdm.cc
@@ -47,7 +47,6 @@
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/err.h>
-#include <boost/foreach.hpp>
using std::list;
using std::vector;
@@ -143,7 +142,7 @@ DecryptedKDM::DecryptedKDM (EncryptedKDM const & kdm, string private_key)
/* Use the private key to decrypt the keys */
- BOOST_FOREACH (string const & i, kdm.keys ()) {
+ for (auto const& i: kdm.keys()) {
/* Decode the base-64-encoded cipher value from the KDM */
unsigned char cipher_value[256];
int const cipher_value_len = base64_decode (i, cipher_value, sizeof (cipher_value));
@@ -312,7 +311,7 @@ DecryptedKDM::encrypt (
{
DCP_ASSERT (!_keys.empty ());
- BOOST_FOREACH (dcp::Certificate i, signer->leaf_to_root()) {
+ for (auto i: signer->leaf_to_root()) {
if (day_greater_than_or_equal(dcp::LocalTime(i.not_before()), _not_valid_before)) {
throw BadKDMDateError (true);
} else if (day_less_than_or_equal(dcp::LocalTime(i.not_after()), _not_valid_after)) {
@@ -322,7 +321,7 @@ DecryptedKDM::encrypt (
vector<pair<string, string>> key_ids;
vector<string> keys;
- BOOST_FOREACH (DecryptedKDMKey const & i, _keys) {
+ for (auto const& i: _keys) {
/* We're making SMPTE keys so we must have a type for each one */
DCP_ASSERT (i.type());
key_ids.push_back (make_pair (i.type().get(), i.id ()));
diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc
index f93e7cf4..9c977b44 100644
--- a/src/interop_subtitle_asset.cc
+++ b/src/interop_subtitle_asset.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -42,7 +42,6 @@
#include "compose.hpp"
#include "subtitle_image.h"
#include <libxml++/libxml++.h>
-#include <boost/foreach.hpp>
#include <boost/weak_ptr.hpp>
#include <cmath>
#include <cstdio>
@@ -55,6 +54,7 @@ using std::map;
using std::shared_ptr;
using std::dynamic_pointer_cast;
using std::vector;
+using std::make_shared;
using boost::shared_array;
using boost::optional;
using namespace dcp;
@@ -83,8 +83,8 @@ InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file)
}
}
- BOOST_FOREACH (shared_ptr<Subtitle> i, _subtitles) {
- shared_ptr<SubtitleImage> si = dynamic_pointer_cast<SubtitleImage>(i);
+ for (auto i: _subtitles) {
+ auto si = dynamic_pointer_cast<SubtitleImage>(i);
if (si) {
si->read_png_file (file.parent_path() / String::compose("%1.png", si->id()));
}
@@ -192,16 +192,16 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const
_file = p;
/* Image subtitles */
- BOOST_FOREACH (shared_ptr<dcp::Subtitle> i, _subtitles) {
- shared_ptr<dcp::SubtitleImage> im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
+ for (auto i: _subtitles) {
+ auto im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
if (im) {
im->write_png_file(p.parent_path() / String::compose("%1.png", im->id()));
}
}
/* Fonts */
- BOOST_FOREACH (shared_ptr<InteropLoadFontNode> i, _load_font_nodes) {
- boost::filesystem::path file = p.parent_path() / i->uri;
+ for (auto i: _load_font_nodes) {
+ auto file = p.parent_path() / i->uri;
auto j = _fonts.begin();
while (j != _fonts.end() && j->load_id != i->id) {
++j;
@@ -220,15 +220,15 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const
void
InteropSubtitleAsset::resolve_fonts (vector<shared_ptr<Asset>> assets)
{
- BOOST_FOREACH (shared_ptr<Asset> i, assets) {
- shared_ptr<FontAsset> font = dynamic_pointer_cast<FontAsset> (i);
+ for (auto i: assets) {
+ auto font = dynamic_pointer_cast<FontAsset> (i);
if (!font) {
continue;
}
- BOOST_FOREACH (shared_ptr<InteropLoadFontNode> j, _load_font_nodes) {
+ for (auto j: _load_font_nodes) {
bool got = false;
- BOOST_FOREACH (Font const & k, _fonts) {
+ for (auto const& k: _fonts) {
if (k.load_id == j->id) {
got = true;
break;
@@ -245,9 +245,9 @@ InteropSubtitleAsset::resolve_fonts (vector<shared_ptr<Asset>> assets)
void
InteropSubtitleAsset::add_font_assets (vector<shared_ptr<Asset>>& assets)
{
- BOOST_FOREACH (Font const & i, _fonts) {
+ for (auto const& i: _fonts) {
DCP_ASSERT (i.file);
- assets.push_back (shared_ptr<FontAsset> (new FontAsset (i.uuid, i.file.get ())));
+ assets.push_back (make_shared<FontAsset>(i.uuid, i.file.get()));
}
}
@@ -256,8 +256,8 @@ InteropSubtitleAsset::write_to_assetmap (xmlpp::Node* node, boost::filesystem::p
{
Asset::write_to_assetmap (node, root);
- BOOST_FOREACH (shared_ptr<dcp::Subtitle> i, _subtitles) {
- shared_ptr<dcp::SubtitleImage> im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
+ for (auto i: _subtitles) {
+ auto im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
if (im) {
DCP_ASSERT (im->file());
write_file_to_assetmap (node, root, im->file().get(), im->id());
@@ -270,10 +270,10 @@ InteropSubtitleAsset::add_to_pkl (shared_ptr<PKL> pkl, boost::filesystem::path r
{
Asset::add_to_pkl (pkl, root);
- BOOST_FOREACH (shared_ptr<dcp::Subtitle> i, _subtitles) {
- shared_ptr<dcp::SubtitleImage> im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
+ for (auto i: _subtitles) {
+ auto im = dynamic_pointer_cast<dcp::SubtitleImage> (i);
if (im) {
- ArrayData png_image = im->png_image ();
+ auto png_image = im->png_image ();
pkl->add_asset (im->id(), optional<string>(), make_digest(png_image), png_image.size(), "image/png");
}
}
@@ -283,13 +283,13 @@ InteropSubtitleAsset::add_to_pkl (shared_ptr<PKL> pkl, boost::filesystem::path r
void
InteropSubtitleAsset::set_font_file (string load_id, boost::filesystem::path file)
{
- BOOST_FOREACH (Font& i, _fonts) {
+ for (auto& i: _fonts) {
if (i.load_id == load_id) {
i.file = file;
}
}
- BOOST_FOREACH (shared_ptr<InteropLoadFontNode> i, _load_font_nodes) {
+ for (auto i: _load_font_nodes) {
if (i->id == load_id) {
i->uri = file.filename().string();
}
diff --git a/src/language_tag.cc b/src/language_tag.cc
index 148e054b..07e95564 100644
--- a/src/language_tag.cc
+++ b/src/language_tag.cc
@@ -37,7 +37,6 @@
#include "exceptions.h"
#include "language_tag.h"
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <string>
@@ -62,7 +61,7 @@ static
optional<LanguageTag::SubtagData>
find_in_list (vector<LanguageTag::SubtagData> const& list, string subtag)
{
- BOOST_FOREACH (LanguageTag::SubtagData const& i, list) {
+ for (auto const& i: list) {
if (boost::iequals(i.subtag, subtag)) {
return i;
}
@@ -158,11 +157,11 @@ LanguageTag::to_string () const
s += "-" + _region->subtag();
}
- BOOST_FOREACH (VariantSubtag i, _variants) {
+ for (auto i: _variants) {
s += "-" + i.subtag();
}
- BOOST_FOREACH (ExtlangSubtag i, _extlangs) {
+ for (auto i: _extlangs) {
s += "-" + i.subtag();
}
@@ -254,13 +253,13 @@ LanguageTag::description () const
string d;
- BOOST_FOREACH (VariantSubtag const& i, _variants) {
+ for (auto const& i: _variants) {
optional<SubtagData> variant = get_subtag_data (SubtagType::VARIANT, i.subtag());
DCP_ASSERT (variant);
d += variant->description + " dialect of ";
}
- optional<SubtagData> language = get_subtag_data (SubtagType::LANGUAGE, _language->subtag());
+ auto language = get_subtag_data (SubtagType::LANGUAGE, _language->subtag());
DCP_ASSERT (language);
d += language->description;
@@ -276,7 +275,7 @@ LanguageTag::description () const
d += " for " + region->description;
}
- BOOST_FOREACH (ExtlangSubtag const& i, _extlangs) {
+ for (auto const& i: _extlangs) {
optional<SubtagData> extlang = get_subtag_data (SubtagType::EXTLANG, i.subtag());
DCP_ASSERT (extlang);
d += ", " + extlang->description;
@@ -371,7 +370,7 @@ dcp::operator<< (ostream& os, dcp::LanguageTag const& tag)
vector<pair<LanguageTag::SubtagType, LanguageTag::SubtagData> >
LanguageTag::subtags () const
{
- vector<pair<SubtagType, SubtagData> > s;
+ vector<pair<SubtagType, SubtagData>> s;
if (_language) {
s.push_back (make_pair(SubtagType::LANGUAGE, *get_subtag_data(SubtagType::LANGUAGE, _language->subtag())));
@@ -385,11 +384,11 @@ LanguageTag::subtags () const
s.push_back (make_pair(SubtagType::REGION, *get_subtag_data(SubtagType::REGION, _region->subtag())));
}
- BOOST_FOREACH (VariantSubtag const& i, _variants) {
+ for (auto const& i: _variants) {
s.push_back (make_pair(SubtagType::VARIANT, *get_subtag_data(SubtagType::VARIANT, i.subtag())));
}
- BOOST_FOREACH (ExtlangSubtag const& i, _extlangs) {
+ for (auto const& i: _extlangs) {
s.push_back (make_pair(SubtagType::EXTLANG, *get_subtag_data(SubtagType::EXTLANG, i.subtag())));
}
diff --git a/src/mono_picture_asset.cc b/src/mono_picture_asset.cc
index 4524c85d..89661061 100644
--- a/src/mono_picture_asset.cc
+++ b/src/mono_picture_asset.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -47,6 +47,7 @@ using std::list;
using std::pair;
using std::shared_ptr;
using std::dynamic_pointer_cast;
+using std::make_shared;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
@@ -56,21 +57,21 @@ MonoPictureAsset::MonoPictureAsset (boost::filesystem::path file)
: PictureAsset (file)
{
ASDCP::JP2K::MXFReader reader;
- Kumu::Result_t r = reader.OpenRead (file.string().c_str());
- if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", file.string(), r));
+ auto r = reader.OpenRead (file.string().c_str());
+ if (ASDCP_FAILURE(r)) {
+ boost::throw_exception (MXFFileError("could not open MXF file for reading", file.string(), r));
}
ASDCP::JP2K::PictureDescriptor desc;
- if (ASDCP_FAILURE (reader.FillPictureDescriptor (desc))) {
- boost::throw_exception (ReadError ("could not read video MXF information"));
+ if (ASDCP_FAILURE (reader.FillPictureDescriptor(desc))) {
+ boost::throw_exception (ReadError("could not read video MXF information"));
}
read_picture_descriptor (desc);
ASDCP::WriterInfo info;
if (ASDCP_FAILURE (reader.FillWriterInfo (info))) {
- boost::throw_exception (ReadError ("could not read video MXF information"));
+ boost::throw_exception (ReadError("could not read video MXF information"));
}
_id = read_writer_info (info);
@@ -91,15 +92,15 @@ storing_note_handler (list<pair<NoteType, string> >& notes, NoteType t, string s
bool
MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler note) const
{
- if (!dynamic_pointer_cast<const MonoPictureAsset> (other)) {
+ if (!dynamic_pointer_cast<const MonoPictureAsset>(other)) {
return false;
}
ASDCP::JP2K::MXFReader reader_A;
DCP_ASSERT (_file);
- Kumu::Result_t r = reader_A.OpenRead (_file->string().c_str());
- if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", _file->string(), r));
+ auto r = reader_A.OpenRead (_file->string().c_str());
+ if (ASDCP_FAILURE(r)) {
+ boost::throw_exception (MXFFileError("could not open MXF file for reading", _file->string(), r));
}
ASDCP::JP2K::MXFReader reader_B;
@@ -122,13 +123,13 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, No
return false;
}
- shared_ptr<const MonoPictureAsset> other_picture = dynamic_pointer_cast<const MonoPictureAsset> (other);
+ auto other_picture = dynamic_pointer_cast<const MonoPictureAsset> (other);
DCP_ASSERT (other_picture);
bool result = true;
- shared_ptr<MonoPictureAssetReader> reader = start_read ();
- shared_ptr<MonoPictureAssetReader> other_reader = other_picture->start_read ();
+ auto reader = start_read ();
+ auto other_reader = other_picture->start_read ();
#ifdef LIBDCP_OPENMP
#pragma omp parallel for
@@ -141,8 +142,8 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, No
if (result || opt.keep_going) {
- shared_ptr<const MonoPictureFrame> frame_A = reader->get_frame (i);
- shared_ptr<const MonoPictureFrame> frame_B = other_reader->get_frame (i);
+ auto frame_A = reader->get_frame (i);
+ auto frame_B = other_reader->get_frame (i);
list<pair<NoteType, string> > notes;
@@ -159,8 +160,8 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, No
#endif
{
note (NoteType::PROGRESS, String::compose("Compared video frame %1 of %2", i, _intrinsic_duration));
- for (list<pair<NoteType, string> >::const_iterator i = notes.begin(); i != notes.end(); ++i) {
- note (i->first, i->second);
+ for (auto const& i: notes) {
+ note (i.first, i.second);
}
}
}
@@ -172,14 +173,13 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, No
shared_ptr<PictureAssetWriter>
MonoPictureAsset::start_write (boost::filesystem::path file, bool overwrite)
{
- /* XXX: can't we use shared_ptr here? */
- return shared_ptr<MonoPictureAssetWriter> (new MonoPictureAssetWriter (this, file, overwrite));
+ return make_shared<MonoPictureAssetWriter>(this, file, overwrite);
}
shared_ptr<MonoPictureAssetReader>
MonoPictureAsset::start_read () const
{
- return shared_ptr<MonoPictureAssetReader> (new MonoPictureAssetReader (this, key(), standard()));
+ return make_shared<MonoPictureAssetReader>(this, key(), standard());
}
string
diff --git a/src/mono_picture_asset_writer.h b/src/mono_picture_asset_writer.h
index 2dce922e..a5799d27 100644
--- a/src/mono_picture_asset_writer.h
+++ b/src/mono_picture_asset_writer.h
@@ -59,6 +59,8 @@ namespace dcp {
class MonoPictureAssetWriter : public PictureAssetWriter
{
public:
+ MonoPictureAssetWriter (PictureAsset *, boost::filesystem::path file, bool);
+
FrameInfo write (uint8_t const *, int);
void fake_write (int size);
bool finalize ();
@@ -66,13 +68,11 @@ public:
private:
friend class MonoPictureAsset;
- MonoPictureAssetWriter (PictureAsset *, boost::filesystem::path file, bool);
void start (uint8_t const *, int);
/* do this with an opaque pointer so we don't have to include
ASDCP headers
*/
-
struct ASDCPState;
std::shared_ptr<ASDCPState> _state;
};
diff --git a/src/name_format.cc b/src/name_format.cc
index 76cca3fd..11b68e19 100644
--- a/src/name_format.cc
+++ b/src/name_format.cc
@@ -33,7 +33,6 @@
#include "name_format.h"
#include <boost/optional.hpp>
-#include <boost/foreach.hpp>
using std::string;
using std::map;
diff --git a/src/pkl.cc b/src/pkl.cc
index b439e8bd..0f62b4a2 100644
--- a/src/pkl.cc
+++ b/src/pkl.cc
@@ -37,7 +37,6 @@
#include "raw_convert.h"
#include "dcp_assert.h"
#include <libxml++/libxml++.h>
-#include <boost/foreach.hpp>
#include <iostream>
using std::string;
diff --git a/src/reel.cc b/src/reel.cc
index efb161bb..25019d35 100644
--- a/src/reel.cc
+++ b/src/reel.cc
@@ -50,7 +50,6 @@
#include "reel_atmos_asset.h"
#include "reel_closed_caption_asset.h"
#include <libxml++/nodes/element.h>
-#include <boost/foreach.hpp>
#include <stdint.h>
/* Centos 6 does not have this */
diff --git a/src/reel_markers_asset.cc b/src/reel_markers_asset.cc
index ba0021cf..1f9282fa 100644
--- a/src/reel_markers_asset.cc
+++ b/src/reel_markers_asset.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2019-2021 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -35,7 +35,6 @@
#include "raw_convert.h"
#include "dcp_assert.h"
#include <libxml++/libxml++.h>
-#include <boost/foreach.hpp>
using std::string;
using std::map;
@@ -53,9 +52,9 @@ ReelMarkersAsset::ReelMarkersAsset (Fraction edit_rate, int64_t intrinsic_durati
ReelMarkersAsset::ReelMarkersAsset (cxml::ConstNodePtr node)
: ReelAsset (node)
{
- cxml::ConstNodePtr list = node->node_child ("MarkerList");
+ auto list = node->node_child ("MarkerList");
DCP_ASSERT (list);
- BOOST_FOREACH (cxml::ConstNodePtr i, list->node_children("Marker")) {
+ for (auto i: list->node_children("Marker")) {
set (marker_from_string(i->string_child("Label")), dcp::Time(i->number_child<int64_t>("Offset"), edit_rate().as_float(), edit_rate().numerator));
}
}
diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc
index 49ccc5a9..2c53cbb3 100644
--- a/src/smpte_subtitle_asset.cc
+++ b/src/smpte_subtitle_asset.cc
@@ -49,7 +49,6 @@
#include <asdcp/KM_util.h>
#include <asdcp/KM_log.h>
#include <libxml++/libxml++.h>
-#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp>
using std::string;
@@ -126,11 +125,11 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file)
/* Try to read PNG files from the same folder that the XML is in; the wisdom of this is
debatable, at best...
*/
- BOOST_FOREACH (shared_ptr<Subtitle> i, _subtitles) {
- shared_ptr<SubtitleImage> im = dynamic_pointer_cast<SubtitleImage>(i);
+ for (auto i: _subtitles) {
+ auto im = dynamic_pointer_cast<SubtitleImage>(i);
if (im && im->png_image().size() == 0) {
/* Even more dubious; allow <id>.png or urn:uuid:<id>.png */
- boost::filesystem::path p = file.parent_path() / String::compose("%1.png", im->id());
+ auto p = file.parent_path() / String::compose("%1.png", im->id());
if (boost::filesystem::is_regular_file(p)) {
im->read_png_file (p);
} else if (starts_with (im->id(), "urn:uuid:")) {
@@ -145,8 +144,8 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file)
}
/* Check that all required image data have been found */
- BOOST_FOREACH (shared_ptr<Subtitle> i, _subtitles) {
- shared_ptr<SubtitleImage> im = dynamic_pointer_cast<SubtitleImage>(i);
+ for (auto i: _subtitles) {
+ auto im = dynamic_pointer_cast<SubtitleImage>(i);
if (im && im->png_image().size() == 0) {
throw MissingSubtitleImageError (im->id());
}
@@ -166,7 +165,7 @@ SMPTESubtitleAsset::parse_xml (shared_ptr<cxml::Document> xml)
_language = xml->optional_string_child ("Language");
/* This is supposed to be two numbers, but a single number has been seen in the wild */
- string const er = xml->string_child ("EditRate");
+ auto const er = xml->string_child ("EditRate");
vector<string> er_parts;
split (er_parts, er, is_any_of (" "));
if (er_parts.size() == 1) {
@@ -185,9 +184,8 @@ SMPTESubtitleAsset::parse_xml (shared_ptr<cxml::Document> xml)
/* Now we need to drop down to xmlpp */
vector<ParseState> ps;
- xmlpp::Node::NodeList c = xml->node()->get_children ();
- for (xmlpp::Node::NodeList::const_iterator i = c.begin(); i != c.end(); ++i) {
- xmlpp::Element const * e = dynamic_cast<xmlpp::Element const *> (*i);
+ for (auto i: xml->node()->get_children()) {
+ auto const e = dynamic_cast<xmlpp::Element const *>(i);
if (e && e->get_name() == "SubtitleList") {
parse_subtitles (e, ps, _time_code_rate, Standard::SMPTE);
}
@@ -206,7 +204,7 @@ SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader>
/* Load fonts and images */
for (
- ASDCP::TimedText::ResourceList_t::const_iterator i = descriptor.ResourceList.begin();
+ auto i = descriptor.ResourceList.begin();
i != descriptor.ResourceList.end();
++i) {
@@ -274,8 +272,8 @@ SMPTESubtitleAsset::set_key (Key key)
/* Our data was encrypted; now we can decrypt it */
- shared_ptr<ASDCP::TimedText::MXFReader> reader (new ASDCP::TimedText::MXFReader ());
- Kumu::Result_t r = reader->OpenRead (_file->string().c_str ());
+ auto reader = make_shared<ASDCP::TimedText::MXFReader>();
+ auto r = reader->OpenRead (_file->string().c_str ());
if (ASDCP_FAILURE (r)) {
boost::throw_exception (
ReadError (
@@ -336,8 +334,8 @@ SMPTESubtitleAsset::xml_as_string () const
root->add_child("StartTime", "dcst")->add_child_text(_start_time.get().as_string(Standard::SMPTE));
}
- BOOST_FOREACH (shared_ptr<SMPTELoadFontNode> i, _load_font_nodes) {
- xmlpp::Element* load_font = root->add_child("LoadFont", "dcst");
+ for (auto i: _load_font_nodes) {
+ auto load_font = root->add_child("LoadFont", "dcst");
load_font->add_child_text ("urn:uuid:" + i->urn);
load_font->set_attribute ("ID", i->id);
}
@@ -362,7 +360,7 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const
/* Font references */
- BOOST_FOREACH (shared_ptr<dcp::SMPTELoadFontNode> i, _load_font_nodes) {
+ for (auto i: _load_font_nodes) {
auto j = _fonts.begin();
while (j != _fonts.end() && j->load_id != i->id) {
++j;
@@ -379,8 +377,8 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const
/* Image subtitle references */
- BOOST_FOREACH (shared_ptr<Subtitle> i, _subtitles) {
- shared_ptr<SubtitleImage> si = dynamic_pointer_cast<SubtitleImage>(i);
+ for (auto i: _subtitles) {
+ auto si = dynamic_pointer_cast<SubtitleImage>(i);
if (si) {
ASDCP::TimedText::TimedTextResourceDescriptor res;
unsigned int c;
@@ -413,7 +411,7 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const
/* Font payload */
- BOOST_FOREACH (shared_ptr<dcp::SMPTELoadFontNode> i, _load_font_nodes) {
+ for (auto i: _load_font_nodes) {
auto j = _fonts.begin();
while (j != _fonts.end() && j->load_id != i->id) {
++j;
@@ -432,8 +430,8 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const
/* Image subtitle payload */
- BOOST_FOREACH (shared_ptr<Subtitle> i, _subtitles) {
- shared_ptr<SubtitleImage> si = dynamic_pointer_cast<SubtitleImage>(i);
+ for (auto i: _subtitles) {
+ auto si = dynamic_pointer_cast<SubtitleImage>(i);
if (si) {
ASDCP::TimedText::FrameBuffer buffer;
buffer.SetData (si->png_image().data(), si->png_image().size());
diff --git a/src/sound_asset_writer.cc b/src/sound_asset_writer.cc
index 87de1b18..5c5bcdec 100644
--- a/src/sound_asset_writer.cc
+++ b/src/sound_asset_writer.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -40,7 +40,6 @@
#include "crypto_context.h"
#include <asdcp/AS_DCP.h>
#include <asdcp/Metadata.h>
-#include <boost/foreach.hpp>
#include <iostream>
using std::min;
@@ -142,7 +141,7 @@ SoundAssetWriter::start ()
_state->mxf_writer.OP1aHeader().AddChildObject(soundfield);
essence_descriptor->SubDescriptors.push_back(soundfield->InstanceUID);
- BOOST_FOREACH (Channel i, _active_channels) {
+ for (auto i: _active_channels) {
ASDCP::MXF::AudioChannelLabelSubDescriptor* channel = new ASDCP::MXF::AudioChannelLabelSubDescriptor(asdcp_smpte_dict);
GenRandomValue (channel->MCALinkID);
channel->SoundfieldGroupLinkID = soundfield->MCALinkID;
diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc
index 9d46cb5c..52ef7ac2 100644
--- a/src/subtitle_asset.cc
+++ b/src/subtitle_asset.cc
@@ -48,7 +48,6 @@
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/shared_array.hpp>
-#include <boost/foreach.hpp>
using std::dynamic_pointer_cast;
using std::string;
@@ -292,7 +291,7 @@ SubtitleAsset::maybe_add_subtitle (string text, vector<ParseState> const & parse
}
ParseState ps;
- BOOST_FOREACH (ParseState const & i, parse_state) {
+ for (auto const& i: parse_state) {
if (i.font_id) {
ps.font_id = i.font_id.get();
}
@@ -548,12 +547,12 @@ SubtitleAsset::pull_fonts (shared_ptr<order::Part> part)
these features go into part's font.
*/
part->font = part->children.front()->font;
- BOOST_FOREACH (shared_ptr<order::Part> i, part->children) {
+ for (auto i: part->children) {
part->font.take_intersection (i->font);
}
/* Remove common values from part's children's fonts */
- BOOST_FOREACH (shared_ptr<order::Part> i, part->children) {
+ for (auto i: part->children) {
i->font.take_difference (part->font);
}
}
@@ -685,7 +684,7 @@ map<string, ArrayData>
SubtitleAsset::font_data () const
{
map<string, ArrayData> out;
- BOOST_FOREACH (Font const & i, _fonts) {
+ for (auto const& i: _fonts) {
out[i.load_id] = i.data;
}
return out;
@@ -696,7 +695,7 @@ map<string, boost::filesystem::path>
SubtitleAsset::font_filenames () const
{
map<string, boost::filesystem::path> out;
- BOOST_FOREACH (Font const& i, _fonts) {
+ for (auto const& i: _fonts) {
if (i.file) {
out[i.load_id] = *i.file;
}
@@ -714,7 +713,7 @@ SubtitleAsset::fix_empty_font_ids ()
{
bool have_empty = false;
vector<string> ids;
- BOOST_FOREACH (shared_ptr<LoadFontNode> i, load_font_nodes()) {
+ for (auto i: load_font_nodes()) {
if (i->id == "") {
have_empty = true;
} else {
@@ -728,14 +727,14 @@ SubtitleAsset::fix_empty_font_ids ()
string const empty_id = unique_string (ids, "font");
- BOOST_FOREACH (shared_ptr<LoadFontNode> i, load_font_nodes()) {
+ for (auto i: load_font_nodes()) {
if (i->id == "") {
i->id = empty_id;
}
}
- BOOST_FOREACH (shared_ptr<Subtitle> i, _subtitles) {
- shared_ptr<SubtitleString> j = dynamic_pointer_cast<SubtitleString> (i);
+ for (auto i: _subtitles) {
+ auto j = dynamic_pointer_cast<SubtitleString> (i);
if (j && j->font() && j->font().get() == "") {
j->set_font (empty_id);
}
diff --git a/src/subtitle_asset_internal.cc b/src/subtitle_asset_internal.cc
index 25a41944..d7b16cbd 100644
--- a/src/subtitle_asset_internal.cc
+++ b/src/subtitle_asset_internal.cc
@@ -141,7 +141,7 @@ order::Part::write_xml (xmlpp::Element* parent, order::Context& context) const
parent = as_xml (parent, context);
- BOOST_FOREACH (std::shared_ptr<order::Part> i, children) {
+ for (auto i: children) {
i->write_xml (parent, context);
}
}
diff --git a/src/subtitle_asset_internal.h b/src/subtitle_asset_internal.h
index 8a9ffe18..0af16238 100644
--- a/src/subtitle_asset_internal.h
+++ b/src/subtitle_asset_internal.h
@@ -40,7 +40,6 @@
#include "types.h"
#include "dcp_time.h"
#include <libxml++/libxml++.h>
-#include <boost/foreach.hpp>
struct take_intersection_test;
struct take_difference_test;
diff --git a/src/types.cc b/src/types.cc
index 6058ea10..099512c6 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -38,7 +38,6 @@
#include "dcp_assert.h"
#include <libxml++/libxml++.h>
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <string>
#include <vector>
#include <cmath>
@@ -570,7 +569,7 @@ MainSoundConfiguration::MainSoundConfiguration (string s)
throw MainSoundConfigurationError (s);
}
- BOOST_FOREACH (string i, channels) {
+ for (auto i: channels) {
if (i == "-") {
_channels.push_back(optional<Channel>());
} else {
diff --git a/src/util.cc b/src/util.cc
index f775c507..2aaeddb5 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -56,7 +56,6 @@
#include <openssl/sha.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <stdexcept>
#include <iostream>
#include <iomanip>
@@ -389,8 +388,8 @@ void
dcp::indent (xmlpp::Element* element, int initial)
{
xmlpp::Node* last = 0;
- BOOST_FOREACH (xmlpp::Node * n, element->get_children()) {
- xmlpp::Element* e = dynamic_cast<xmlpp::Element*>(n);
+ for (auto n: element->get_children()) {
+ auto e = dynamic_cast<xmlpp::Element*>(n);
if (e) {
element->add_child_text_before (e, "\n" + spaces(initial + 2));
indent (e, initial + 2);
diff --git a/test/combine_test.cc b/test/combine_test.cc
index fc34109b..09a45770 100644
--- a/test/combine_test.cc
+++ b/test/combine_test.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.
@@ -44,7 +44,6 @@
#include "verify.h"
#include "reel_markers_asset.h"
#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
#include <boost/optional.hpp>
#include <boost/test/unit_test.hpp>
#include <iostream>
@@ -74,7 +73,7 @@ static
void
dump_notes (vector<dcp::VerificationNote> const & notes)
{
- BOOST_FOREACH (dcp::VerificationNote i, notes) {
+ for (auto i: notes) {
std::cout << dcp::note_to_string(i) << "\n";
}
}
@@ -100,7 +99,7 @@ template <class T>
shared_ptr<T>
pointer_to_id_in_vector (shared_ptr<T> needle, vector<shared_ptr<T> > haystack)
{
- BOOST_FOREACH (shared_ptr<T> i, haystack) {
+ for (auto i: haystack) {
if (i->id() == needle->id()) {
return i;
}
diff --git a/test/verify_test.cc b/test/verify_test.cc
index a9d5c0a7..a6f71b49 100644
--- a/test/verify_test.cc
+++ b/test/verify_test.cc
@@ -54,7 +54,6 @@
#include "raw_convert.h"
#include "stream_operators.h"
#include <boost/test/unit_test.hpp>
-#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp>
#include <cstdio>
#include <iostream>
diff --git a/tools/dcpdiff.cc b/tools/dcpdiff.cc
index a9d78712..336d09a5 100644
--- a/tools/dcpdiff.cc
+++ b/tools/dcpdiff.cc
@@ -99,14 +99,14 @@ load_dcp (boost::filesystem::path path, bool ignore_missing_assets, optional<str
vector<dcp::VerificationNote> notes;
dcp->read (&notes);
filter_notes (notes, ignore_missing_assets);
- BOOST_FOREACH (dcp::VerificationNote i, notes) {
+ for (auto i: notes) {
cerr << dcp::note_to_string(i) << "\n";
}
if (key) {
auto assets = dcp->assets ();
for (auto i: assets) {
- shared_ptr<MXF> mxf = dynamic_pointer_cast<MXF>(i);
+ auto mxf = dynamic_pointer_cast<MXF>(i);
if (mxf) {
mxf->set_key (Key (key.get ()));
}
diff --git a/tools/dcpdumpsub.cc b/tools/dcpdumpsub.cc
index 5d6668af..8117f0c6 100644
--- a/tools/dcpdumpsub.cc
+++ b/tools/dcpdumpsub.cc
@@ -115,7 +115,7 @@ main (int argc, char* argv[])
dcp::EncryptedKDM encrypted_kdm (dcp::file_to_string (kdm_file.get ()));
dcp::DecryptedKDM decrypted_kdm (encrypted_kdm, dcp::file_to_string (private_key_file.get()));
bool done = false;
- BOOST_FOREACH (dcp::DecryptedKDMKey const & i, decrypted_kdm.keys()) {
+ for (auto const& i: decrypted_kdm.keys()) {
if (i.id() == *sub.key_id()) {
sub.set_key (i.key ());
done = true;
diff --git a/tools/dcpinfo.cc b/tools/dcpinfo.cc
index 18272dcf..c8519858 100644
--- a/tools/dcpinfo.cc
+++ b/tools/dcpinfo.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -52,7 +52,6 @@
#include "compose.hpp"
#include <getopt.h>
#include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp>
#include <iostream>
#include <cstdlib>
@@ -384,7 +383,7 @@ main (int argc, char* argv[])
OUTPUT_DCP_PATH("DCP: %1\n", boost::filesystem::path(argv[optind]).string());
dcp::filter_notes (notes, ignore_missing_assets);
- BOOST_FOREACH (dcp::VerificationNote i, notes) {
+ for (auto i: notes) {
cerr << "Error: " << note_to_string(i) << "\n";
}
@@ -396,11 +395,11 @@ main (int argc, char* argv[])
dcp::Time total_time;
- BOOST_FOREACH (shared_ptr<CPL> i, cpls) {
+ for (auto i: cpls) {
OUTPUT_CPL_NAME_ID(" CPL: %1 %2\n", i->annotation_text().get_value_or(""), i->id());
int R = 1;
- BOOST_FOREACH (shared_ptr<Reel> j, i->reels()) {
+ for (auto j: i->reels()) {
if (should_output(only, "picture") || should_output(only, "sound") || should_output(only, "subtitle")) {
cout << " Reel " << R << "\n";
}
diff --git a/tools/dcpkdm.cc b/tools/dcpkdm.cc
index 60fcf902..d1421ed1 100644
--- a/tools/dcpkdm.cc
+++ b/tools/dcpkdm.cc
@@ -112,7 +112,7 @@ try
cout << "Signer chain:\n";
dcp::CertificateChain signer = enc_kdm.signer_certificate_chain ();
- BOOST_FOREACH (dcp::Certificate const & i, signer.root_to_leaf()) {
+ for (auto const& i: signer.root_to_leaf()) {
cout << "\tCertificate:\n";
cout << "\t\tSubject: " << i.subject() << "\n";
cout << "\t\tSubject common name: " << i.subject_common_name() << "\n";
@@ -129,7 +129,7 @@ try
try {
dcp::DecryptedKDM dec_kdm (enc_kdm, dcp::file_to_string (private_key_file.get()));
cout << "\nKeys:";
- BOOST_FOREACH (dcp::DecryptedKDMKey i, dec_kdm.keys ()) {
+ for (auto i: dec_kdm.keys()) {
cout << "\n";
cout << "\tID: " << i.id() << "\n";
cout << "\tStandard: " << (i.standard() == dcp::Standard::SMPTE ? "SMPTE" : "Interop") << "\n";
diff --git a/tools/dcprecover.cc b/tools/dcprecover.cc
index b5790992..f9e08087 100644
--- a/tools/dcprecover.cc
+++ b/tools/dcprecover.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -39,7 +39,6 @@
#include <getopt.h>
#include <libxml++/libxml++.h>
#include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
#include <iostream>
using std::cerr;
@@ -109,7 +108,7 @@ main (int argc, char* argv[])
cout << "Error:" << e.what() << "\n";
}
- BOOST_FOREACH (dcp::VerificationNote i, notes) {
+ for (auto i: notes) {
cout << "Error: " << dcp::note_to_string(i) << "\n";
}
diff --git a/tools/dcpverify.cc b/tools/dcpverify.cc
index b3ac5f06..2ba4f5c8 100644
--- a/tools/dcpverify.cc
+++ b/tools/dcpverify.cc
@@ -142,7 +142,7 @@ main (int argc, char* argv[])
dcp::filter_notes (notes, ignore_missing_assets);
bool failed = false;
- BOOST_FOREACH (dcp::VerificationNote i, notes) {
+ for (auto i: notes) {
if (ignore_bv21_smpte && i.code() == dcp::VerificationNote::Code::INVALID_STANDARD) {
continue;
}