summaryrefslogtreecommitdiff
path: root/lib/jsonParse-persistance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/jsonParse-persistance.cpp')
-rw-r--r--lib/jsonParse-persistance.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/lib/jsonParse-persistance.cpp b/lib/jsonParse-persistance.cpp
new file mode 100644
index 0000000..89887da
--- /dev/null
+++ b/lib/jsonParse-persistance.cpp
@@ -0,0 +1,81 @@
+#include "jsonParse-persistance.h"
+
+namespace Persistanace {
+ JsonParsePersistance::JsonParsePersistance(std::istream & in) : json::jsonParser {&in} { }
+
+ void
+ JsonParsePersistance::loadState()
+ {
+ yy_push_state(0);
+ yylex();
+ }
+
+ void
+ JsonParsePersistance::BeginObject()
+ {
+ stk.push(current()->BeginObject());
+ }
+
+ void
+ JsonParsePersistance::BeginArray()
+ {
+ current()->BeginArray(stk);
+ }
+
+ void
+ JsonParsePersistance::PushBoolean(bool value)
+ {
+ PushValue(value);
+ }
+
+ void
+ JsonParsePersistance::PushNumber(float value)
+ {
+ PushValue(value);
+ }
+
+ void
+ JsonParsePersistance::PushNull()
+ {
+ PushValue(nullptr);
+ }
+
+ void
+ JsonParsePersistance::PushText(std::string && value)
+ {
+ PushValue(value);
+ }
+
+ void
+ JsonParsePersistance::PushKey(std::string && k)
+ {
+ stk.push(current()->select(k));
+ }
+
+ void
+ JsonParsePersistance::EndArray()
+ {
+ stk.pop();
+ }
+
+ void
+ JsonParsePersistance::EndObject()
+ {
+ stk.pop();
+ }
+
+ template<typename T>
+ inline void
+ JsonParsePersistance::PushValue(T && value)
+ {
+ current()->beforeValue(stk);
+ (*current())(value);
+ stk.pop();
+ }
+
+ inline SelectionPtr &
+ JsonParsePersistance::current()
+ {
+ return stk.top();
+ }
+}