From 9f125fddff88bf62d36381f9d3f09e5240b033d5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 18 May 2023 22:21:33 +0200 Subject: Cleanup: replace some list with vector. --- src/lib/cinema.cc | 5 ++++- src/lib/cinema.h | 8 ++++---- src/lib/dkdm_recipient.h | 4 ++-- src/lib/emailer.cc | 6 +++--- src/lib/emailer.h | 12 ++++++------ src/lib/kdm_cli.cc | 10 +++++----- src/lib/kdm_with_metadata.h | 6 +++--- src/lib/screen.cc | 2 +- src/lib/send_notification_email_job.cc | 6 +----- 9 files changed, 29 insertions(+), 30 deletions(-) (limited to 'src/lib') diff --git a/src/lib/cinema.cc b/src/lib/cinema.cc index 57780fa7b..3b4b9d7b6 100644 --- a/src/lib/cinema.cc +++ b/src/lib/cinema.cc @@ -91,7 +91,10 @@ Cinema::add_screen (shared_ptr s) void Cinema::remove_screen (shared_ptr s) { - _screens.remove (s); + auto iter = std::find(_screens.begin(), _screens.end(), s); + if (iter != _screens.end()) { + _screens.erase(iter); + } } void diff --git a/src/lib/cinema.h b/src/lib/cinema.h index c17454db9..6c202a7bf 100644 --- a/src/lib/cinema.h +++ b/src/lib/cinema.h @@ -44,7 +44,7 @@ namespace dcpomatic { class Cinema : public std::enable_shared_from_this { public: - Cinema (std::string const & name_, std::list const & e, std::string notes_, int utc_offset_hour, int utc_offset_minute) + Cinema(std::string const & name_, std::vector const & e, std::string notes_, int utc_offset_hour, int utc_offset_minute) : name (name_) , emails (e) , notes (notes_) @@ -65,7 +65,7 @@ public: void set_utc_offset_minute (int m); std::string name; - std::list emails; + std::vector emails; std::string notes; int utc_offset_hour () const { @@ -76,12 +76,12 @@ public: return _utc_offset_minute; } - std::list> screens () const { + std::vector> screens() const { return _screens; } private: - std::list> _screens; + std::vector> _screens; /** Offset such that the equivalent time in UTC can be determined by subtracting the offset from the local time. */ diff --git a/src/lib/dkdm_recipient.h b/src/lib/dkdm_recipient.h index 6e9e4dfb1..7a0fa0185 100644 --- a/src/lib/dkdm_recipient.h +++ b/src/lib/dkdm_recipient.h @@ -33,7 +33,7 @@ public: std::string const& name_, std::string const& notes_, boost::optional recipient_, - std::list emails_, + std::vector emails_, int utc_offset_hour_, int utc_offset_minute_ ) @@ -49,7 +49,7 @@ public: void as_xml (xmlpp::Element *) const override; - std::list emails; + std::vector emails; int utc_offset_hour; int utc_offset_minute; }; diff --git a/src/lib/emailer.cc b/src/lib/emailer.cc index e21bbfe2d..f580e3c56 100644 --- a/src/lib/emailer.cc +++ b/src/lib/emailer.cc @@ -31,15 +31,15 @@ using std::cout; -using std::list; using std::min; using std::pair; using std::shared_ptr; using std::string; +using std::vector; using dcp::ArrayData; -Emailer::Emailer (string from, list to, string subject, string body) +Emailer::Emailer(string from, vector to, string subject, string body) : _from (from) , _to (to) , _subject (subject) @@ -247,7 +247,7 @@ Emailer::send (string server, int port, EmailProtocol protocol, string user, str string -Emailer::address_list (list addresses) +Emailer::address_list(vector addresses) { string o; for (auto i: addresses) { diff --git a/src/lib/emailer.h b/src/lib/emailer.h index ef41b0320..78942ad1e 100644 --- a/src/lib/emailer.h +++ b/src/lib/emailer.h @@ -26,7 +26,7 @@ class Emailer { public: - Emailer (std::string from, std::list to, std::string subject, std::string body); + Emailer(std::string from, std::vector to, std::string subject, std::string body); void add_cc (std::string cc); void add_bcc (std::string bcc); @@ -46,7 +46,7 @@ public: return _email; } - static std::string address_list (std::list addresses); + static std::string address_list(std::vector addresses); private: @@ -54,11 +54,11 @@ private: static std::string encode_rfc1342 (std::string subject); std::string _from; - std::list _to; + std::vector _to; std::string _subject; std::string _body; - std::list _cc; - std::list _bcc; + std::vector _cc; + std::vector _bcc; struct Attachment { boost::filesystem::path file; @@ -66,7 +66,7 @@ private: std::string mime_type; }; - std::list _attachments; + std::vector _attachments; std::string _email; size_t _offset; std::string _notes; diff --git a/src/lib/kdm_cli.cc b/src/lib/kdm_cli.cc index 925626119..05a59142f 100644 --- a/src/lib/kdm_cli.cc +++ b/src/lib/kdm_cli.cc @@ -203,7 +203,7 @@ find_cinema (string cinema_name) static void from_film ( - list> screens, + vector> screens, boost::filesystem::path film_dir, bool verbose, boost::filesystem::path output, @@ -346,7 +346,7 @@ kdm_from_dkdm ( static void from_dkdm ( - list> screens, + vector> screens, dcp::DecryptedKDM dkdm, bool verbose, boost::filesystem::path output, @@ -396,7 +396,7 @@ from_dkdm ( name_values['e'] = end.date() + " " + end.time_of_day(true, false); name_values['i'] = kdm.cpl_id(); - kdms.push_back (make_shared(name_values, i->cinema.get(), i->cinema ? i->cinema->emails : list(), kdm)); + kdms.push_back(make_shared(name_values, i->cinema.get(), i->cinema ? i->cinema->emails : vector(), kdm)); } write_files (kdms, zip, output, container_name_format, filename_format, verbose, out); if (email) { @@ -441,7 +441,7 @@ try shared_ptr cinema; optional certificate; optional screen; - list> screens; + vector> screens; optional dkdm; optional valid_from; optional valid_to; @@ -552,7 +552,7 @@ try (for lookup) and by creating a Cinema which the next Screen will be added to. */ cinema_name = optarg; - cinema = make_shared(optarg, list(), "", 0, 0); + cinema = make_shared(optarg, vector(), "", 0, 0); break; case 'S': /* Similarly, this could be the name of a new (temporary) screen or the name of a screen diff --git a/src/lib/kdm_with_metadata.h b/src/lib/kdm_with_metadata.h index df9f04125..fbeeffbc1 100644 --- a/src/lib/kdm_with_metadata.h +++ b/src/lib/kdm_with_metadata.h @@ -33,7 +33,7 @@ class Cinema; class KDMWithMetadata { public: - KDMWithMetadata (dcp::NameFormat::Map const& name_values, void const* group, std::list emails, dcp::EncryptedKDM kdm) + KDMWithMetadata(dcp::NameFormat::Map const& name_values, void const* group, std::vector emails, dcp::EncryptedKDM kdm) : _name_values (name_values) , _group (group) , _emails (emails) @@ -58,14 +58,14 @@ public: return _group; } - std::list emails () const { + std::vector emails() const { return _emails; } private: dcp::NameFormat::Map _name_values; void const* _group; - std::list _emails; + std::vector _emails; dcp::EncryptedKDM _kdm; }; diff --git a/src/lib/screen.cc b/src/lib/screen.cc index dbf013111..097ff80b8 100644 --- a/src/lib/screen.cc +++ b/src/lib/screen.cc @@ -116,6 +116,6 @@ kdm_for_screen ( name_values['e'] = end.date() + " " + end.time_of_day(true, false); name_values['i'] = kdm.cpl_id(); - return make_shared(name_values, cinema.get(), cinema ? cinema->emails : list(), kdm); + return make_shared(name_values, cinema.get(), cinema ? cinema->emails : vector(), kdm); } diff --git a/src/lib/send_notification_email_job.cc b/src/lib/send_notification_email_job.cc index c4d5a6518..2dd1f63f2 100644 --- a/src/lib/send_notification_email_job.cc +++ b/src/lib/send_notification_email_job.cc @@ -24,13 +24,11 @@ #include "config.h" #include "emailer.h" #include "compose.hpp" -#include #include "i18n.h" using std::string; -using std::list; using std::shared_ptr; @@ -73,9 +71,7 @@ SendNotificationEmailJob::run () } set_progress_unknown (); - list to; - to.push_back (config->notification_to()); - Emailer email (config->notification_from(), to, config->notification_subject(), _body); + Emailer email (config->notification_from(), { config->notification_to() }, config->notification_subject(), _body); for (auto i: config->notification_cc()) { email.add_cc (i); } -- cgit v1.2.3