summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cache.h3
-rw-r--r--lib/jsonParse-persistence.cpp9
-rw-r--r--lib/jsonParse.impl.cpp20
-rw-r--r--lib/maths.cpp4
-rw-r--r--lib/maths.h6
-rw-r--r--lib/persistence.h13
-rw-r--r--lib/ptr.hpp4
7 files changed, 37 insertions, 22 deletions
diff --git a/lib/cache.h b/lib/cache.h
index 48b9c55..2a6e3e5 100644
--- a/lib/cache.h
+++ b/lib/cache.h
@@ -7,6 +7,9 @@
template<typename Obj> class Cache {
public:
using Ptr = std::shared_ptr<Obj>;
+
+ virtual ~Cache() = default;
+
[[nodiscard]] Ptr
get(const std::string & key)
{
diff --git a/lib/jsonParse-persistence.cpp b/lib/jsonParse-persistence.cpp
index 5062796..a9b9a83 100644
--- a/lib/jsonParse-persistence.cpp
+++ b/lib/jsonParse-persistence.cpp
@@ -97,7 +97,7 @@ namespace Persistence {
wrh(std::ostream & strm, char ch)
{
using namespace std::literals;
- strm << R"(\u)"sv << std::setw(4) << std::hex << (int)ch << std::setw(1);
+ strm << R"(\u)"sv << std::setw(4) << std::hex << static_cast<int>(ch) << std::setw(1);
}
static inline void
wre(std::ostream & strm, char e)
@@ -116,7 +116,7 @@ namespace Persistence {
static constexpr OutFuncs outFuncs {[]() {
OutFuncs outFuncs;
outFuncs.fill(&wrv);
- for (int x = 0; x < 0x20; x += 1) {
+ for (auto x = 0U; x < 0x20U; x += 1) {
outFuncs[x] = &wrh;
}
outFuncs['\"'] = &wre<'"'>;
@@ -160,7 +160,8 @@ namespace Persistence {
strm << value;
}
- void JsonWritePersistence::pushValue(std::nullptr_t) const
+ void
+ JsonWritePersistence::pushValue(std::nullptr_t) const
{
strm << "null";
}
@@ -170,7 +171,7 @@ namespace Persistence {
{
strm << '"';
std::for_each(value.begin(), value.end(), [this](char ch) {
- outFuncs[(unsigned char)ch](strm, ch);
+ outFuncs[static_cast<unsigned char>(ch)](strm, ch);
});
strm << '"';
}
diff --git a/lib/jsonParse.impl.cpp b/lib/jsonParse.impl.cpp
index 0913847..ce1020f 100644
--- a/lib/jsonParse.impl.cpp
+++ b/lib/jsonParse.impl.cpp
@@ -19,24 +19,24 @@ void
json::jsonParser::appendEscape(unsigned long cp, std::string & str)
{
if (cp <= 0x7F) {
- str += (char)cp;
+ str += static_cast<char>(cp);
}
else if (cp <= 0x7FF) {
- str += char((cp >> 6) + 192);
- str += char((cp & 63) + 128);
+ str += static_cast<char>((cp >> 6) + 192);
+ str += static_cast<char>((cp & 63) + 128);
}
else if ((0xd800 <= cp && cp <= 0xdfff) || cp > 0x10FFFF) {
throw std::range_error("Invalid UTF-8 sequence");
}
else if (cp <= 0xFFFF) {
- str += char((cp >> 12) + 224);
- str += char(((cp >> 6) & 63) + 128);
- str += char((cp & 63) + 128);
+ str += static_cast<char>((cp >> 12) + 224);
+ str += static_cast<char>(((cp >> 6) & 63) + 128);
+ str += static_cast<char>((cp & 63) + 128);
}
else {
- str += char((cp >> 18) + 240);
- str += char(((cp >> 12) & 63) + 128);
- str += char(((cp >> 6) & 63) + 128);
- str += char((cp & 63) + 128);
+ str += static_cast<char>((cp >> 18) + 240);
+ str += static_cast<char>(((cp >> 12) & 63) + 128);
+ str += static_cast<char>(((cp >> 6) & 63) + 128);
+ str += static_cast<char>((cp & 63) + 128);
}
}
diff --git a/lib/maths.cpp b/lib/maths.cpp
index e894d02..4d9f8d4 100644
--- a/lib/maths.cpp
+++ b/lib/maths.cpp
@@ -173,10 +173,10 @@ find_arcs_radius(glm::vec2 start, glm::vec2 ad, glm::vec2 end, glm::vec2 bd)
float operator"" _mph(const long double v)
{
- return mph_to_ms(v);
+ return static_cast<float>(mph_to_ms(v));
}
float operator"" _kph(const long double v)
{
- return kph_to_ms(v);
+ return static_cast<float>(kph_to_ms(v));
}
diff --git a/lib/maths.h b/lib/maths.h
index 285c69a..18332b7 100644
--- a/lib/maths.h
+++ b/lib/maths.h
@@ -69,7 +69,7 @@ template<typename R = float, typename Ta, typename Tb>
inline constexpr auto
rdiv(Ta a, Tb b)
{
- return ((R)a / (R)b);
+ return (static_cast<R>(a) / static_cast<R>(b));
}
constexpr inline glm::vec2
@@ -105,14 +105,14 @@ float find_arcs_radius(glm::vec2 start, glm::vec2 ad, glm::vec2 end, glm::vec2 b
// Conversions
template<typename T>
-inline constexpr float
+inline constexpr auto
mph_to_ms(T v)
{
return v / 2.237;
}
template<typename T>
-inline constexpr float
+inline constexpr auto
kph_to_ms(T v)
{
return v / 3.6;
diff --git a/lib/persistence.h b/lib/persistence.h
index 252afde..0faa24d 100644
--- a/lib/persistence.h
+++ b/lib/persistence.h
@@ -26,6 +26,10 @@ namespace Persistence {
using Stack = std::stack<SelectionPtr>;
struct Writer {
+ Writer() = default;
+ virtual ~Writer() = default;
+ DEFAULT_MOVE_COPY(Writer);
+
virtual void beginObject() const = 0;
virtual void beginArray() const = 0;
virtual void pushValue(bool value) const = 0;
@@ -85,6 +89,7 @@ namespace Persistence {
template<typename T> struct SelectionT : public SelectionV<T> {
using SelectionV<T>::SelectionV;
+ using Selection::setValue;
using P = std::conditional_t<std::is_scalar_v<T>, T, T &&>;
void
@@ -102,6 +107,8 @@ namespace Persistence {
struct Persistable;
struct PersistenceStore {
+ virtual ~PersistenceStore() = default;
+
template<typename T> [[nodiscard]] inline bool persistType(const T * const, const std::type_info & ti);
enum class NameAction { Push, HandleAndContinue, Ignore };
@@ -292,6 +299,7 @@ namespace Persistence {
struct SelectionObj : public SelectionV<Ptr> {
struct MakeObjectByTypeName : public SelectionV<Ptr> {
using SelectionV<Ptr>::SelectionV;
+ using Selection::setValue;
void
setValue(std::string && type) override
@@ -316,6 +324,7 @@ namespace Persistence {
struct RememberObjectById : public SelectionV<Ptr> {
using SelectionV<Ptr>::SelectionV;
+ using Selection::setValue;
void
setValue(std::string && id) override
@@ -383,8 +392,10 @@ namespace Persistence {
}
using SelectionV<Ptr>::SelectionV;
+ using Selection::setValue;
- void setValue(std::nullptr_t) override
+ void
+ setValue(std::nullptr_t) override
{
this->v.reset();
}
diff --git a/lib/ptr.hpp b/lib/ptr.hpp
index b92b63e..0b00285 100644
--- a/lib/ptr.hpp
+++ b/lib/ptr.hpp
@@ -16,9 +16,9 @@ public:
template<typename... Args, typename... Params>
static auto
- create(Obj * (*factory)(Args...), void (*deleter)(Obj *), Params &&... params)
+ create(Obj * (*factory)(Params...), void (*deleter)(Obj *), Args &&... args)
{
- return wrapped_ptr<Obj> {factory(std::forward<Params>(params)...), deleter};
+ return wrapped_ptr<Obj> {factory(std::forward<Args>(args)...), deleter};
}
};