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 | |
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
-rw-r--r-- | lib/jsonParse-persistence.cpp (renamed from lib/jsonParse-persistance.cpp) | 28 | ||||
-rw-r--r-- | lib/jsonParse-persistence.h (renamed from lib/jsonParse-persistance.h) | 6 | ||||
-rw-r--r-- | lib/persistence.cpp (renamed from lib/persistance.cpp) | 4 | ||||
-rw-r--r-- | lib/persistence.h (renamed from lib/persistance.h) | 12 | ||||
-rw-r--r-- | test/Jamfile.jam | 2 | ||||
-rw-r--r-- | test/test-persistence.cpp (renamed from test/test-persistance.cpp) | 22 |
6 files changed, 37 insertions, 37 deletions
diff --git a/lib/jsonParse-persistance.cpp b/lib/jsonParse-persistence.cpp index 100fa5c..5b3314e 100644 --- a/lib/jsonParse-persistance.cpp +++ b/lib/jsonParse-persistence.cpp @@ -1,8 +1,8 @@ -#include "jsonParse-persistance.h" +#include "jsonParse-persistence.h" -namespace Persistanace { +namespace Persistence { void - JsonParsePersistance::loadState(std::istream & in) + JsonParsePersistence::loadState(std::istream & in) { this->switch_streams(&in, nullptr); yy_push_state(0); @@ -10,58 +10,58 @@ namespace Persistanace { } void - JsonParsePersistance::beginObject() + JsonParsePersistence::beginObject() { current()->beforeValue(stk); current()->beginObject(stk); } void - JsonParsePersistance::beginArray() + JsonParsePersistence::beginArray() { current()->beforeValue(stk); current()->beginArray(stk); } void - JsonParsePersistance::pushBoolean(bool value) + JsonParsePersistence::pushBoolean(bool value) { pushValue(value); } void - JsonParsePersistance::pushNumber(float value) + JsonParsePersistence::pushNumber(float value) { pushValue(value); } void - JsonParsePersistance::pushNull() + JsonParsePersistence::pushNull() { pushValue(nullptr); } void - JsonParsePersistance::pushText(std::string && value) + JsonParsePersistence::pushText(std::string && value) { pushValue(value); } void - JsonParsePersistance::pushKey(std::string && k) + JsonParsePersistence::pushKey(std::string && k) { stk.push(current()->select(k)); } void - JsonParsePersistance::endArray() + JsonParsePersistence::endArray() { stk.pop(); stk.pop(); } void - JsonParsePersistance::endObject() + JsonParsePersistence::endObject() { current()->endObject(stk); current()->endObject(stk); @@ -69,7 +69,7 @@ namespace Persistanace { template<typename T> inline void - JsonParsePersistance::pushValue(T && value) + JsonParsePersistence::pushValue(T && value) { current()->beforeValue(stk); current()->setValue(value); @@ -77,7 +77,7 @@ namespace Persistanace { } inline SelectionPtr & - JsonParsePersistance::current() + JsonParsePersistence::current() { return stk.top(); } diff --git a/lib/jsonParse-persistance.h b/lib/jsonParse-persistence.h index 37483bc..6449f7b 100644 --- a/lib/jsonParse-persistance.h +++ b/lib/jsonParse-persistence.h @@ -2,14 +2,14 @@ #define JSONPARSE_PERSISTANCE #include "jsonParse.h" // IWYU pragma: export -#include "persistance.h" // IWYU pragma: export +#include "persistence.h" // IWYU pragma: export #include <functional> #include <iosfwd> #include <memory> #include <string> -namespace Persistanace { - class JsonParsePersistance : public json::jsonParser { +namespace Persistence { + class JsonParsePersistence : public json::jsonParser { public: template<typename T> inline T diff --git a/lib/persistance.cpp b/lib/persistence.cpp index 204e8f0..5744cd7 100644 --- a/lib/persistance.cpp +++ b/lib/persistence.cpp @@ -1,7 +1,7 @@ -#include "persistance.h" +#include "persistence.h" #include <map> -namespace Persistanace { +namespace Persistence { using Factories = std::pair<std::function<std::unique_ptr<Persistable>()>, std::function<std::shared_ptr<Persistable>()>>; using NamedTypeFactories = std::map<std::string_view, Factories>; diff --git a/lib/persistance.h b/lib/persistence.h index c64d4ec..ed21ec8 100644 --- a/lib/persistance.h +++ b/lib/persistence.h @@ -18,7 +18,7 @@ namespace glm { template<glm::length_t L, typename T, glm::qualifier Q> struct vec; } -namespace Persistanace { +namespace Persistence { struct Selection; using SelectionPtr = std::unique_ptr<Selection>; using Stack = std::stack<SelectionPtr>; @@ -75,7 +75,7 @@ namespace Persistanace { } }; - struct PersistanceStore { + struct PersistenceStore { template<typename T> inline bool persistType() const; template<typename T> @@ -144,7 +144,7 @@ namespace Persistanace { virtual ~Persistable() = default; DEFAULT_MOVE_COPY(Persistable); - virtual bool persist(PersistanceStore & store) = 0; + virtual bool persist(PersistenceStore & store) = 0; template<typename T> constexpr static auto @@ -171,7 +171,7 @@ namespace Persistanace { template<typename T> inline bool - PersistanceStore::persistType() const + PersistenceStore::persistType() const { if constexpr (!std::is_abstract_v<T>) { [[maybe_unused]] constexpr auto f = &Persistable::addFactory<T>; @@ -216,7 +216,7 @@ namespace Persistanace { this->v = std::make_unique<T>(); } } - PersistanceStore ps {mbr}; + PersistenceStore ps {mbr}; if (this->v->persist(ps)) { throw std::runtime_error("cannot find member: " + mbr); } @@ -314,7 +314,7 @@ namespace Persistanace { this->v = std::make_shared<T>(); } } - PersistanceStore ps {mbr}; + PersistenceStore ps {mbr}; if (this->v->persist(ps)) { throw std::runtime_error("cannot find member: " + mbr); } diff --git a/test/Jamfile.jam b/test/Jamfile.jam index cfa1f21..2c09b8a 100644 --- a/test/Jamfile.jam +++ b/test/Jamfile.jam @@ -19,4 +19,4 @@ run test-collection.cpp ; run test-obj.cpp ; run test-maths.cpp ; run test-network.cpp ; -run test-persistance.cpp : -- : [ sequence.insertion-sort [ glob fixtures/json/*.json ] ] ; +run test-persistence.cpp : -- : [ sequence.insertion-sort [ glob fixtures/json/*.json ] ] ; diff --git a/test/test-persistance.cpp b/test/test-persistence.cpp index 2c06c48..d5910e9 100644 --- a/test/test-persistance.cpp +++ b/test/test-persistence.cpp @@ -1,20 +1,20 @@ -#define BOOST_TEST_MODULE test_persistance +#define BOOST_TEST_MODULE test_persistence #include <boost/test/unit_test.hpp> #include <glm/glm.hpp> #include <iosfwd> -#include <jsonParse-persistance.h> +#include <jsonParse-persistence.h> #include <memory> #include <stdexcept> #include <string> #include <vector> -struct AbsObject : public Persistanace::Persistable { +struct AbsObject : public Persistence::Persistable { std::string base; bool - persist(Persistanace::PersistanceStore & store) override + persist(Persistence::PersistenceStore & store) override { return STORE_TYPE && STORE_MEMBER(base); } @@ -26,7 +26,7 @@ struct SubObject : public AbsObject { std::string sub; bool - persist(Persistanace::PersistanceStore & store) override + persist(Persistence::PersistenceStore & store) override { return AbsObject::persist(store) && STORE_TYPE && STORE_MEMBER(sub); } @@ -37,7 +37,7 @@ struct SubObject : public AbsObject { } }; -struct TestObject : public Persistanace::Persistable { +struct TestObject : public Persistence::Persistable { TestObject() = default; float flt {}; @@ -52,7 +52,7 @@ struct TestObject : public Persistanace::Persistable { std::vector<std::unique_ptr<TestObject>> vptr; bool - persist(Persistanace::PersistanceStore & store) override + persist(Persistence::PersistenceStore & store) override { return STORE_TYPE && STORE_MEMBER(flt) && STORE_MEMBER(str) && STORE_MEMBER(bl) && STORE_MEMBER(pos) && STORE_MEMBER(flts) && STORE_MEMBER(poss) && STORE_MEMBER(nest) && STORE_MEMBER(ptr) @@ -60,7 +60,7 @@ struct TestObject : public Persistanace::Persistable { } }; -struct JPP : public Persistanace::JsonParsePersistance { +struct JPP : public Persistence::JsonParsePersistence { template<typename T> T load_json(const char * path) @@ -68,7 +68,7 @@ struct JPP : public Persistanace::JsonParsePersistance { BOOST_TEST_CONTEXT(path) { std::ifstream ss {path}; auto to = loadState<T>(ss); - Persistanace::sharedObjects.clear(); + Persistence::sharedObjects.clear(); BOOST_CHECK(stk.empty()); BOOST_REQUIRE(to); return to; @@ -179,14 +179,14 @@ BOOST_FIXTURE_TEST_CASE(load_vector_ptr, JPP) BOOST_CHECK(to->vptr.at(3)->str.empty()); } -struct SharedTestObject : public Persistanace::Persistable { +struct SharedTestObject : public Persistence::Persistable { SharedTestObject() = default; std::shared_ptr<AbsObject> sptr; std::shared_ptr<SubObject> ssptr; bool - persist(Persistanace::PersistanceStore & store) override + persist(Persistence::PersistenceStore & store) override { return STORE_TYPE && STORE_MEMBER(sptr) && STORE_MEMBER(ssptr); } |