summaryrefslogtreecommitdiff
path: root/lib/jsonParse-persistence.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/jsonParse-persistence.h')
-rw-r--r--lib/jsonParse-persistence.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/jsonParse-persistence.h b/lib/jsonParse-persistence.h
index 6449f7b..edb5305 100644
--- a/lib/jsonParse-persistence.h
+++ b/lib/jsonParse-persistence.h
@@ -7,6 +7,7 @@
#include <iosfwd>
#include <memory>
#include <string>
+#include <string_view>
namespace Persistence {
class JsonParsePersistence : public json::jsonParser {
@@ -39,6 +40,33 @@ namespace Persistence {
template<typename T> inline void pushValue(T && value);
inline SelectionPtr & current();
};
+
+ class JsonWritePersistence : public Writer {
+ public:
+ explicit JsonWritePersistence(std::ostream & s);
+
+ template<typename T>
+ inline void
+ saveState(T & t) const
+ {
+ SelectionT<T> {t}.write(*this);
+ }
+
+ protected:
+ void beginObject() const override;
+ void beginArray() const override;
+ void pushValue(bool value) const override;
+ void pushValue(float value) const override;
+ void pushValue(std::nullptr_t) const override;
+ void pushValue(const std::string_view value) const override;
+ void nextValue() const override;
+ void pushKey(const std::string_view k) const override;
+ void endArray() const override;
+ void endObject() const override;
+
+ private:
+ std::ostream & strm;
+ };
}
#endif