summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-04-14 16:05:59 +0200
committerCarl Hetherington <cth@carlh.net>2023-04-14 16:05:59 +0200
commit7b96b3ceec5d14874628cd8b9cb7a827d266b2f4 (patch)
treeaaca321f02a8061e69b848ea8c1717b7305ef6a4 /src
parent2c4dcc782d1db5422e9ccefee8ab8fd3639ea064 (diff)
Replace slightly weird add_font_assets() API.
Diffstat (limited to 'src')
-rw-r--r--src/combine.cc2
-rw-r--r--src/dcp.cc2
-rw-r--r--src/interop_subtitle_asset.cc16
-rw-r--r--src/interop_subtitle_asset.h4
-rw-r--r--src/util.h8
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<InteropSubtitleAsset>(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<shared_ptr<Asset>> assets)
}
-void
-InteropSubtitleAsset::add_font_assets (vector<shared_ptr<Asset>>& assets)
+vector<shared_ptr<Asset>>
+InteropSubtitleAsset::font_assets()
{
+ vector<shared_ptr<Asset>> assets;
for (auto const& i: _fonts) {
DCP_ASSERT (i.file);
- assets.push_back (make_shared<FontAsset>(i.uuid, i.file.get()));
+ assets.push_back(make_shared<FontAsset>(i.uuid, i.file.get()));
}
+ return assets;
}
-void
-InteropSubtitleAsset::add_font_assets(vector<shared_ptr<const Asset>>& assets)
+vector<shared_ptr<const Asset>>
+InteropSubtitleAsset::font_assets() const
{
+ vector<shared_ptr<const Asset>> assets;
for (auto const& i: _fonts) {
DCP_ASSERT (i.file);
- assets.push_back (make_shared<FontAsset>(i.uuid, i.file.get()));
+ assets.push_back(make_shared<const FontAsset>(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<std::shared_ptr<Asset>> assets);
- void add_font_assets (std::vector<std::shared_ptr<Asset>>& assets);
- void add_font_assets(std::vector<std::shared_ptr<const Asset>>& assets);
void set_font_file (std::string load_id, boost::filesystem::path file);
+ std::vector<std::shared_ptr<Asset>> font_assets();
+ std::vector<std::shared_ptr<const Asset>> font_assets() const;
/** @return the <LoadFont> 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 <class From, class To>
+void
+add_to_container(To& container, From source)
+{
+ std::copy(source.begin(), source.end(), std::back_inserter(container));
+}
+
+
}