From 5d1496fa502655d334439b4b2658625a2b3c1b70 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 5 Nov 2021 00:43:00 +0100 Subject: [PATCH] C++11 tidying. --- src/lib/audio_content.cc | 2 +- src/lib/audio_ring_buffers.h | 2 +- src/lib/check_content_change_job.cc | 16 ++++++++++------ src/lib/cinema.h | 2 +- src/lib/config.h | 8 ++++---- src/lib/cross.h | 2 +- src/lib/ffmpeg_decoder.h | 2 +- src/lib/ffmpeg_encoder.h | 2 +- src/lib/player.h | 4 ++-- src/lib/render_text.h | 2 +- src/lib/send_kdm_email_job.cc | 2 +- src/lib/subtitle_encoder.h | 2 +- src/lib/text_content.h | 4 ++-- src/lib/video_content.cc | 2 +- src/tools/dcpomatic_create.cc | 4 ++-- src/wx/content_panel.cc | 2 +- src/wx/content_properties_dialog.h | 2 +- src/wx/content_widget.h | 14 +++++++------- src/wx/text_panel.cc | 2 +- src/wx/timeline.cc | 2 +- src/wx/timeline_content_view.cc | 6 +++--- src/wx/timeline_time_axis_view.cc | 2 +- src/wx/timeline_time_axis_view.h | 2 +- src/wx/wx_util.cc | 2 +- src/wx/wx_util.h | 2 +- test/create_cli_test.cc | 6 +++--- 26 files changed, 51 insertions(+), 47 deletions(-) diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index 748cbb7d0..f2510b494 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -98,7 +98,7 @@ AudioContent::AudioContent (Content* parent, cxml::ConstNodePtr node) } -AudioContent::AudioContent (Content* parent, vector > c) +AudioContent::AudioContent (Content* parent, vector> c) : ContentPart (parent) { auto ref = c[0]->audio; diff --git a/src/lib/audio_ring_buffers.h b/src/lib/audio_ring_buffers.h index 4c90ed791..6fb84e0d7 100644 --- a/src/lib/audio_ring_buffers.h +++ b/src/lib/audio_ring_buffers.h @@ -48,7 +48,7 @@ public: private: mutable boost::mutex _mutex; - std::list, dcpomatic::DCPTime> > _buffers; + std::list, dcpomatic::DCPTime>> _buffers; int _used_in_head = 0; }; diff --git a/src/lib/check_content_change_job.cc b/src/lib/check_content_change_job.cc index c4d050c0e..216cf3e51 100644 --- a/src/lib/check_content_change_job.cc +++ b/src/lib/check_content_change_job.cc @@ -18,19 +18,23 @@ */ + #include "check_content_change_job.h" -#include "job_manager.h" -#include "examine_content_job.h" #include "content.h" +#include "examine_content_job.h" #include "film.h" +#include "job_manager.h" #include #include "i18n.h" -using std::string; -using std::list; + using std::cout; +using std::list; +using std::make_shared; using std::shared_ptr; +using std::string; + /** @param gui true if we are running this job from the GUI, false if it's the CLI */ CheckContentChangeJob::CheckContentChangeJob (shared_ptr film, shared_ptr following, bool gui) @@ -63,7 +67,7 @@ CheckContentChangeJob::run () { set_progress_unknown (); - list > changed; + list> changed; for (auto i: _film->content()) { bool ic = false; @@ -84,7 +88,7 @@ CheckContentChangeJob::run () if (!changed.empty()) { if (_gui) { for (auto i: changed) { - JobManager::instance()->add(shared_ptr(new ExamineContentJob(_film, i))); + JobManager::instance()->add(make_shared(_film, i)); } string m = _("Some files have been changed since they were added to the project.\n\nThese files will now be re-examined, so you may need to check their settings."); if (_following) { diff --git a/src/lib/cinema.h b/src/lib/cinema.h index a89408f3f..c17454db9 100644 --- a/src/lib/cinema.h +++ b/src/lib/cinema.h @@ -76,7 +76,7 @@ public: return _utc_offset_minute; } - std::list > screens () const { + std::list> screens () const { return _screens; } diff --git a/src/lib/config.h b/src/lib/config.h index c9206b139..d927b3b19 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -140,11 +140,11 @@ public: return _tms_password; } - std::list > cinemas () const { + std::list> cinemas () const { return _cinemas; } - std::list > dkdm_recipients () const { + std::list> dkdm_recipients () const { return _dkdm_recipients; } @@ -1194,8 +1194,8 @@ private: */ boost::optional _default_kdm_directory; bool _upload_after_make_dcp; - std::list > _cinemas; - std::list > _dkdm_recipients; + std::list> _cinemas; + std::list> _dkdm_recipients; std::string _mail_server; int _mail_port; EmailProtocol _mail_protocol; diff --git a/src/lib/cross.h b/src/lib/cross.h index ed1d0c8e7..1f06822b0 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -43,7 +43,7 @@ extern void dcpomatic_sleep_seconds (int); extern void dcpomatic_sleep_milliseconds (int); extern std::string cpu_info (); extern void run_ffprobe (boost::filesystem::path, boost::filesystem::path); -extern std::list > mount_info (); +extern std::list> mount_info (); extern boost::filesystem::path openssl_path (); extern void make_foreground_application (); #ifdef DCPOMATIC_DISK diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index fce3fcae9..264733c70 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -71,7 +71,7 @@ private: void maybe_add_subtitle (); - std::list > _filter_graphs; + std::list> _filter_graphs; boost::mutex _filter_graphs_mutex; dcpomatic::ContentTime _pts_offset; diff --git a/src/lib/ffmpeg_encoder.h b/src/lib/ffmpeg_encoder.h index f450c8022..393a6d72e 100644 --- a/src/lib/ffmpeg_encoder.h +++ b/src/lib/ffmpeg_encoder.h @@ -73,7 +73,7 @@ private: void audio (std::shared_ptr); private: - std::map > _encoders; + std::map> _encoders; }; int _output_audio_channels; diff --git a/src/lib/player.h b/src/lib/player.h index 51c30e864..14fb8d0ee 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -174,7 +174,7 @@ private: /** > 0 if we are suspended (i.e. pass() and seek() do nothing) */ boost::atomic _suspended; - std::list > _pieces; + std::list> _pieces; /** Size of the image we are rendering to; this may be the DCP frame size, or * the size of preview in a window. @@ -208,7 +208,7 @@ private: AudioMerger _audio_merger; std::unique_ptr _shuffler; - std::list, dcpomatic::DCPTime> > _delay; + std::list, dcpomatic::DCPTime>> _delay; class StreamState { diff --git a/src/lib/render_text.h b/src/lib/render_text.h index 07a97bb40..b7846654b 100644 --- a/src/lib/render_text.h +++ b/src/lib/render_text.h @@ -29,5 +29,5 @@ namespace dcpomatic { std::string marked_up (std::list subtitles, int target_height, float fade_factor, std::string font_name); std::list render_text ( - std::list, std::list > fonts, dcp::Size, dcpomatic::DCPTime, int + std::list, std::list> fonts, dcp::Size, dcpomatic::DCPTime, int ); diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc index 67ddd0eef..a0d65508d 100644 --- a/src/lib/send_kdm_email_job.cc +++ b/src/lib/send_kdm_email_job.cc @@ -60,7 +60,7 @@ SendKDMEmailJob::SendKDMEmailJob ( * @param cpl_name Name of the CPL that the KDMs are for. */ SendKDMEmailJob::SendKDMEmailJob ( - list > kdms, + list> kdms, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, string cpl_name diff --git a/src/lib/subtitle_encoder.h b/src/lib/subtitle_encoder.h index b43cc2683..a10e4ba47 100644 --- a/src/lib/subtitle_encoder.h +++ b/src/lib/subtitle_encoder.h @@ -54,7 +54,7 @@ public: private: void text (PlayerText subs, TextType type, boost::optional track, dcpomatic::DCPTimePeriod period); - std::vector, boost::filesystem::path> > _assets; + std::vector, boost::filesystem::path>> _assets; std::vector _reels; bool _split_reels; bool _include_font; diff --git a/src/lib/text_content.h b/src/lib/text_content.h index d3e9b564b..66bedecf5 100644 --- a/src/lib/text_content.h +++ b/src/lib/text_content.h @@ -132,7 +132,7 @@ public: return _y_scale; } - std::list > fonts () const { + std::list> fonts () const { boost::mutex::scoped_lock lm (_mutex); return _fonts; } @@ -221,7 +221,7 @@ private: double _x_scale; /** y scale factor to apply to subtitles */ double _y_scale; - std::list > _fonts; + std::list> _fonts; boost::optional _colour; boost::optional _effect; boost::optional _effect_colour; diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 9ff35ffdf..c6574fce3 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -196,7 +196,7 @@ VideoContent::VideoContent (Content* parent, cxml::ConstNodePtr node, int versio } -VideoContent::VideoContent (Content* parent, vector > c) +VideoContent::VideoContent (Content* parent, vector> c) : ContentPart (parent) , _length (0) , _yuv (false) diff --git a/src/tools/dcpomatic_create.cc b/src/tools/dcpomatic_create.cc index 14eae6b3e..e4e674fbf 100644 --- a/src/tools/dcpomatic_create.cc +++ b/src/tools/dcpomatic_create.cc @@ -111,8 +111,8 @@ main (int argc, char* argv[]) } for (auto i: cc.content) { - boost::filesystem::path const can = boost::filesystem::canonical (i.path); - list > content; + auto const can = boost::filesystem::canonical (i.path); + list> content; if (boost::filesystem::exists (can / "ASSETMAP") || (boost::filesystem::exists (can / "ASSETMAP.xml"))) { content.push_back (shared_ptr(new DCPContent(can))); diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index ceebd6e14..b2b72b216 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -473,7 +473,7 @@ ContentPanel::add_folder_clicked () return; } - list > content; + list> content; try { content = content_factory (path); diff --git a/src/wx/content_properties_dialog.h b/src/wx/content_properties_dialog.h index c7efa4497..f8e8eaf2f 100644 --- a/src/wx/content_properties_dialog.h +++ b/src/wx/content_properties_dialog.h @@ -36,5 +36,5 @@ public: ContentPropertiesDialog (wxWindow* parent, std::shared_ptr film, std::shared_ptr content); private: - void maybe_add_group (std::map > const & groups, UserProperty::Category category); + void maybe_add_group (std::map> const & groups, UserProperty::Category category); }; diff --git a/src/wx/content_widget.h b/src/wx/content_widget.h index 34755e4b5..782b339a7 100644 --- a/src/wx/content_widget.h +++ b/src/wx/content_widget.h @@ -92,13 +92,13 @@ public: return _wrapped; } - typedef std::vector > List; + typedef std::vector> List; /** Set the content that this control is working on (i.e. the selected content) */ void set_content (List content) { - for (typename std::list::iterator i = _connections.begin(); i != _connections.end(); ++i) { - i->disconnect (); + for (auto& i: _connections) { + i.disconnect (); } _connections.clear (); @@ -109,11 +109,11 @@ public: update_from_model (); - for (typename List::iterator i = _content.begin(); i != _content.end(); ++i) { + for (auto i: _content) { #if BOOST_VERSION >= 106100 - _connections.push_back ((*i)->Change.connect (boost::bind (&ContentWidget::model_changed, this, boost::placeholders::_1, boost::placeholders::_3))); + _connections.push_back (i->Change.connect(boost::bind(&ContentWidget::model_changed, this, boost::placeholders::_1, boost::placeholders::_3))); #else - _connections.push_back ((*i)->Change.connect (boost::bind (&ContentWidget::model_changed, this, _1, _3))); + _connections.push_back (i->Change.connect(boost::bind(&ContentWidget::model_changed, this, _1, _3))); #endif } } @@ -135,7 +135,7 @@ public: return; } - typename List::iterator i = _content.begin (); + auto i = _content.begin (); U const v = boost::bind (_model_getter, _part(_content.front().get()).get())(); while (i != _content.end() && boost::bind (_model_getter, _part(i->get()).get())() == v) { ++i; diff --git a/src/wx/text_panel.cc b/src/wx/text_panel.cc index 7bbead30c..715503b6a 100644 --- a/src/wx/text_panel.cc +++ b/src/wx/text_panel.cc @@ -874,7 +874,7 @@ TextPanel::update_outline_subtitles_in_viewer () } fv->set_outline_subtitles (rect); } else { - fv->set_outline_subtitles (optional >()); + fv->set_outline_subtitles ({}); } } diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 359de9bf9..1c5937ae0 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -152,7 +152,7 @@ Timeline::paint_labels () _labels_canvas->GetViewStart (&vsx, &vsy); gc->Translate (-vsx * _x_scroll_rate, -vsy * _y_scroll_rate + tracks_y_offset()); - _labels_view->paint (gc, list >()); + _labels_view->paint (gc, {}); delete gc; } diff --git a/src/wx/timeline_content_view.cc b/src/wx/timeline_content_view.cc index 677b83bdd..481e8100d 100644 --- a/src/wx/timeline_content_view.cc +++ b/src/wx/timeline_content_view.cc @@ -95,7 +95,7 @@ TimelineContentView::track () const } void -TimelineContentView::do_paint (wxGraphicsContext* gc, list > overlaps) +TimelineContentView::do_paint (wxGraphicsContext* gc, list> overlaps) { DCPOMATIC_ASSERT (_track); @@ -105,8 +105,8 @@ TimelineContentView::do_paint (wxGraphicsContext* gc, list return; } - DCPTime const position = cont->position (); - DCPTime const len = cont->length_after_trim (film); + auto const position = cont->position (); + auto const len = cont->length_after_trim (film); wxColour selected (background_colour().Red() / 2, background_colour().Green() / 2, background_colour().Blue() / 2); diff --git a/src/wx/timeline_time_axis_view.cc b/src/wx/timeline_time_axis_view.cc index e9de1b542..cd0b97d19 100644 --- a/src/wx/timeline_time_axis_view.cc +++ b/src/wx/timeline_time_axis_view.cc @@ -50,7 +50,7 @@ TimelineTimeAxisView::set_y (int y) } void -TimelineTimeAxisView::do_paint (wxGraphicsContext* gc, list >) +TimelineTimeAxisView::do_paint (wxGraphicsContext* gc, list>) { if (!_timeline.pixels_per_second()) { return; diff --git a/src/wx/timeline_time_axis_view.h b/src/wx/timeline_time_axis_view.h index 5477e61f1..100228ae8 100644 --- a/src/wx/timeline_time_axis_view.h +++ b/src/wx/timeline_time_axis_view.h @@ -29,7 +29,7 @@ public: void set_y (int y); private: - void do_paint (wxGraphicsContext* gc, std::list > overlaps); + void do_paint (wxGraphicsContext* gc, std::list> overlaps); int _y; ///< y position in tracks (not pixels) }; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index a0beb8f72..47b381562 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -297,7 +297,7 @@ checked_set (wxChoice* widget, string value) void -checked_set (wxChoice* widget, vector > items) +checked_set (wxChoice* widget, vector> items) { vector> current; for (unsigned int i = 0; i < widget->GetCount(); ++i) { diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index 585a30611..3fa2ebe25 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -144,7 +144,7 @@ extern void checked_set (wxSpinCtrl* widget, int value); extern void checked_set (wxSpinCtrlDouble* widget, double value); extern void checked_set (wxChoice* widget, int value); extern void checked_set (wxChoice* widget, std::string value); -extern void checked_set (wxChoice* widget, std::vector > items); +extern void checked_set (wxChoice* widget, std::vector> items); extern void checked_set (wxTextCtrl* widget, std::string value); extern void checked_set (wxTextCtrl* widget, wxString value); extern void checked_set (PasswordEntry* widget, std::string value); diff --git a/test/create_cli_test.cc b/test/create_cli_test.cc index ad794226f..b5663f81c 100644 --- a/test/create_cli_test.cc +++ b/test/create_cli_test.cc @@ -35,13 +35,13 @@ run (string cmd) /* This approximates the logic which splits command lines up into argc/argv */ boost::escaped_list_separator els ("", " ", "\"\'"); - boost::tokenizer > tok (cmd, els); + boost::tokenizer> tok (cmd, els); std::vector argv(256); int argc = 0; - for (boost::tokenizer >::iterator i = tok.begin(); i != tok.end(); ++i) { - argv[argc++] = strdup (i->c_str()); + for (auto i: tok) { + argv[argc++] = strdup (i.c_str()); } CreateCLI cc (argc, argv.data()); -- 2.30.2