diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-01-08 12:56:05 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-01-08 12:56:05 +0100 |
| commit | 49493f16a9bab200e50954ae69f0c7bca869a139 (patch) | |
| tree | ffb772ea6c44c2cd9f241cfed302c8a988962d54 /src/lib | |
| parent | 2ac6688e4e75ff26db9208e760966bd071dcc48f (diff) | |
C++11 tidying.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/atmos_metadata.cc | 3 | ||||
| -rw-r--r-- | src/lib/audio_delay.cc | 2 | ||||
| -rw-r--r-- | src/lib/audio_filter_graph.cc | 10 | ||||
| -rw-r--r-- | src/lib/config.cc | 44 | ||||
| -rw-r--r-- | src/lib/image_content.cc | 28 | ||||
| -rw-r--r-- | src/lib/json_server.cc | 19 | ||||
| -rw-r--r-- | src/lib/writer.cc | 5 | ||||
| -rw-r--r-- | src/lib/zipper.cc | 11 |
8 files changed, 68 insertions, 54 deletions
diff --git a/src/lib/atmos_metadata.cc b/src/lib/atmos_metadata.cc index 0fe23f3b0..0ab04a825 100644 --- a/src/lib/atmos_metadata.cc +++ b/src/lib/atmos_metadata.cc @@ -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); } diff --git a/src/lib/audio_delay.cc b/src/lib/audio_delay.cc index 90214470c..d06d9e730 100644 --- a/src/lib/audio_delay.cc +++ b/src/lib/audio_delay.cc @@ -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) { diff --git a/src/lib/audio_filter_graph.cc b/src/lib/audio_filter_graph.cc index fc43b5a34..95f6730cf 100644 --- a/src/lib/audio_filter_graph.cc +++ b/src/lib/audio_filter_graph.cc @@ -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); } diff --git a/src/lib/config.cc b/src/lib/config.cc index fdab2bb16..bf294aec9 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -18,24 +18,25 @@ */ + +#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> @@ -48,27 +49,30 @@ #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)); } } diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index 517d6792f..6a6be2716 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -16,33 +16,37 @@ 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 (); } diff --git a/src/lib/json_server.cc b/src/lib/json_server.cc index dd56b3124..8c626ad1f 100644 --- a/src/lib/json_server.cc +++ b/src/lib/json_server.cc @@ -19,12 +19,12 @@ */ -#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> @@ -32,14 +32,15 @@ #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); } diff --git a/src/lib/writer.cc b/src/lib/writer.cc index d85be9eff..4596fde05 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -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 (); } diff --git a/src/lib/zipper.cc b/src/lib/zipper.cc index 2c334dc94..2a0723278 100644 --- a/src/lib/zipper.cc +++ b/src/lib/zipper.cc @@ -19,17 +19,18 @@ */ -#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; } |
