summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/jsonParse-persistence.cpp4
-rw-r--r--lib/persistence.cpp9
-rw-r--r--lib/persistence.h20
3 files changed, 16 insertions, 17 deletions
diff --git a/lib/jsonParse-persistence.cpp b/lib/jsonParse-persistence.cpp
index 5b3314e..7c00773 100644
--- a/lib/jsonParse-persistence.cpp
+++ b/lib/jsonParse-persistence.cpp
@@ -44,7 +44,7 @@ namespace Persistence {
void
JsonParsePersistence::pushText(std::string && value)
{
- pushValue(value);
+ pushValue(std::move(value));
}
void
@@ -72,7 +72,7 @@ namespace Persistence {
JsonParsePersistence::pushValue(T && value)
{
current()->beforeValue(stk);
- current()->setValue(value);
+ current()->setValue(std::forward<T>(value));
stk.pop();
}
diff --git a/lib/persistence.cpp b/lib/persistence.cpp
index 15391ad..c4ee142 100644
--- a/lib/persistence.cpp
+++ b/lib/persistence.cpp
@@ -27,25 +27,24 @@ namespace Persistence {
}
void
- Selection::setValue(float &)
+ Selection::setValue(float)
{
throw std::runtime_error("Unexpected float");
}
void
- Selection::setValue(bool &)
+ Selection::setValue(bool)
{
throw std::runtime_error("Unexpected bool");
}
- void
- Selection::setValue(const std::nullptr_t &)
+ void Selection::setValue(std::nullptr_t)
{
throw std::runtime_error("Unexpected null");
}
void
- Selection::setValue(std::string &)
+ Selection::setValue(std::string &&)
{
throw std::runtime_error("Unexpected string");
}
diff --git a/lib/persistence.h b/lib/persistence.h
index e8e3415..5d5fb0f 100644
--- a/lib/persistence.h
+++ b/lib/persistence.h
@@ -28,10 +28,10 @@ namespace Persistence {
virtual ~Selection() = default;
DEFAULT_MOVE_COPY(Selection);
- virtual void setValue(float &);
- virtual void setValue(bool &);
- virtual void setValue(const std::nullptr_t &);
- virtual void setValue(std::string &);
+ virtual void setValue(float);
+ virtual void setValue(bool);
+ virtual void setValue(std::nullptr_t);
+ virtual void setValue(std::string &&);
virtual void beginArray(Stack &);
virtual void beginObject(Stack &);
virtual void endObject(Stack &);
@@ -67,9 +67,10 @@ namespace Persistence {
template<typename T> struct SelectionT : public SelectionV<T> {
using SelectionV<T>::SelectionV;
+ using P = std::conditional_t<std::is_scalar_v<T>, T, T &&>;
void
- setValue(T & evalue) override
+ setValue(P evalue) override
{
std::swap(this->v, evalue);
}
@@ -190,7 +191,7 @@ namespace Persistence {
using SelectionV<Ptr>::SelectionV;
void
- setValue(std::string & type) override
+ setValue(std::string && type) override
{
if constexpr (shared) {
auto no = Persistable::callSharedFactory(type);
@@ -214,7 +215,7 @@ namespace Persistence {
using SelectionV<Ptr>::SelectionV;
void
- setValue(std::string & id) override
+ setValue(std::string && id) override
{
sharedObjects.emplace(id, this->v);
}
@@ -271,8 +272,7 @@ namespace Persistence {
using SelectionV<Ptr>::SelectionV;
- void
- setValue(const std::nullptr_t &) override
+ void setValue(std::nullptr_t) override
{
this->v.reset();
}
@@ -298,7 +298,7 @@ namespace Persistence {
using SelectionPtrBase<std::shared_ptr<T>, true>::SelectionPtrBase;
void
- setValue(std::string & id) override
+ setValue(std::string && id) override
{
if (auto teo = std::dynamic_pointer_cast<T>(sharedObjects.at(id))) {
this->v = std::move(teo);