C++11 tidying.
authorCarl Hetherington <cth@carlh.net>
Sat, 8 Jan 2022 11:56:05 +0000 (12:56 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 8 Jan 2022 11:56:05 +0000 (12:56 +0100)
src/lib/atmos_metadata.cc
src/lib/audio_delay.cc
src/lib/audio_filter_graph.cc
src/lib/config.cc
src/lib/image_content.cc
src/lib/json_server.cc
src/lib/writer.cc
src/lib/zipper.cc
src/tools/dcpomatic.cc
src/wx/job_manager_view.cc
src/wx/subtitle_appearance_dialog.cc

index 0fe23f3b0f4b8e4d5404922ed83e251bf44aa41d..0ab04a8259dcb03282b3dfe0afcc98d52c9bf1db 100644 (file)
@@ -23,6 +23,7 @@
 #include <dcp/atmos_asset.h>
 
 
+using std::make_shared;
 using std::shared_ptr;
 
 
@@ -39,5 +40,5 @@ AtmosMetadata::AtmosMetadata (shared_ptr<const dcp::AtmosAsset> asset)
 shared_ptr<dcp::AtmosAsset>
 AtmosMetadata::create (dcp::Fraction edit_rate) const
 {
-       return shared_ptr<dcp::AtmosAsset> (new dcp::AtmosAsset(edit_rate, _first_frame, _max_channel_count, _max_object_count, _atmos_version));
+       return make_shared<dcp::AtmosAsset>(edit_rate, _first_frame, _max_channel_count, _max_object_count, _atmos_version);
 }
index 90214470cd279185cd2e4a3ef4f7ef825c978a16..d06d9e73023055d8d060ae322bd64cc63e379f0c 100644 (file)
@@ -43,7 +43,7 @@ AudioDelay::run (shared_ptr<const AudioBuffers> in)
        /* You can't call this with varying channel counts */
        DCPOMATIC_ASSERT (!_tail || in->channels() == _tail->channels());
 
-       shared_ptr<AudioBuffers> out (new AudioBuffers (in->channels(), in->frames()));
+       auto out = make_shared<AudioBuffers>(in->channels(), in->frames());
 
        if (in->frames() > _samples) {
 
index fc43b5a344a972a9ef20d69e1257441024616412..95f6730cf4f24d99d43a981e6056c8058366406f 100644 (file)
@@ -18,8 +18,9 @@
 
 */
 
-#include "audio_filter_graph.h"
+
 #include "audio_buffers.h"
+#include "audio_filter_graph.h"
 #include "compose.hpp"
 extern "C" {
 #include <libavfilter/buffersink.h>
@@ -31,9 +32,12 @@ extern "C" {
 
 #include "i18n.h"
 
-using std::string;
+
 using std::cout;
+using std::make_shared;
 using std::shared_ptr;
+using std::string;
+
 
 AudioFilterGraph::AudioFilterGraph (int sample_rate, int channels)
        : _sample_rate (sample_rate)
@@ -113,7 +117,7 @@ AudioFilterGraph::process (shared_ptr<const AudioBuffers> buffers)
                   the constructor) so we need to create new buffers with some extra
                   silent channels.
                */
-               shared_ptr<AudioBuffers> extended_buffers (new AudioBuffers (process_channels, buffers->frames()));
+               auto extended_buffers = make_shared<AudioBuffers>(process_channels, buffers->frames());
                for (int i = 0; i < buffers->channels(); ++i) {
                        extended_buffers->copy_channel_from (buffers.get(), i, i);
                }
index fdab2bb16bd3afa5f5b0088bc3d58cdf3c1c5bdb..bf294aec957e03a3c95d7d6ff8f7677112d66073 100644 (file)
 
 */
 
+
+#include "cinema.h"
+#include "colour_conversion.h"
+#include "compose.hpp"
 #include "config.h"
+#include "cross.h"
+#include "crypto.h"
+#include "dcp_content_type.h"
+#include "dkdm_recipient.h"
+#include "dkdm_wrapper.h"
+#include "film.h"
 #include "filter.h"
+#include "log.h"
 #include "ratio.h"
 #include "types.h"
-#include "log.h"
-#include "dcp_content_type.h"
-#include "colour_conversion.h"
-#include "cinema.h"
 #include "util.h"
-#include "cross.h"
-#include "film.h"
-#include "dkdm_wrapper.h"
-#include "compose.hpp"
-#include "crypto.h"
-#include "dkdm_recipient.h"
-#include <dcp/raw_convert.h>
-#include <dcp/name_format.h>
 #include <dcp/certificate_chain.h>
+#include <dcp/name_format.h>
+#include <dcp/raw_convert.h>
 #include <libcxml/cxml.h>
 #include <glib.h>
 #include <libxml++/libxml++.h>
 
 #include "i18n.h"
 
-using std::vector;
+
 using std::cout;
+using std::dynamic_pointer_cast;
 using std::ifstream;
-using std::string;
 using std::list;
-using std::min;
+using std::make_shared;
 using std::max;
+using std::min;
 using std::remove;
 using std::shared_ptr;
-using std::make_shared;
-using boost::optional;
-using std::dynamic_pointer_cast;
+using std::string;
+using std::vector;
 using boost::algorithm::trim;
+using boost::optional;
 using dcp::raw_convert;
 
+
 Config* Config::_instance = 0;
 int const Config::_current_version = 3;
 boost::signals2::signal<void ()> Config::FailedToLoad;
 boost::signals2::signal<void (string)> Config::Warning;
 boost::signals2::signal<bool (Config::BadReason)> Config::Bad;
 
+
 /** Construct default configuration */
 Config::Config ()
         /* DKDMs are not considered a thing to reset on set_defaults() */
@@ -487,7 +491,7 @@ try
                _dkdms = dynamic_pointer_cast<DKDMGroup> (DKDMBase::read (f.node_child("DKDMGroup")));
        } else {
                /* Old-style: one or more DKDM nodes */
-               _dkdms.reset (new DKDMGroup ("root"));
+               _dkdms = make_shared<DKDMGroup>("root");
                for (auto i: f.node_children("DKDM")) {
                        _dkdms->add (DKDMBase::read (i));
                }
@@ -1269,7 +1273,7 @@ Config::read_dkdm_recipients (cxml::Document const & f)
 {
        _dkdm_recipients.clear ();
        for (auto i: f.node_children("DKDMRecipient")) {
-               _dkdm_recipients.push_back (shared_ptr<DKDMRecipient>(new DKDMRecipient(i)));
+               _dkdm_recipients.push_back (make_shared<DKDMRecipient>(i));
        }
 }
 
index 517d6792f89715d16f83edcaa60779f40a7e99ee..6a6be2716c4bffc01ae067538676025c95a4e16f 100644 (file)
     You should have received a copy of the GNU General Public License
     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
 
+
 */
 
-#include "image_content.h"
-#include "video_content.h"
-#include "image_examiner.h"
 #include "compose.hpp"
+#include "exceptions.h"
 #include "film.h"
-#include "job.h"
 #include "frame_rate_change.h"
-#include "exceptions.h"
+#include "image_content.h"
+#include "image_examiner.h"
 #include "image_filename_sorter.h"
+#include "job.h"
+#include "video_content.h"
 #include <libcxml/cxml.h>
 #include <libxml++/libxml++.h>
 #include <iostream>
 
 #include "i18n.h"
 
-using std::string;
+
 using std::cout;
 using std::list;
-using std::vector;
+using std::make_shared;
 using std::shared_ptr;
+using std::string;
+using std::vector;
 using namespace dcpomatic;
 
+
 ImageContent::ImageContent (boost::filesystem::path p)
 {
-       video.reset (new VideoContent (this));
+       video = make_shared<VideoContent>(this);
 
        if (boost::filesystem::is_regular_file (p) && valid_image_file (p)) {
                add_path (p);
@@ -107,9 +111,9 @@ ImageContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
                job->sub (_("Scanning image files"));
                vector<boost::filesystem::path> paths;
                int n = 0;
-               for (boost::filesystem::directory_iterator i(*_path_to_scan); i != boost::filesystem::directory_iterator(); ++i) {
-                       if (boost::filesystem::is_regular_file (i->path()) && valid_image_file (i->path())) {
-                               paths.push_back (i->path());
+               for (auto i: boost::filesystem::directory_iterator(*_path_to_scan)) {
+                       if (boost::filesystem::is_regular_file(i.path()) && valid_image_file(i.path())) {
+                               paths.push_back (i.path());
                        }
                        ++n;
                        if ((n % 1000) == 0) {
@@ -127,7 +131,7 @@ ImageContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
 
        Content::examine (film, job);
 
-       shared_ptr<ImageExaminer> examiner (new ImageExaminer (film, shared_from_this(), job));
+       auto examiner = make_shared<ImageExaminer>(film, shared_from_this(), job);
        video->take_from_examiner (examiner);
        set_default_colour_conversion ();
 }
index dd56b3124fea46550a2921ea96e813dd4a71f213..8c626ad1f0e2186d48d205f050dfececbf6de0bc 100644 (file)
 */
 
 
-#include "json_server.h"
-#include "job_manager.h"
-#include "job.h"
-#include "util.h"
 #include "film.h"
+#include "job.h"
+#include "job_manager.h"
+#include "json_server.h"
 #include "transcode_job.h"
+#include "util.h"
 #include <dcp/raw_convert.h>
 #include <boost/asio.hpp>
 #include <boost/bind/bind.hpp>
 #include <iostream>
 
 
-using std::string;
 using std::cout;
-using std::map;
+using std::dynamic_pointer_cast;
 using std::list;
-using boost::thread;
+using std::make_shared;
+using std::map;
 using std::shared_ptr;
-using std::dynamic_pointer_cast;
+using std::string;
 using boost::asio::ip::tcp;
+using boost::thread;
 using dcp::raw_convert;
 
 
@@ -74,7 +75,7 @@ try
        tcp::acceptor a (io_service, tcp::endpoint (tcp::v4 (), port));
        while (true) {
                try {
-                       shared_ptr<tcp::socket> s (new tcp::socket (io_service));
+                       auto s = make_shared<tcp::socket>(io_service);
                        a.accept (*s);
                        handle (s);
                }
index d85be9eff2b741adebbb9165d5b3ff01938c16a8..4596fde0522c03f25d7510d50bacf2bb4e98c802 100644 (file)
@@ -303,12 +303,11 @@ Writer::write (shared_ptr<const AudioBuffers> audio, DCPTime const time)
                        DCPOMATIC_ASSERT ((part_frames[0] + part_frames[1]) <= audio->frames());
 
                        if (part_frames[0]) {
-                               shared_ptr<AudioBuffers> part (new AudioBuffers(audio, part_frames[0], 0));
-                               _audio_reel->write (part);
+                               _audio_reel->write (make_shared<AudioBuffers>(audio, part_frames[0], 0));
                        }
 
                        if (part_frames[1]) {
-                               audio.reset (new AudioBuffers(audio, part_frames[1], part_frames[0]));
+                               audio = make_shared<AudioBuffers>(audio, part_frames[1], part_frames[0]);
                        } else {
                                audio.reset ();
                        }
index 2c334dc947fe62c9f25c06d5b47856c623219e32..2a07232789a456e301d8a576fc2b9049d54f6606 100644 (file)
 */
 
 
-#include "zipper.h"
-#include "exceptions.h"
 #include "dcpomatic_assert.h"
+#include "exceptions.h"
+#include "zipper.h"
 #include <zip.h>
 #include <boost/filesystem.hpp>
 #include <stdexcept>
 
 
-using std::string;
+using std::make_shared;
 using std::runtime_error;
 using std::shared_ptr;
+using std::string;
 
 
 Zipper::Zipper (boost::filesystem::path file)
@@ -48,7 +49,7 @@ Zipper::Zipper (boost::filesystem::path file)
 void
 Zipper::add (string name, string content)
 {
-       shared_ptr<string> copy(new string(content));
+       auto copy = make_shared<string>(content);
        _store.push_back (copy);
 
        auto source = zip_source_buffer (_zip, copy->c_str(), copy->length(), 0);
@@ -68,7 +69,7 @@ Zipper::close ()
        if (zip_close(_zip) == -1) {
                throw runtime_error ("failed to close ZIP archive");
        }
-       _zip = 0;
+       _zip = nullptr;
 }
 
 
index 459832963ecebdcc9cff0c9991bb99a668353e5b..fa61d4e1d5fa50652e3bbabddbdddf9ad2e3604a 100644 (file)
@@ -630,7 +630,7 @@ private:
                int const r = d->ShowModal ();
 
                if (r == wxID_OK && d->check_path() && maybe_save_film<FilmChangedDuplicatingDialog>()) {
-                       shared_ptr<Film> film (new Film (d->path()));
+                       auto film = make_shared<Film>(d->path());
                        film->copy_from (_film);
                        film->set_name (d->path().filename().generic_string());
                        film->write_metadata ();
index 19243393c308dc174e7ee7bda14c1699f183df8d..35b6d98b93648fb247f61763ab3be2b17925bd3b 100644 (file)
  */
 
 
-#include "job_manager_view.h"
 #include "batch_job_view.h"
+#include "job_manager_view.h"
 #include "normal_job_view.h"
 #include "wx_util.h"
-#include "lib/job_manager.h"
+#include "lib/compose.hpp"
+#include "lib/exceptions.h"
 #include "lib/job.h"
+#include "lib/job_manager.h"
 #include "lib/util.h"
-#include "lib/exceptions.h"
-#include "lib/compose.hpp"
 #include <iostream>
 
 
-using std::string;
+using std::cout;
 using std::list;
 using std::map;
 using std::min;
-using std::cout;
 using std::shared_ptr;
+using std::string;
 using std::weak_ptr;
 using boost::bind;
 #if BOOST_VERSION >= 106100
index b5ab8c2db79777f9ab8bee2230782917c104442d..aa8e31a4ed1271c8a27ae20d56f6647994f3657f 100644 (file)
@@ -39,11 +39,12 @@ DCPOMATIC_DISABLE_WARNINGS
 DCPOMATIC_ENABLE_WARNINGS
 
 
+using std::dynamic_pointer_cast;
+using std::make_shared;
 using std::map;
-using std::string;
 using std::shared_ptr;
+using std::string;
 using boost::bind;
-using std::dynamic_pointer_cast;
 using boost::optional;
 using namespace dcpomatic;
 #if BOOST_VERSION >= 106100
@@ -68,7 +69,7 @@ SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr
                /* XXX: assuming that all FFmpeg streams have bitmap subs */
                if (_stream->colours().empty()) {
                        _job_manager_connection = JobManager::instance()->ActiveJobsChanged.connect(boost::bind(&SubtitleAppearanceDialog::active_jobs_changed, this, _1));
-                       _job = JobManager::instance()->add(shared_ptr<Job>(new ExamineFFmpegSubtitlesJob(film, ff)));
+                       _job = JobManager::instance()->add(make_shared<ExamineFFmpegSubtitlesJob>(film, ff));
                }
        }