summaryrefslogtreecommitdiff
path: root/src/lib/spl.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-02-02 20:48:48 +0100
committerCarl Hetherington <cth@carlh.net>2025-02-02 21:24:31 +0100
commit676be00ff2d50c399eeeef3802099ec6a5065f52 (patch)
tree9677c1869955104880b6347de8acb120d2c19bf6 /src/lib/spl.cc
parent4d2cc8cf69cdbc35675ffbf6911ac83564418f43 (diff)
Add SPL::insert().
Diffstat (limited to 'src/lib/spl.cc')
-rw-r--r--src/lib/spl.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/spl.cc b/src/lib/spl.cc
index 615dd916a..3897709db 100644
--- a/src/lib/spl.cc
+++ b/src/lib/spl.cc
@@ -33,6 +33,7 @@ LIBDCP_ENABLE_WARNINGS
using std::cout;
using std::string;
using std::shared_ptr;
+using boost::optional;
void
@@ -67,3 +68,20 @@ SPL::write (boost::filesystem::path path) const
}
doc.write_to_file_formatted (path.string());
}
+
+
+void
+SPL::insert(SPLEntry entry, optional<string> before_id)
+{
+ if (before_id) {
+ auto iter = std::find_if(_spl.begin(), _spl.end(), [before_id](SPLEntry const& e) {
+ return e.id == before_id;
+ });
+ if (iter != _spl.end()) {
+ _spl.insert(iter, entry);
+ }
+ } else {
+ _spl.push_back(entry);
+ }
+}
+