From 7b96b3ceec5d14874628cd8b9cb7a827d266b2f4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 14 Apr 2023 16:05:59 +0200 Subject: [PATCH] Replace slightly weird add_font_assets() API. --- src/combine.cc | 2 +- src/dcp.cc | 2 +- src/interop_subtitle_asset.cc | 16 ++++++++++------ src/interop_subtitle_asset.h | 4 ++-- src/util.h | 8 ++++++++ 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/combine.cc b/src/combine.cc index 86762dda..b728298a 100644 --- a/src/combine.cc +++ b/src/combine.cc @@ -155,7 +155,7 @@ dcp::combine ( DCP_ASSERT (file); path new_path = make_unique(output / file->filename()); sub->write (new_path); - sub->add_font_assets(assets); + add_to_container(assets, sub->font_assets()); } assets.push_back (j); diff --git a/src/dcp.cc b/src/dcp.cc index a73ebbf5..2c327b74 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -497,7 +497,7 @@ DCP::assets (bool ignore_unresolved) const /* More Interop special-casing */ auto sub = dynamic_pointer_cast(o); if (sub) { - sub->add_font_assets (assets); + add_to_container(assets, sub->font_assets()); } } } diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc index 4bf3958f..8fb115a7 100644 --- a/src/interop_subtitle_asset.cc +++ b/src/interop_subtitle_asset.cc @@ -253,23 +253,27 @@ InteropSubtitleAsset::resolve_fonts (vector> assets) } -void -InteropSubtitleAsset::add_font_assets (vector>& assets) +vector> +InteropSubtitleAsset::font_assets() { + vector> assets; for (auto const& i: _fonts) { DCP_ASSERT (i.file); - assets.push_back (make_shared(i.uuid, i.file.get())); + assets.push_back(make_shared(i.uuid, i.file.get())); } + return assets; } -void -InteropSubtitleAsset::add_font_assets(vector>& assets) +vector> +InteropSubtitleAsset::font_assets() const { + vector> assets; for (auto const& i: _fonts) { DCP_ASSERT (i.file); - assets.push_back (make_shared(i.uuid, i.file.get())); + assets.push_back(make_shared(i.uuid, i.file.get())); } + return assets; } diff --git a/src/interop_subtitle_asset.h b/src/interop_subtitle_asset.h index 72d862ad..3005c8fc 100644 --- a/src/interop_subtitle_asset.h +++ b/src/interop_subtitle_asset.h @@ -82,9 +82,9 @@ public: void write (boost::filesystem::path path) const override; void resolve_fonts (std::vector> assets); - void add_font_assets (std::vector>& assets); - void add_font_assets(std::vector>& assets); void set_font_file (std::string load_id, boost::filesystem::path file); + std::vector> font_assets(); + std::vector> font_assets() const; /** @return the IDs of fonts for which we have not (yet) found a font asset. * This could be because resolve_fonts() has not yet been called, or because there is diff --git a/src/util.h b/src/util.h index 8261a812..8338e7cc 100644 --- a/src/util.h +++ b/src/util.h @@ -155,6 +155,14 @@ private: }; +template +void +add_to_container(To& container, From source) +{ + std::copy(source.begin(), source.end(), std::back_inserter(container)); +} + + } -- 2.30.2