diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-02-21 20:09:41 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-02-21 20:09:41 +0000 |
commit | f91e2ea8d9e30b1e62c4f8784fddfd4eb9578d2d (patch) | |
tree | fa0326b9d09687c79360cfbd738ce4e14ef0b1d3 /lib | |
parent | Rename ModelFactory to AssetFactory (diff) | |
download | ilt-f91e2ea8d9e30b1e62c4f8784fddfd4eb9578d2d.tar.bz2 ilt-f91e2ea8d9e30b1e62c4f8784fddfd4eb9578d2d.tar.xz ilt-f91e2ea8d9e30b1e62c4f8784fddfd4eb9578d2d.zip |
Move Appender in Persistence NS and simplify types
Diffstat (limited to 'lib')
-rw-r--r-- | lib/persistence.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/persistence.h b/lib/persistence.h index d55062a..5c8454c 100644 --- a/lib/persistence.h +++ b/lib/persistence.h @@ -273,6 +273,22 @@ namespace Persistence { Map & map; }; + template<typename Container, typename Type = typename Container::value_type> + struct Appender : public Persistence::SelectionT<Type> { + Appender(Container & c) : Persistence::SelectionT<Type> {s}, container {c} { } + using Persistence::SelectionT<Type>::SelectionT; + void + endObject(Persistence::Stack & stk) override + { + container.emplace_back(std::move(s)); + stk.pop(); + } + + private: + Type s; + Container & container; + }; + struct Persistable { Persistable() = default; virtual ~Persistable() = default; |