diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-04-30 01:03:42 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-11-07 16:41:37 +0000 |
commit | a31858d29048735b812d385f75db4ed6a6a94556 (patch) | |
tree | fffd08d958c4970be617b3ad36905b54f2445bad /lib/jsonParse-persistence.cpp | |
parent | Implement shared_ptr support (diff) | |
download | ilt-a31858d29048735b812d385f75db4ed6a6a94556.tar.bz2 ilt-a31858d29048735b812d385f75db4ed6a6a94556.tar.xz ilt-a31858d29048735b812d385f75db4ed6a6a94556.zip |
Fix the fact I've been spelling persistence wrong this whole time
Diffstat (limited to 'lib/jsonParse-persistence.cpp')
-rw-r--r-- | lib/jsonParse-persistence.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/lib/jsonParse-persistence.cpp b/lib/jsonParse-persistence.cpp new file mode 100644 index 0000000..5b3314e --- /dev/null +++ b/lib/jsonParse-persistence.cpp @@ -0,0 +1,84 @@ +#include "jsonParse-persistence.h" + +namespace Persistence { + void + JsonParsePersistence::loadState(std::istream & in) + { + this->switch_streams(&in, nullptr); + yy_push_state(0); + yylex(); + } + + void + JsonParsePersistence::beginObject() + { + current()->beforeValue(stk); + current()->beginObject(stk); + } + + void + JsonParsePersistence::beginArray() + { + current()->beforeValue(stk); + current()->beginArray(stk); + } + + void + JsonParsePersistence::pushBoolean(bool value) + { + pushValue(value); + } + + void + JsonParsePersistence::pushNumber(float value) + { + pushValue(value); + } + + void + JsonParsePersistence::pushNull() + { + pushValue(nullptr); + } + + void + JsonParsePersistence::pushText(std::string && value) + { + pushValue(value); + } + + void + JsonParsePersistence::pushKey(std::string && k) + { + stk.push(current()->select(k)); + } + + void + JsonParsePersistence::endArray() + { + stk.pop(); + stk.pop(); + } + + void + JsonParsePersistence::endObject() + { + current()->endObject(stk); + current()->endObject(stk); + } + + template<typename T> + inline void + JsonParsePersistence::pushValue(T && value) + { + current()->beforeValue(stk); + current()->setValue(value); + stk.pop(); + } + + inline SelectionPtr & + JsonParsePersistence::current() + { + return stk.top(); + } +} |