c++ tidying.
authorCarl Hetherington <cth@carlh.net>
Fri, 8 Jan 2021 20:56:40 +0000 (21:56 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 8 Jan 2021 20:56:56 +0000 (21:56 +0100)
src/lib/audio_mapping.cc
src/lib/cinema.cc
src/lib/colour_conversion.cc
src/lib/config.cc
src/lib/content.cc
src/lib/ffmpeg_content.cc
src/lib/text_content.cc
src/lib/text_content.h

index da9f9822ec6644f8a9ae8b034cd6653d90701dee..0f330dc2b8ba3acef6c44febec62e199a6b85970 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
-    Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
     This file is part of DCP-o-matic.
 
@@ -155,24 +155,22 @@ AudioMapping::AudioMapping (cxml::ConstNodePtr node, int state_version)
 
        if (state_version <= 5) {
                /* Old-style: on/off mapping */
 
        if (state_version <= 5) {
                /* Old-style: on/off mapping */
-               list<cxml::NodePtr> const c = node->node_children ("Map");
-               for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
-                       set ((*i)->number_child<int> ("ContentIndex"), static_cast<dcp::Channel> ((*i)->number_child<int> ("DCP")), 1);
+               for (auto i: node->node_children ("Map")) {
+                       set (i->number_child<int>("ContentIndex"), static_cast<dcp::Channel>(i->number_child<int>("DCP")), 1);
                }
        } else {
                }
        } else {
-               list<cxml::NodePtr> const c = node->node_children ("Gain");
-               for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
+               for (auto i: node->node_children("Gain")) {
                        if (state_version < 32) {
                                set (
                        if (state_version < 32) {
                                set (
-                                       (*i)->number_attribute<int> ("Content"),
-                                       static_cast<dcp::Channel> ((*i)->number_attribute<int> ("DCP")),
-                                       raw_convert<float> ((*i)->content ())
+                                       i->number_attribute<int>("Content"),
+                                       static_cast<dcp::Channel>(i->number_attribute<int>("DCP")),
+                                       raw_convert<float>(i->content())
                                        );
                        } else {
                                set (
                                        );
                        } else {
                                set (
-                                       (*i)->number_attribute<int> ("Input"),
-                                       (*i)->number_attribute<int> ("Output"),
-                                       raw_convert<float> ((*i)->content ())
+                                       i->number_attribute<int>("Input"),
+                                       i->number_attribute<int>("Output"),
+                                       raw_convert<float>(i->content())
                                        );
                        }
                }
                                        );
                        }
                }
@@ -203,7 +201,7 @@ AudioMapping::as_xml (xmlpp::Node* node) const
 
        for (int c = 0; c < _input_channels; ++c) {
                for (int d = 0; d < _output_channels; ++d) {
 
        for (int c = 0; c < _input_channels; ++c) {
                for (int d = 0; d < _output_channels; ++d) {
-                       xmlpp::Element* t = node->add_child ("Gain");
+                       auto t = node->add_child ("Gain");
                        t->set_attribute ("Input", raw_convert<string> (c));
                        t->set_attribute ("Output", raw_convert<string> (d));
                        t->add_child_text (raw_convert<string> (get (c, d)));
                        t->set_attribute ("Input", raw_convert<string> (c));
                        t->set_attribute ("Output", raw_convert<string> (d));
                        t->add_child_text (raw_convert<string> (get (c, d)));
@@ -236,9 +234,9 @@ AudioMapping::mapped_output_channels () const
 
        list<int> mapped;
 
 
        list<int> mapped;
 
-       for (vector<vector<float> >::const_iterator i = _gain.begin(); i != _gain.end(); ++i) {
+       for (auto const& i: _gain) {
                for (auto j: dcp::used_audio_channels()) {
                for (auto j: dcp::used_audio_channels()) {
-                       if (abs ((*i)[j]) > minus_96_db) {
+                       if (abs(i[j]) > minus_96_db) {
                                mapped.push_back (j);
                        }
                }
                                mapped.push_back (j);
                        }
                }
@@ -253,9 +251,9 @@ AudioMapping::mapped_output_channels () const
 void
 AudioMapping::unmap_all ()
 {
 void
 AudioMapping::unmap_all ()
 {
-       for (vector<vector<float> >::iterator i = _gain.begin(); i != _gain.end(); ++i) {
-               for (vector<float>::iterator j = i->begin(); j != i->end(); ++j) {
-                       *j = 0;
+       for (auto& i: _gain) {
+               for (auto& j: i) {
+                       j = 0;
                }
        }
 }
                }
        }
 }
index 42557efc3135c4614fdb1dfbec294b61c71941b4..9a3b55e0aafe2dfc4ae8443ab33f2e1038938fd0 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
-    Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
     This file is part of DCP-o-matic.
 
@@ -55,9 +55,8 @@ Cinema::Cinema (cxml::ConstNodePtr node)
 void
 Cinema::read_screens (cxml::ConstNodePtr node)
 {
 void
 Cinema::read_screens (cxml::ConstNodePtr node)
 {
-       list<cxml::NodePtr> s = node->node_children ("Screen");
-       for (list<cxml::NodePtr>::iterator i = s.begin(); i != s.end(); ++i) {
-               add_screen (shared_ptr<Screen> (new Screen (*i)));
+       for (auto i: node->node_children("Screen")) {
+               add_screen (shared_ptr<Screen>(new Screen(i)));
        }
 }
 
        }
 }
 
index e0158b7356ddd4a846d2eb2e5d06558906424ca1..57e73a5b5c02133b65d30b5d544cc48a7b03a130 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
-    Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
     This file is part of DCP-o-matic.
 
@@ -41,6 +41,7 @@ using std::list;
 using std::string;
 using std::cout;
 using std::vector;
 using std::string;
 using std::cout;
 using std::vector;
+using std::make_shared;
 using std::shared_ptr;
 using boost::optional;
 using std::dynamic_pointer_cast;
 using std::shared_ptr;
 using boost::optional;
 using std::dynamic_pointer_cast;
@@ -68,19 +69,19 @@ ColourConversion::ColourConversion (cxml::NodePtr node, int version)
 
                /* Version 2.x */
 
 
                /* Version 2.x */
 
-               cxml::ConstNodePtr in_node = node->node_child ("InputTransferFunction");
-               string in_type = in_node->string_child ("Type");
+               auto in_node = node->node_child ("InputTransferFunction");
+               auto in_type = in_node->string_child ("Type");
                if (in_type == "Gamma") {
                if (in_type == "Gamma") {
-                       _in.reset (new dcp::GammaTransferFunction (in_node->number_child<double> ("Gamma")));
+                       _in = make_shared<dcp::GammaTransferFunction>(in_node->number_child<double> ("Gamma"));
                } else if (in_type == "ModifiedGamma") {
                } else if (in_type == "ModifiedGamma") {
-                       _in.reset (new dcp::ModifiedGammaTransferFunction (
-                                          in_node->number_child<double> ("Power"),
-                                          in_node->number_child<double> ("Threshold"),
-                                          in_node->number_child<double> ("A"),
-                                          in_node->number_child<double> ("B")
-                                          ));
+                       _in = make_shared<dcp::ModifiedGammaTransferFunction>(
+                                          in_node->number_child<double>("Power"),
+                                          in_node->number_child<double>("Threshold"),
+                                          in_node->number_child<double>("A"),
+                                          in_node->number_child<double>("B")
+                                          );
                } else if (in_type == "SGamut3") {
                } else if (in_type == "SGamut3") {
-                       _in.reset (new dcp::SGamut3TransferFunction ());
+                       _in = make_shared<dcp::SGamut3TransferFunction>();
                }
 
        } else {
                }
 
        } else {
@@ -96,14 +97,14 @@ ColourConversion::ColourConversion (cxml::NodePtr node, int version)
 
        _yuv_to_rgb = static_cast<dcp::YUVToRGB> (node->optional_number_child<int>("YUVToRGB").get_value_or (dcp::YUV_TO_RGB_REC601));
 
 
        _yuv_to_rgb = static_cast<dcp::YUVToRGB> (node->optional_number_child<int>("YUVToRGB").get_value_or (dcp::YUV_TO_RGB_REC601));
 
-       list<cxml::NodePtr> m = node->node_children ("Matrix");
+       auto m = node->node_children ("Matrix");
        if (!m.empty ()) {
                /* Read in old <Matrix> nodes and convert them to chromaticities */
                boost::numeric::ublas::matrix<double> C (3, 3);
        if (!m.empty ()) {
                /* Read in old <Matrix> nodes and convert them to chromaticities */
                boost::numeric::ublas::matrix<double> C (3, 3);
-               for (list<cxml::NodePtr>::iterator i = m.begin(); i != m.end(); ++i) {
-                       int const ti = (*i)->number_attribute<int> ("i");
-                       int const tj = (*i)->number_attribute<int> ("j");
-                       C(ti, tj) = raw_convert<double> ((*i)->content ());
+               for (auto i: m) {
+                       int const ti = i->number_attribute<int>("i");
+                       int const tj = i->number_attribute<int>("j");
+                       C(ti, tj) = raw_convert<double>(i->content());
                }
 
                double const rd = C(0, 0) + C(1, 0) + C(2, 0);
                }
 
                double const rd = C(0, 0) + C(1, 0) + C(2, 0);
@@ -127,11 +128,11 @@ ColourConversion::ColourConversion (cxml::NodePtr node, int version)
                }
        }
 
                }
        }
 
-       optional<double> gamma = node->optional_number_child<double> ("OutputGamma");
+       auto gamma = node->optional_number_child<double>("OutputGamma");
        if (gamma) {
        if (gamma) {
-               _out.reset (new dcp::GammaTransferFunction (node->number_child<double> ("OutputGamma")));
+               _out = make_shared<dcp::GammaTransferFunction>(node->number_child<double>("OutputGamma"));
        } else {
        } else {
-               _out.reset (new dcp::IdentityTransferFunction ());
+               _out = make_shared<dcp::IdentityTransferFunction>();
        }
 }
 
        }
 }
 
@@ -148,13 +149,13 @@ ColourConversion::from_xml (cxml::NodePtr node, int version)
 void
 ColourConversion::as_xml (xmlpp::Node* node) const
 {
 void
 ColourConversion::as_xml (xmlpp::Node* node) const
 {
-       xmlpp::Node* in_node = node->add_child ("InputTransferFunction");
+       auto in_node = node->add_child ("InputTransferFunction");
        if (dynamic_pointer_cast<const dcp::GammaTransferFunction> (_in)) {
        if (dynamic_pointer_cast<const dcp::GammaTransferFunction> (_in)) {
-               shared_ptr<const dcp::GammaTransferFunction> tf = dynamic_pointer_cast<const dcp::GammaTransferFunction> (_in);
+               auto tf = dynamic_pointer_cast<const dcp::GammaTransferFunction> (_in);
                in_node->add_child("Type")->add_child_text ("Gamma");
                in_node->add_child("Gamma")->add_child_text (raw_convert<string> (tf->gamma ()));
        } else if (dynamic_pointer_cast<const dcp::ModifiedGammaTransferFunction> (_in)) {
                in_node->add_child("Type")->add_child_text ("Gamma");
                in_node->add_child("Gamma")->add_child_text (raw_convert<string> (tf->gamma ()));
        } else if (dynamic_pointer_cast<const dcp::ModifiedGammaTransferFunction> (_in)) {
-               shared_ptr<const dcp::ModifiedGammaTransferFunction> tf = dynamic_pointer_cast<const dcp::ModifiedGammaTransferFunction> (_in);
+               auto tf = dynamic_pointer_cast<const dcp::ModifiedGammaTransferFunction> (_in);
                in_node->add_child("Type")->add_child_text ("ModifiedGamma");
                in_node->add_child("Power")->add_child_text (raw_convert<string> (tf->power ()));
                in_node->add_child("Threshold")->add_child_text (raw_convert<string> (tf->threshold ()));
                in_node->add_child("Type")->add_child_text ("ModifiedGamma");
                in_node->add_child("Power")->add_child_text (raw_convert<string> (tf->power ()));
                in_node->add_child("Threshold")->add_child_text (raw_convert<string> (tf->threshold ()));
@@ -187,14 +188,14 @@ ColourConversion::as_xml (xmlpp::Node* node) const
 optional<size_t>
 ColourConversion::preset () const
 {
 optional<size_t>
 ColourConversion::preset () const
 {
-       vector<PresetColourConversion> presets = PresetColourConversion::all ();
+       auto presets = PresetColourConversion::all ();
        size_t i = 0;
        while (i < presets.size() && presets[i].conversion != *this) {
                ++i;
        }
 
        if (i >= presets.size ()) {
        size_t i = 0;
        while (i < presets.size() && presets[i].conversion != *this) {
                ++i;
        }
 
        if (i >= presets.size ()) {
-               return optional<size_t> ();
+               return {};
        }
 
        return i;
        }
 
        return i;
@@ -230,7 +231,7 @@ ColourConversion::identifier () const
                digester.add (_adjusted_white.get().y);
        }
 
                digester.add (_adjusted_white.get().y);
        }
 
-       shared_ptr<const dcp::GammaTransferFunction> gf = dynamic_pointer_cast<const dcp::GammaTransferFunction> (_out);
+       auto gf = dynamic_pointer_cast<const dcp::GammaTransferFunction> (_out);
        if (gf) {
                digester.add (gf->gamma ());
        }
        if (gf) {
                digester.add (gf->gamma ());
        }
index a3eb1b77ad73b6b4fcdc3b8787ee7e048390106a..eae57cc06f365195683780fb9d4c8358a576bcf4 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
-    Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
     This file is part of DCP-o-matic.
 
@@ -59,6 +59,7 @@ using std::remove;
 using std::exception;
 using std::cerr;
 using std::shared_ptr;
 using std::exception;
 using std::cerr;
 using std::shared_ptr;
+using std::make_shared;
 using boost::optional;
 using std::dynamic_pointer_cast;
 using boost::algorithm::trim;
 using boost::optional;
 using std::dynamic_pointer_cast;
 using boost::algorithm::trim;
@@ -198,15 +199,13 @@ Config::restore_defaults ()
 shared_ptr<dcp::CertificateChain>
 Config::create_certificate_chain ()
 {
 shared_ptr<dcp::CertificateChain>
 Config::create_certificate_chain ()
 {
-       return shared_ptr<dcp::CertificateChain> (
-               new dcp::CertificateChain (
-                       openssl_path(),
-                       "dcpomatic.com",
-                       "dcpomatic.com",
-                       ".dcpomatic.smpte-430-2.ROOT",
-                       ".dcpomatic.smpte-430-2.INTERMEDIATE",
-                       "CS.dcpomatic.smpte-430-2.LEAF"
-                       )
+       return make_shared<dcp::CertificateChain> (
+               openssl_path(),
+               "dcpomatic.com",
+               "dcpomatic.com",
+               ".dcpomatic.smpte-430-2.ROOT",
+               ".dcpomatic.smpte-430-2.INTERMEDIATE",
+               "CS.dcpomatic.smpte-430-2.LEAF"
                );
 }
 
                );
 }
 
@@ -233,7 +232,7 @@ try
        cxml::Document f ("Config");
        f.read_file (config_file ());
 
        cxml::Document f ("Config");
        f.read_file (config_file ());
 
-       optional<int> version = f.optional_number_child<int> ("Version");
+       auto version = f.optional_number_child<int> ("Version");
        if (version && *version < _current_version) {
                /* Back up the old config before we re-write it in a back-incompatible way */
                backup ();
        if (version && *version < _current_version) {
                /* Back up the old config before we re-write it in a back-incompatible way */
                backup ();
@@ -252,13 +251,13 @@ try
                _default_directory = boost::optional<boost::filesystem::path> ();
        }
 
                _default_directory = boost::optional<boost::filesystem::path> ();
        }
 
-       boost::optional<int> b = f.optional_number_child<int> ("ServerPort");
+       auto b = f.optional_number_child<int> ("ServerPort");
        if (!b) {
                b = f.optional_number_child<int> ("ServerPortBase");
        }
        _server_port_base = b.get ();
 
        if (!b) {
                b = f.optional_number_child<int> ("ServerPortBase");
        }
        _server_port_base = b.get ();
 
-       boost::optional<bool> u = f.optional_bool_child ("UseAnyServers");
+       auto u = f.optional_bool_child ("UseAnyServers");
        _use_any_servers = u.get_value_or (true);
 
        for (auto i: f.node_children("Server")) {
        _use_any_servers = u.get_value_or (true);
 
        for (auto i: f.node_children("Server")) {
@@ -278,7 +277,7 @@ try
 
        _language = f.optional_string_child ("Language");
 
 
        _language = f.optional_string_child ("Language");
 
-       optional<string> c = f.optional_string_child ("DefaultContainer");
+       auto c = f.optional_string_child ("DefaultContainer");
        if (c) {
                _default_container = Ratio::from_id (c.get ());
        }
        if (c) {
                _default_container = Ratio::from_id (c.get ());
        }
@@ -297,7 +296,7 @@ try
                _dcp_issuer = f.string_child ("DCPIssuer");
        }
 
                _dcp_issuer = f.string_child ("DCPIssuer");
        }
 
-       optional<bool> up = f.optional_bool_child("UploadAfterMakeDCP");
+       auto up = f.optional_bool_child("UploadAfterMakeDCP");
        if (!up) {
                up = f.optional_bool_child("DefaultUploadAfterMakeDCP");
        }
        if (!up) {
                up = f.optional_bool_child("DefaultUploadAfterMakeDCP");
        }
@@ -391,9 +390,9 @@ try
                _player_history.push_back (i->content ());
        }
 
                _player_history.push_back (i->content ());
        }
 
-       cxml::NodePtr signer = f.optional_node_child ("Signer");
+       auto signer = f.optional_node_child ("Signer");
        if (signer) {
        if (signer) {
-               shared_ptr<dcp::CertificateChain> c (new dcp::CertificateChain ());
+               auto c = make_shared<dcp::CertificateChain>();
                /* Read the signing certificates and private key in from the config file */
                for (auto i: signer->node_children ("Certificate")) {
                        c->add (dcp::Certificate (i->content ()));
                /* Read the signing certificates and private key in from the config file */
                for (auto i: signer->node_children ("Certificate")) {
                        c->add (dcp::Certificate (i->content ()));
@@ -405,9 +404,9 @@ try
                _signer_chain = create_certificate_chain ();
        }
 
                _signer_chain = create_certificate_chain ();
        }
 
-       cxml::NodePtr decryption = f.optional_node_child ("Decryption");
+       auto decryption = f.optional_node_child ("Decryption");
        if (decryption) {
        if (decryption) {
-               shared_ptr<dcp::CertificateChain> c (new dcp::CertificateChain ());
+               auto c = make_shared<dcp::CertificateChain>();
                for (auto i: decryption->node_children ("Certificate")) {
                        c->add (dcp::Certificate (i->content ()));
                }
                for (auto i: decryption->node_children ("Certificate")) {
                        c->add (dcp::Certificate (i->content ()));
                }
@@ -421,7 +420,7 @@ try
           of the nags.
        */
        for (auto i: f.node_children("Nagged")) {
           of the nags.
        */
        for (auto i: f.node_children("Nagged")) {
-               int const id = i->number_attribute<int>("Id");
+               auto const id = i->number_attribute<int>("Id");
                if (id >= 0 && id < NAG_COUNT) {
                        _nagged[id] = raw_convert<int>(i->content());
                }
                if (id >= 0 && id < NAG_COUNT) {
                        _nagged[id] = raw_convert<int>(i->content());
                }
@@ -444,7 +443,7 @@ try
        }
 
        if (bad) {
        }
 
        if (bad) {
-               optional<bool> const remake = Bad(*bad);
+               auto const remake = Bad(*bad);
                if (remake && *remake) {
                        switch (*bad) {
                        case BAD_SIGNER_UTF8_STRINGS:
                if (remake && *remake) {
                        switch (*bad) {
                        case BAD_SIGNER_UTF8_STRINGS:
@@ -519,7 +518,7 @@ try
        _gdc_username = f.optional_string_child("GDCUsername");
        _gdc_password = f.optional_string_child("GDCPassword");
 
        _gdc_username = f.optional_string_child("GDCUsername");
        _gdc_password = f.optional_string_child("GDCPassword");
 
-       optional<string> pm = f.optional_string_child("PlayerMode");
+       auto pm = f.optional_string_child("PlayerMode");
        if (pm && *pm == "window") {
                _player_mode = PLAYER_MODE_WINDOW;
        } else if (pm && *pm == "full") {
        if (pm && *pm == "window") {
                _player_mode = PLAYER_MODE_WINDOW;
        } else if (pm && *pm == "full") {
@@ -529,7 +528,7 @@ try
        }
 
        _image_display = f.optional_number_child<int>("ImageDisplay").get_value_or(0);
        }
 
        _image_display = f.optional_number_child<int>("ImageDisplay").get_value_or(0);
-       optional<string> vc = f.optional_string_child("VideoViewType");
+       auto vc = f.optional_string_child("VideoViewType");
        if (vc && *vc == "opengl") {
                _video_view_type = VIDEO_VIEW_OPENGL;
        } else if (vc && *vc == "simple") {
        if (vc && *vc == "opengl") {
                _video_view_type = VIDEO_VIEW_OPENGL;
        } else if (vc && *vc == "simple") {
@@ -601,7 +600,7 @@ void
 Config::write_config () const
 {
        xmlpp::Document doc;
 Config::write_config () const
 {
        xmlpp::Document doc;
-       xmlpp::Element* root = doc.create_root_node ("Config");
+       auto root = doc.create_root_node ("Config");
 
        /* [XML] Version The version number of the configuration file format. */
        root->add_child("Version")->add_child_text (raw_convert<string>(_current_version));
 
        /* [XML] Version The version number of the configuration file format. */
        root->add_child("Version")->add_child_text (raw_convert<string>(_current_version));
@@ -779,7 +778,7 @@ Config::write_config () const
        /* [XML] Signer Certificate chain and private key to use when signing DCPs and KDMs.  Should contain <code>&lt;Certificate&gt;</code>
           tags in order and a <code>&lt;PrivateKey&gt;</code> tag all containing PEM-encoded certificates or private keys as appropriate.
        */
        /* [XML] Signer Certificate chain and private key to use when signing DCPs and KDMs.  Should contain <code>&lt;Certificate&gt;</code>
           tags in order and a <code>&lt;PrivateKey&gt;</code> tag all containing PEM-encoded certificates or private keys as appropriate.
        */
-       xmlpp::Element* signer = root->add_child ("Signer");
+       auto signer = root->add_child ("Signer");
        DCPOMATIC_ASSERT (_signer_chain);
        for (auto const& i: _signer_chain->unordered()) {
                signer->add_child("Certificate")->add_child_text (i.certificate (true));
        DCPOMATIC_ASSERT (_signer_chain);
        for (auto const& i: _signer_chain->unordered()) {
                signer->add_child("Certificate")->add_child_text (i.certificate (true));
@@ -787,7 +786,7 @@ Config::write_config () const
        signer->add_child("PrivateKey")->add_child_text (_signer_chain->key().get ());
 
        /* [XML] Decryption Certificate chain and private key to use when decrypting KDMs */
        signer->add_child("PrivateKey")->add_child_text (_signer_chain->key().get ());
 
        /* [XML] Decryption Certificate chain and private key to use when decrypting KDMs */
-       xmlpp::Element* decryption = root->add_child ("Decryption");
+       auto decryption = root->add_child ("Decryption");
        DCPOMATIC_ASSERT (_decryption_chain);
        for (auto const& i: _decryption_chain->unordered()) {
                decryption->add_child("Certificate")->add_child_text (i.certificate (true));
        DCPOMATIC_ASSERT (_decryption_chain);
        for (auto const& i: _decryption_chain->unordered()) {
                decryption->add_child("Certificate")->add_child_text (i.certificate (true));
@@ -975,9 +974,9 @@ Config::write_config () const
        }
 
        try {
        }
 
        try {
-               string const s = doc.write_to_string_formatted ();
+               auto const s = doc.write_to_string_formatted ();
                boost::filesystem::path tmp (string(config_file().string()).append(".tmp"));
                boost::filesystem::path tmp (string(config_file().string()).append(".tmp"));
-               FILE* f = fopen_boost (tmp, "w");
+               auto f = fopen_boost (tmp, "w");
                if (!f) {
                        throw FileError (_("Could not open file for writing"), tmp);
                }
                if (!f) {
                        throw FileError (_("Could not open file for writing"), tmp);
                }
@@ -995,10 +994,10 @@ Config::write_config () const
 
 template <class T>
 void
 
 template <class T>
 void
-write_file (string root_node, string node, string version, list<shared_ptr<T> > things, boost::filesystem::path file)
+write_file (string root_node, string node, string version, list<shared_ptr<T>> things, boost::filesystem::path file)
 {
        xmlpp::Document doc;
 {
        xmlpp::Document doc;
-       xmlpp::Element* root = doc.create_root_node (root_node);
+       auto root = doc.create_root_node (root_node);
        root->add_child("Version")->add_child_text(version);
 
        for (auto i: things) {
        root->add_child("Version")->add_child_text(version);
 
        for (auto i: things) {
@@ -1051,7 +1050,7 @@ Config::directory_or (optional<boost::filesystem::path> dir, boost::filesystem::
        }
 
        boost::system::error_code ec;
        }
 
        boost::system::error_code ec;
-       bool const e = boost::filesystem::exists (*dir, ec);
+       auto const e = boost::filesystem::exists (*dir, ec);
        if (ec || !e) {
                return a;
        }
        if (ec || !e) {
                return a;
        }
@@ -1169,7 +1168,7 @@ Config::add_to_history_internal (vector<boost::filesystem::path>& h, boost::file
 void
 Config::clean_history_internal (vector<boost::filesystem::path>& h)
 {
 void
 Config::clean_history_internal (vector<boost::filesystem::path>& h)
 {
-       vector<boost::filesystem::path> old = h;
+       auto old = h;
        h.clear ();
        for (auto i: old) {
                try {
        h.clear ();
        for (auto i: old) {
                try {
@@ -1192,12 +1191,11 @@ void
 Config::read_cinemas (cxml::Document const & f)
 {
        _cinemas.clear ();
 Config::read_cinemas (cxml::Document const & f)
 {
        _cinemas.clear ();
-       list<cxml::NodePtr> cin = f.node_children ("Cinema");
        for (auto i: f.node_children("Cinema")) {
                /* Slightly grotty two-part construction of Cinema here so that we can use
                   shared_from_this.
                */
        for (auto i: f.node_children("Cinema")) {
                /* Slightly grotty two-part construction of Cinema here so that we can use
                   shared_from_this.
                */
-               shared_ptr<Cinema> cinema (new Cinema (i));
+               auto cinema = make_shared<Cinema>(i);
                cinema->read_screens (i);
                _cinemas.push_back (cinema);
        }
                cinema->read_screens (i);
                _cinemas.push_back (cinema);
        }
@@ -1227,7 +1225,6 @@ void
 Config::read_dkdm_recipients (cxml::Document const & f)
 {
        _dkdm_recipients.clear ();
 Config::read_dkdm_recipients (cxml::Document const & f)
 {
        _dkdm_recipients.clear ();
-       list<cxml::NodePtr> cin = f.node_children ("DKDMRecipient");
        for (auto i: f.node_children("DKDMRecipient")) {
                _dkdm_recipients.push_back (shared_ptr<DKDMRecipient>(new DKDMRecipient(i)));
        }
        for (auto i: f.node_children("DKDMRecipient")) {
                _dkdm_recipients.push_back (shared_ptr<DKDMRecipient>(new DKDMRecipient(i)));
        }
@@ -1263,12 +1260,12 @@ list<string>
 Config::templates () const
 {
        if (!boost::filesystem::exists (path ("templates"))) {
 Config::templates () const
 {
        if (!boost::filesystem::exists (path ("templates"))) {
-               return list<string> ();
+               return {};
        }
 
        list<string> n;
        }
 
        list<string> n;
-       for (boost::filesystem::directory_iterator i (path("templates")); i != boost::filesystem::directory_iterator(); ++i) {
-               n.push_back (i->path().filename().string());
+       for (auto const& i: boost::filesystem::directory_iterator(path("templates"))) {
+               n.push_back (i.path().filename().string());
        }
        return n;
 }
        }
        return n;
 }
@@ -1302,7 +1299,7 @@ boost::filesystem::path
 Config::config_file ()
 {
        cxml::Document f ("Config");
 Config::config_file ()
 {
        cxml::Document f ("Config");
-       boost::filesystem::path main = path("config.xml", false);
+       auto main = path("config.xml", false);
        if (!boost::filesystem::exists (main)) {
                /* It doesn't exist, so there can't be any links; just return it */
                return main;
        if (!boost::filesystem::exists (main)) {
                /* It doesn't exist, so there can't be any links; just return it */
                return main;
@@ -1311,7 +1308,7 @@ Config::config_file ()
        /* See if there's a link */
        try {
                f.read_file (main);
        /* See if there's a link */
        try {
                f.read_file (main);
-               optional<string> link = f.optional_string_child("Link");
+               auto link = f.optional_string_child("Link");
                if (link) {
                        return *link;
                }
                if (link) {
                        return *link;
                }
@@ -1356,7 +1353,7 @@ Config::copy_and_link (boost::filesystem::path new_file) const
 bool
 Config::have_write_permission () const
 {
 bool
 Config::have_write_permission () const
 {
-       FILE* f = fopen_boost (config_file(), "r+");
+       auto f = fopen_boost (config_file(), "r+");
        if (!f) {
                return false;
        }
        if (!f) {
                return false;
        }
@@ -1409,7 +1406,7 @@ void
 Config::set_audio_mapping_to_default ()
 {
        DCPOMATIC_ASSERT (_audio_mapping);
 Config::set_audio_mapping_to_default ()
 {
        DCPOMATIC_ASSERT (_audio_mapping);
-       int const ch = _audio_mapping->output_channels ();
+       auto const ch = _audio_mapping->output_channels ();
        _audio_mapping = boost::none;
        _audio_mapping = audio_mapping (ch);
        changed (AUDIO_MAPPING);
        _audio_mapping = boost::none;
        _audio_mapping = audio_mapping (ch);
        changed (AUDIO_MAPPING);
index 5fb9d324ac8142953edfafe33ab2c4759af59068..d4dffe7775978e5ff267ed18dd67e3eb99e9189c 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
-    Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
     This file is part of DCP-o-matic.
 
@@ -91,10 +91,9 @@ Content::Content (boost::filesystem::path p)
 Content::Content (cxml::ConstNodePtr node)
        : _change_signals_frequent (false)
 {
 Content::Content (cxml::ConstNodePtr node)
        : _change_signals_frequent (false)
 {
-       list<cxml::NodePtr> path_children = node->node_children ("Path");
-       for (auto i: path_children) {
+       for (auto i: node->node_children("Path")) {
                _paths.push_back (i->content());
                _paths.push_back (i->content());
-               optional<time_t> const mod = i->optional_number_attribute<time_t>("mtime");
+               auto const mod = i->optional_number_attribute<time_t>("mtime");
                if (mod) {
                        _last_write_times.push_back (*mod);
                } else if (boost::filesystem::exists(i->content())) {
                if (mod) {
                        _last_write_times.push_back (*mod);
                } else if (boost::filesystem::exists(i->content())) {
@@ -169,7 +168,7 @@ string
 Content::calculate_digest () const
 {
        boost::mutex::scoped_lock lm (_mutex);
 Content::calculate_digest () const
 {
        boost::mutex::scoped_lock lm (_mutex);
-       vector<boost::filesystem::path> p = _paths;
+       auto p = _paths;
        lm.unlock ();
 
        /* Some content files are very big, so we use a poor man's
        lm.unlock ();
 
        /* Some content files are very big, so we use a poor man's
@@ -186,7 +185,7 @@ Content::examine (shared_ptr<const Film>, shared_ptr<Job> job)
                job->sub (_("Computing digest"));
        }
 
                job->sub (_("Computing digest"));
        }
 
-       string const d = calculate_digest ();
+       auto const d = calculate_digest ();
 
        boost::mutex::scoped_lock lm (_mutex);
        _digest = d;
 
        boost::mutex::scoped_lock lm (_mutex);
        _digest = d;
@@ -282,7 +281,7 @@ Content::clone () const
 {
        /* This is a bit naughty, but I can't think of a compelling reason not to do it ... */
        xmlpp::Document doc;
 {
        /* This is a bit naughty, but I can't think of a compelling reason not to do it ... */
        xmlpp::Document doc;
-       xmlpp::Node* node = doc.create_root_node ("Content");
+       auto node = doc.create_root_node ("Content");
        as_xml (node, true);
 
        /* notes is unused here (we assume) */
        as_xml (node, true);
 
        /* notes is unused here (we assume) */
@@ -293,7 +292,7 @@ Content::clone () const
 string
 Content::technical_summary () const
 {
 string
 Content::technical_summary () const
 {
-       string s = String::compose ("%1 %2 %3", path_summary(), digest(), position().seconds());
+       auto s = String::compose ("%1 %2 %3", path_summary(), digest(), position().seconds());
        if (_video_frame_rate) {
                s += String::compose(" %1", *_video_frame_rate);
        }
        if (_video_frame_rate) {
                s += String::compose(" %1", *_video_frame_rate);
        }
@@ -303,7 +302,7 @@ Content::technical_summary () const
 DCPTime
 Content::length_after_trim (shared_ptr<const Film> film) const
 {
 DCPTime
 Content::length_after_trim (shared_ptr<const Film> film) const
 {
-       DCPTime length = max(DCPTime(), full_length(film) - DCPTime(trim_start() + trim_end(), film->active_frame_rate_change(position())));
+       auto length = max(DCPTime(), full_length(film) - DCPTime(trim_start() + trim_end(), film->active_frame_rate_change(position())));
        if (video) {
                length = length.round(film->video_frame_rate());
        }
        if (video) {
                length = length.round(film->video_frame_rate());
        }
@@ -358,7 +357,7 @@ Content::path_summary () const
 
        DCPOMATIC_ASSERT (number_of_paths ());
 
 
        DCPOMATIC_ASSERT (number_of_paths ());
 
-       string s = path(0).filename().string ();
+       auto s = path(0).filename().string();
        if (number_of_paths() > 1) {
                s += " ...";
        }
        if (number_of_paths() > 1) {
                s += " ...";
        }
@@ -473,8 +472,8 @@ Content::take_settings_from (shared_ptr<const Content> c)
                audio->take_settings_from (c->audio);
        }
 
                audio->take_settings_from (c->audio);
        }
 
-       list<shared_ptr<TextContent> >::iterator i = text.begin ();
-       list<shared_ptr<TextContent> >::const_iterator j = c->text.begin ();
+       auto i = text.begin ();
+       auto j = c->text.begin ();
        while (i != text.end() && j != c->text.end()) {
                (*i)->take_settings_from (*j);
                ++i;
        while (i != text.end() && j != c->text.end()) {
                (*i)->take_settings_from (*j);
                ++i;
index 234c792fd3ddfff4c7915fa54bbcaca0dca22cda..2c42cf579cbbb1a11b2a8916531d050010f9e5ca 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
-    Copyright (C) 2013-2019 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
     This file is part of DCP-o-matic.
 
@@ -52,6 +52,7 @@ using std::cout;
 using std::pair;
 using std::make_pair;
 using std::max;
 using std::pair;
 using std::make_pair;
 using std::max;
+using std::make_shared;
 using std::shared_ptr;
 using std::dynamic_pointer_cast;
 using boost::optional;
 using std::shared_ptr;
 using std::dynamic_pointer_cast;
 using boost::optional;
@@ -73,7 +74,7 @@ template <class T>
 optional<T>
 get_optional_enum (cxml::ConstNodePtr node, string name)
 {
 optional<T>
 get_optional_enum (cxml::ConstNodePtr node, string name)
 {
-       optional<int> const v = node->optional_number_child<int>(name);
+       auto const v = node->optional_number_child<int>(name);
        if (!v) {
                return optional<T>();
        }
        if (!v) {
                return optional<T>();
        }
@@ -87,35 +88,32 @@ FFmpegContent::FFmpegContent (cxml::ConstNodePtr node, int version, list<string>
        audio = AudioContent::from_xml (this, node, version);
        text = TextContent::from_xml (this, node, version);
 
        audio = AudioContent::from_xml (this, node, version);
        text = TextContent::from_xml (this, node, version);
 
-       list<cxml::NodePtr> c = node->node_children ("SubtitleStream");
-       for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
-               _subtitle_streams.push_back (shared_ptr<FFmpegSubtitleStream> (new FFmpegSubtitleStream (*i, version)));
-               if ((*i)->optional_number_child<int> ("Selected")) {
+       for (auto i: node->node_children("SubtitleStream")) {
+               _subtitle_streams.push_back (make_shared<FFmpegSubtitleStream>(i, version));
+               if (i->optional_number_child<int>("Selected")) {
                        _subtitle_stream = _subtitle_streams.back ();
                }
        }
 
                        _subtitle_stream = _subtitle_streams.back ();
                }
        }
 
-       c = node->node_children ("AudioStream");
-       for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
-               shared_ptr<FFmpegAudioStream> as (new FFmpegAudioStream (*i, version));
+       for (auto i: node->node_children("AudioStream")) {
+               auto as = make_shared<FFmpegAudioStream>(i, version);
                audio->add_stream (as);
                audio->add_stream (as);
-               if (version < 11 && !(*i)->optional_node_child ("Selected")) {
+               if (version < 11 && !i->optional_node_child ("Selected")) {
                        /* This is an old file and this stream is not selected, so un-map it */
                        as->set_mapping (AudioMapping (as->channels (), MAX_DCP_AUDIO_CHANNELS));
                }
        }
 
                        /* This is an old file and this stream is not selected, so un-map it */
                        as->set_mapping (AudioMapping (as->channels (), MAX_DCP_AUDIO_CHANNELS));
                }
        }
 
-       c = node->node_children ("Filter");
-       for (list<cxml::NodePtr>::iterator i = c.begin(); i != c.end(); ++i) {
-               Filter const * f = Filter::from_id ((*i)->content ());
+       for (auto i: node->node_children("Filter")) {
+               Filter const * f = Filter::from_id(i->content());
                if (f) {
                        _filters.push_back (f);
                } else {
                if (f) {
                        _filters.push_back (f);
                } else {
-                       notes.push_back (String::compose (_("DCP-o-matic no longer supports the `%1' filter, so it has been turned off."), (*i)->content()));
+                       notes.push_back (String::compose (_("DCP-o-matic no longer supports the `%1' filter, so it has been turned off."), i->content()));
                }
        }
 
                }
        }
 
-       optional<ContentTime::Type> const f = node->optional_number_child<ContentTime::Type> ("FirstVideo");
+       auto const f = node->optional_number_child<ContentTime::Type> ("FirstVideo");
        if (f) {
                _first_video = ContentTime (f.get ());
        }
        if (f) {
                _first_video = ContentTime (f.get ());
        }
@@ -130,7 +128,7 @@ FFmpegContent::FFmpegContent (cxml::ConstNodePtr node, int version, list<string>
 FFmpegContent::FFmpegContent (vector<shared_ptr<Content> > c)
        : Content (c)
 {
 FFmpegContent::FFmpegContent (vector<shared_ptr<Content> > c)
        : Content (c)
 {
-       vector<shared_ptr<Content> >::const_iterator i = c.begin ();
+       auto i = c.begin ();
 
        bool need_video = false;
        bool need_audio = false;
 
        bool need_video = false;
        bool need_audio = false;
@@ -156,20 +154,20 @@ FFmpegContent::FFmpegContent (vector<shared_ptr<Content> > c)
        }
 
        if (need_video) {
        }
 
        if (need_video) {
-               video.reset (new VideoContent (this, c));
+               video = make_shared<VideoContent>(this, c);
        }
        if (need_audio) {
        }
        if (need_audio) {
-               audio.reset (new AudioContent (this, c));
+               audio = make_shared<AudioContent>(this, c);
        }
        if (need_text) {
        }
        if (need_text) {
-               text.push_back (shared_ptr<TextContent> (new TextContent (this, c)));
+               text.push_back (make_shared<TextContent>(this, c));
        }
 
        }
 
-       shared_ptr<FFmpegContent> ref = dynamic_pointer_cast<FFmpegContent> (c[0]);
+       auto ref = dynamic_pointer_cast<FFmpegContent> (c[0]);
        DCPOMATIC_ASSERT (ref);
 
        for (size_t i = 0; i < c.size(); ++i) {
        DCPOMATIC_ASSERT (ref);
 
        for (size_t i = 0; i < c.size(); ++i) {
-               shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c[i]);
+               auto fc = dynamic_pointer_cast<FFmpegContent>(c[i]);
                if (fc->only_text() && fc->only_text()->use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) {
                        throw JoinError (_("Content to be joined must use the same subtitle stream."));
                }
                if (fc->only_text() && fc->only_text()->use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) {
                        throw JoinError (_("Content to be joined must use the same subtitle stream."));
                }
@@ -202,7 +200,7 @@ FFmpegContent::as_xml (xmlpp::Node* node, bool with_paths) const
                audio->as_xml (node);
 
                for (auto i: audio->streams ()) {
                audio->as_xml (node);
 
                for (auto i: audio->streams ()) {
-                       shared_ptr<FFmpegAudioStream> f = dynamic_pointer_cast<FFmpegAudioStream> (i);
+                       auto f = dynamic_pointer_cast<FFmpegAudioStream> (i);
                        DCPOMATIC_ASSERT (f);
                        f->as_xml (node->add_child("AudioStream"));
                }
                        DCPOMATIC_ASSERT (f);
                        f->as_xml (node->add_child("AudioStream"));
                }
@@ -214,16 +212,16 @@ FFmpegContent::as_xml (xmlpp::Node* node, bool with_paths) const
 
        boost::mutex::scoped_lock lm (_mutex);
 
 
        boost::mutex::scoped_lock lm (_mutex);
 
-       for (vector<shared_ptr<FFmpegSubtitleStream> >::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) {
-               xmlpp::Node* t = node->add_child("SubtitleStream");
-               if (_subtitle_stream && *i == _subtitle_stream) {
+       for (auto i: _subtitle_streams) {
+               auto t = node->add_child("SubtitleStream");
+               if (_subtitle_stream && i == _subtitle_stream) {
                        t->add_child("Selected")->add_child_text("1");
                }
                        t->add_child("Selected")->add_child_text("1");
                }
-               (*i)->as_xml (t);
+               i->as_xml (t);
        }
 
        }
 
-       for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
-               node->add_child("Filter")->add_child_text ((*i)->id ());
+       for (auto i: _filters) {
+               node->add_child("Filter")->add_child_text(i->id());
        }
 
        if (_first_video) {
        }
 
        if (_first_video) {
@@ -259,14 +257,14 @@ FFmpegContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
 
        Content::examine (film, job);
 
 
        Content::examine (film, job);
 
-       shared_ptr<FFmpegExaminer> examiner (new FFmpegExaminer (shared_from_this (), job));
+       auto examiner = make_shared<FFmpegExaminer>(shared_from_this (), job);
 
        if (examiner->has_video ()) {
                video.reset (new VideoContent (this));
                video->take_from_examiner (examiner);
        }
 
 
        if (examiner->has_video ()) {
                video.reset (new VideoContent (this));
                video->take_from_examiner (examiner);
        }
 
-       boost::filesystem::path first_path = path (0);
+       auto first_path = path (0);
 
        {
                boost::mutex::scoped_lock lm (_mutex);
 
        {
                boost::mutex::scoped_lock lm (_mutex);
@@ -280,7 +278,7 @@ FFmpegContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
                        _bits_per_pixel = examiner->bits_per_pixel ();
 
                        if (examiner->rotation()) {
                        _bits_per_pixel = examiner->bits_per_pixel ();
 
                        if (examiner->rotation()) {
-                               double rot = *examiner->rotation ();
+                               auto rot = *examiner->rotation ();
                                if (fabs (rot - 180) < 1.0) {
                                        _filters.push_back (Filter::from_id ("vflip"));
                                        _filters.push_back (Filter::from_id ("hflip"));
                                if (fabs (rot - 180) < 1.0) {
                                        _filters.push_back (Filter::from_id ("vflip"));
                                        _filters.push_back (Filter::from_id ("hflip"));
@@ -293,14 +291,14 @@ FFmpegContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
                }
 
                if (!examiner->audio_streams().empty ()) {
                }
 
                if (!examiner->audio_streams().empty ()) {
-                       audio.reset (new AudioContent (this));
+                       audio = make_shared<AudioContent>(this);
 
 
-                       for (auto i: examiner->audio_streams ()) {
+                       for (auto i: examiner->audio_streams()) {
                                audio->add_stream (i);
                        }
 
                                audio->add_stream (i);
                        }
 
-                       AudioStreamPtr as = audio->streams().front();
-                       AudioMapping m = as->mapping ();
+                       auto as = audio->streams().front();
+                       auto m = as->mapping ();
                        m.make_default (film ? film->audio_processor() : 0, first_path);
                        as->set_mapping (m);
                }
                        m.make_default (film ? film->audio_processor() : 0, first_path);
                        as->set_mapping (m);
                }
@@ -308,7 +306,7 @@ FFmpegContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
                _subtitle_streams = examiner->subtitle_streams ();
                if (!_subtitle_streams.empty ()) {
                        text.clear ();
                _subtitle_streams = examiner->subtitle_streams ();
                if (!_subtitle_streams.empty ()) {
                        text.clear ();
-                       text.push_back (shared_ptr<TextContent> (new TextContent (this, TEXT_OPEN_SUBTITLE, TEXT_UNKNOWN)));
+                       text.push_back (make_shared<TextContent>(this, TEXT_OPEN_SUBTITLE, TEXT_UNKNOWN));
                        _subtitle_stream = _subtitle_streams.front ();
                }
        }
                        _subtitle_stream = _subtitle_streams.front ();
                }
        }
@@ -357,9 +355,9 @@ FFmpegContent::technical_summary () const
                ss = _subtitle_stream->technical_summary ();
        }
 
                ss = _subtitle_stream->technical_summary ();
        }
 
-       string filt = Filter::ffmpeg_string (_filters);
+       auto filt = Filter::ffmpeg_string (_filters);
 
 
-       string s = Content::technical_summary ();
+       auto s = Content::technical_summary ();
 
        if (video) {
                s += " - " + video->technical_summary ();
 
        if (video) {
                s += " - " + video->technical_summary ();
@@ -465,8 +463,8 @@ FFmpegContent::identifier () const
                s += "_" + _subtitle_stream->identifier ();
        }
 
                s += "_" + _subtitle_stream->identifier ();
        }
 
-       for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
-               s += "_" + (*i)->id ();
+       for (auto i: _filters) {
+               s += "_" + i->id();
        }
 
        return s;
        }
 
        return s;
@@ -477,7 +475,7 @@ FFmpegContent::set_default_colour_conversion ()
 {
        DCPOMATIC_ASSERT (video);
 
 {
        DCPOMATIC_ASSERT (video);
 
-       dcp::Size const s = video->size ();
+       auto const s = video->size ();
 
        boost::mutex::scoped_lock lm (_mutex);
 
 
        boost::mutex::scoped_lock lm (_mutex);
 
@@ -680,7 +678,7 @@ FFmpegContent::ffmpeg_audio_streams () const
 void
 FFmpegContent::take_settings_from (shared_ptr<const Content> c)
 {
 void
 FFmpegContent::take_settings_from (shared_ptr<const Content> c)
 {
-       shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (c);
+       auto fc = dynamic_pointer_cast<const FFmpegContent> (c);
        if (!fc) {
                return;
                }
        if (!fc) {
                return;
                }
index 2f01bb2fa6e8a32e9d819ca3e2515bc272676b81..a9ed8608350fdbb9f9a48b8f2fbc2edfd598da56 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
-    Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
     This file is part of DCP-o-matic.
 
@@ -35,6 +35,7 @@ using std::vector;
 using std::cout;
 using std::list;
 using std::shared_ptr;
 using std::cout;
 using std::list;
 using std::shared_ptr;
+using std::make_shared;
 using std::dynamic_pointer_cast;
 using boost::optional;
 using dcp::raw_convert;
 using std::dynamic_pointer_cast;
 using boost::optional;
 using dcp::raw_convert;
@@ -76,7 +77,7 @@ TextContent::TextContent (Content* parent, TextType type, TextType original_type
 /** @return TextContents from node or <Text> nodes under node (according to version).
  *  The list could be empty if no TextContents are found.
  */
 /** @return TextContents from node or <Text> nodes under node (according to version).
  *  The list could be empty if no TextContents are found.
  */
-list<shared_ptr<TextContent> >
+list<shared_ptr<TextContent>>
 TextContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version)
 {
        if (version < 34) {
 TextContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version)
 {
        if (version < 34) {
@@ -84,7 +85,7 @@ TextContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version)
                   subtitle streams, so check for that.
                */
                if (node->string_child("Type") == "FFmpeg" && node->node_children("SubtitleStream").empty()) {
                   subtitle streams, so check for that.
                */
                if (node->string_child("Type") == "FFmpeg" && node->node_children("SubtitleStream").empty()) {
-                       return list<shared_ptr<TextContent> >();
+                       return {};
                }
 
                /* Otherwise we can drop through to the newer logic */
                }
 
                /* Otherwise we can drop through to the newer logic */
@@ -92,20 +93,20 @@ TextContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version)
 
        if (version < 37) {
                if (!node->optional_number_child<double>("SubtitleXOffset") && !node->optional_number_child<double>("SubtitleOffset")) {
 
        if (version < 37) {
                if (!node->optional_number_child<double>("SubtitleXOffset") && !node->optional_number_child<double>("SubtitleOffset")) {
-                       return list<shared_ptr<TextContent> >();
+                       return {};
                }
                }
-               list<shared_ptr<TextContent> > c;
-               c.push_back (shared_ptr<TextContent> (new TextContent (parent, node, version)));
+               list<shared_ptr<TextContent>> c;
+               c.push_back (make_shared<TextContent>(parent, node, version));
                return c;
        }
 
        if (!node->optional_node_child("Text")) {
                return c;
        }
 
        if (!node->optional_node_child("Text")) {
-               return list<shared_ptr<TextContent> >();
+               return {};
        }
 
        }
 
-       list<shared_ptr<TextContent> > c;
+       list<shared_ptr<TextContent>> c;
        for (auto i: node->node_children("Text")) {
        for (auto i: node->node_children("Text")) {
-               c.push_back (shared_ptr<TextContent> (new TextContent (parent, i, version)));
+               c.push_back (make_shared<TextContent>(parent, i, version));
        }
 
        return c;
        }
 
        return c;
@@ -150,7 +151,7 @@ TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version)
                _effect = dcp::NONE;
        }
 
                _effect = dcp::NONE;
        }
 
-       optional<string> effect = node->optional_string_child("Effect");
+       auto effect = node->optional_string_child("Effect");
        if (effect) {
                if (*effect == "none") {
                        _effect = dcp::NONE;
        if (effect) {
                if (*effect == "none") {
                        _effect = dcp::NONE;
@@ -171,17 +172,17 @@ TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version)
                _x_scale = _y_scale = node->number_child<double> ("SubtitleScale");
        }
 
                _x_scale = _y_scale = node->number_child<double> ("SubtitleScale");
        }
 
-       optional<int> r = node->optional_number_child<int>("Red");
-       optional<int> g = node->optional_number_child<int>("Green");
-       optional<int> b = node->optional_number_child<int>("Blue");
+       auto r = node->optional_number_child<int>("Red");
+       auto g = node->optional_number_child<int>("Green");
+       auto b = node->optional_number_child<int>("Blue");
        if (r && g && b) {
                _colour = dcp::Colour (*r, *g, *b);
        }
 
        if (version >= 36) {
        if (r && g && b) {
                _colour = dcp::Colour (*r, *g, *b);
        }
 
        if (version >= 36) {
-               optional<int> er = node->optional_number_child<int>("EffectRed");
-               optional<int> eg = node->optional_number_child<int>("EffectGreen");
-               optional<int> eb = node->optional_number_child<int>("EffectBlue");
+               auto er = node->optional_number_child<int>("EffectRed");
+               auto eg = node->optional_number_child<int>("EffectGreen");
+               auto eb = node->optional_number_child<int>("EffectBlue");
                if (er && eg && eb) {
                        _effect_colour = dcp::Colour (*er, *eg, *eb);
                }
                if (er && eg && eb) {
                        _effect_colour = dcp::Colour (*er, *eg, *eb);
                }
@@ -213,9 +214,8 @@ TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version)
                _fade_out = ContentTime (*fo);
        }
 
                _fade_out = ContentTime (*fo);
        }
 
-       list<cxml::NodePtr> fonts = node->node_children ("Font");
-       for (list<cxml::NodePtr>::const_iterator i = fonts.begin(); i != fonts.end(); ++i) {
-               _fonts.push_back (shared_ptr<Font> (new Font (*i)));
+       for (auto i: node->node_children ("Font")) {
+               _fonts.push_back (make_shared<Font>(i));
        }
 
        connect_to_fonts ();
        }
 
        connect_to_fonts ();
@@ -227,21 +227,21 @@ TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version)
                }
        }
 
                }
        }
 
-       cxml::ConstNodePtr dt = node->optional_node_child("DCPTrack");
+       auto dt = node->optional_node_child("DCPTrack");
        if (dt) {
                _dcp_track = DCPTextTrack (dt);
        }
 }
 
        if (dt) {
                _dcp_track = DCPTextTrack (dt);
        }
 }
 
-TextContent::TextContent (Content* parent, vector<shared_ptr<Content> > c)
+TextContent::TextContent (Content* parent, vector<shared_ptr<Content>> c)
        : ContentPart (parent)
 {
        /* This constructor is for join which is only supported for content types
           that have a single text, so we can use only_text() here.
        */
        : ContentPart (parent)
 {
        /* This constructor is for join which is only supported for content types
           that have a single text, so we can use only_text() here.
        */
-       shared_ptr<TextContent> ref = c[0]->only_text();
+       auto ref = c[0]->only_text();
        DCPOMATIC_ASSERT (ref);
        DCPOMATIC_ASSERT (ref);
-       list<shared_ptr<Font> > ref_fonts = ref->fonts ();
+       auto ref_fonts = ref->fonts ();
 
        for (size_t i = 1; i < c.size(); ++i) {
 
 
        for (size_t i = 1; i < c.size(); ++i) {
 
@@ -281,7 +281,7 @@ TextContent::TextContent (Content* parent, vector<shared_ptr<Content> > c)
                        throw JoinError (_("Content to be joined must have the same outline width."));
                }
 
                        throw JoinError (_("Content to be joined must have the same outline width."));
                }
 
-               list<shared_ptr<Font> > fonts = c[i]->only_text()->fonts ();
+               auto fonts = c[i]->only_text()->fonts ();
                if (fonts.size() != ref_fonts.size()) {
                        throw JoinError (_("Content to be joined must use the same fonts."));
                }
                if (fonts.size() != ref_fonts.size()) {
                        throw JoinError (_("Content to be joined must use the same fonts."));
                }
@@ -290,8 +290,8 @@ TextContent::TextContent (Content* parent, vector<shared_ptr<Content> > c)
                        throw JoinError (_("Content to be joined must use the same DCP track."));
                }
 
                        throw JoinError (_("Content to be joined must use the same DCP track."));
                }
 
-               list<shared_ptr<Font> >::const_iterator j = ref_fonts.begin ();
-               list<shared_ptr<Font> >::const_iterator k = fonts.begin ();
+               auto j = ref_fonts.begin ();
+               auto k = fonts.begin ();
 
                while (j != ref_fonts.end ()) {
                        if (**j != **k) {
 
                while (j != ref_fonts.end ()) {
                        if (**j != **k) {
@@ -326,7 +326,7 @@ TextContent::as_xml (xmlpp::Node* root) const
 {
        boost::mutex::scoped_lock lm (_mutex);
 
 {
        boost::mutex::scoped_lock lm (_mutex);
 
-       xmlpp::Element* text = root->add_child ("Text");
+       auto text = root->add_child ("Text");
 
        text->add_child("Use")->add_child_text (_use ? "1" : "0");
        text->add_child("Burn")->add_child_text (_burn ? "1" : "0");
 
        text->add_child("Use")->add_child_text (_use ? "1" : "0");
        text->add_child("Burn")->add_child_text (_burn ? "1" : "0");
@@ -366,8 +366,8 @@ TextContent::as_xml (xmlpp::Node* root) const
        }
        text->add_child("OutlineWidth")->add_child_text (raw_convert<string> (_outline_width));
 
        }
        text->add_child("OutlineWidth")->add_child_text (raw_convert<string> (_outline_width));
 
-       for (list<shared_ptr<Font> >::const_iterator i = _fonts.begin(); i != _fonts.end(); ++i) {
-               (*i)->as_xml (text->add_child("Font"));
+       for (auto i: _fonts) {
+               i->as_xml (text->add_child("Font"));
        }
 
        text->add_child("Type")->add_child_text (text_type_to_string(_type));
        }
 
        text->add_child("Type")->add_child_text (text_type_to_string(_type));
@@ -380,7 +380,7 @@ TextContent::as_xml (xmlpp::Node* root) const
 string
 TextContent::identifier () const
 {
 string
 TextContent::identifier () const
 {
-       string s = raw_convert<string> (x_scale())
+       auto s = raw_convert<string> (x_scale())
                + "_" + raw_convert<string> (y_scale())
                + "_" + raw_convert<string> (x_offset())
                + "_" + raw_convert<string> (y_offset())
                + "_" + raw_convert<string> (y_scale())
                + "_" + raw_convert<string> (x_offset())
                + "_" + raw_convert<string> (y_offset())
index 21d09ad12b7329e146b5a1169a5ea934cd26dc16..e566d05524721fc952f4cbaeb4fd4806d8c4df95 100644 (file)
@@ -63,6 +63,7 @@ class TextContent : public ContentPart
 public:
        TextContent (Content* parent, TextType type, TextType original_type);
        TextContent (Content* parent, std::vector<std::shared_ptr<Content> >);
 public:
        TextContent (Content* parent, TextType type, TextType original_type);
        TextContent (Content* parent, std::vector<std::shared_ptr<Content> >);
+       TextContent (Content* parent, cxml::ConstNodePtr, int version);
 
        void as_xml (xmlpp::Node *) const;
        std::string identifier () const;
 
        void as_xml (xmlpp::Node *) const;
        std::string identifier () const;
@@ -182,7 +183,6 @@ public:
 private:
        friend struct ffmpeg_pts_offset_test;
 
 private:
        friend struct ffmpeg_pts_offset_test;
 
-       TextContent (Content* parent, cxml::ConstNodePtr, int version);
        void font_changed ();
        void connect_to_fonts ();
 
        void font_changed ();
        void connect_to_fonts ();