diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-03-05 01:59:16 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-03-05 01:59:16 +0000 |
commit | d4c073a18adaed73973f34c6c39fc15664d9211d (patch) | |
tree | 44536af3af0284ab75eae79ef81a5e4452019269 /lib/saxParse-persistence.h | |
parent | Add helper operator to perform vec3*mat4 and perspective divide (diff) | |
parent | Remove old hard coded asset factory test, run entirely from XML load and rend... (diff) | |
download | ilt-d4c073a18adaed73973f34c6c39fc15664d9211d.tar.bz2 ilt-d4c073a18adaed73973f34c6c39fc15664d9211d.tar.xz ilt-d4c073a18adaed73973f34c6c39fc15664d9211d.zip |
Merge branch 'model-factory'
Diffstat (limited to 'lib/saxParse-persistence.h')
-rw-r--r-- | lib/saxParse-persistence.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/saxParse-persistence.h b/lib/saxParse-persistence.h new file mode 100644 index 0000000..6043b25 --- /dev/null +++ b/lib/saxParse-persistence.h @@ -0,0 +1,40 @@ +#pragma once + +#include "persistence.h" +#include "saxParse.h" +#include <cstdio> +#include <mxml.h> + +namespace Persistence { + class SAXParsePersistence : public SAXParse, ParseBase { + private: + template<typename T> struct Root : public Persistable { + T t {}; + bool + persist(PersistenceStore & store) + { + return STORE_TYPE && STORE_NAME_MEMBER("ilt", t); + } + }; + + void loadStateInternal(FILE * in); + + public: + template<typename T> + auto + loadState(FILE * in) + { + std::unique_ptr<Root<T>> root; + stk.push(std::make_unique<SelectionT<decltype(root)>>(std::ref(root))); + loadStateInternal(in); + return std::move(root->t); + } + + protected: + void elementOpen(mxml_node_t * n) override; + void elementClose(mxml_node_t *) override; + void data(mxml_node_t *) override; + void directive(mxml_node_t *) override; + void cdata(mxml_node_t *) override; + }; +} |