summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cache.h1
-rw-r--r--lib/collections.h3
-rw-r--r--lib/enumDetails.h6
-rw-r--r--lib/glArrays.h3
-rw-r--r--lib/glContainer.h6
-rw-r--r--lib/gl_traits.h12
-rw-r--r--lib/jsonParse-persistence.cpp3
-rw-r--r--lib/maths.cpp6
-rw-r--r--lib/persistence.cpp1
-rw-r--r--lib/persistence.h9
-rw-r--r--lib/ptr.h1
-rw-r--r--lib/resource.h1
-rw-r--r--lib/saxParse-persistence.h1
-rw-r--r--lib/stdTypeDefs.h4
-rw-r--r--lib/unicode.h2
-rw-r--r--lib/worker.h3
16 files changed, 59 insertions, 3 deletions
diff --git a/lib/cache.h b/lib/cache.h
index 2c3975b..f5fd227 100644
--- a/lib/cache.h
+++ b/lib/cache.h
@@ -35,4 +35,5 @@ public:
private:
std::map<Key, Ptr, std::less<>> cached;
};
+
// IWYU pragma: no_forward_declare Cache
diff --git a/lib/collections.h b/lib/collections.h
index 7d78ef9..943b986 100644
--- a/lib/collections.h
+++ b/lib/collections.h
@@ -149,11 +149,14 @@ template<typename T> struct pair_range {
{
return pair.first;
}
+
constexpr auto &
end() const noexcept
{
return pair.second;
}
+
const std::pair<T, T> & pair;
};
+
template<typename T> pair_range(std::pair<T, T>) -> pair_range<T>;
diff --git a/lib/enumDetails.h b/lib/enumDetails.h
index 5966be2..b6ff046 100644
--- a/lib/enumDetails.h
+++ b/lib/enumDetails.h
@@ -26,11 +26,13 @@ template<typename E> struct EnumTypeDetails : EnumDetailsBase {
protected:
#endif
constexpr static std::string_view SEARCH_TYPE {"E = "};
+
constexpr static auto
typeraw()
{
return std::string_view {__PRETTY_FUNCTION__};
};
+
constexpr static auto typeNameStart {typeraw().find(SEARCH_TYPE) + SEARCH_TYPE.length()};
constexpr static auto typeNameEnd {typeraw().find_first_of("];", typeNameStart)};
constexpr static auto typeNameLen {typeNameEnd - typeNameStart};
@@ -47,11 +49,13 @@ template<auto value> struct EnumValueDetails : public EnumTypeDetails<decltype(v
private:
#endif
using T = EnumTypeDetails<decltype(value)>;
+
constexpr static auto
raw()
{
return std::string_view {__PRETTY_FUNCTION__};
};
+
constexpr static auto nameStart {raw().find_last_of(": ") + 1};
constexpr static auto nameEnd {raw().find_first_of("];", nameStart)};
constexpr static auto nameLen {nameEnd - nameStart};
@@ -84,12 +88,14 @@ private:
return std::array {EnumValueDetails<static_cast<E>(n)>::valid...};
#pragma GCC diagnostic pop
}
+
template<auto... n>
constexpr static auto
get_values(std::integer_sequence<int, n...>)
{
return std::array {EnumValueDetails<static_cast<E>(n)>::raw_value...};
}
+
template<auto... n>
constexpr static auto
get_valueNames(std::integer_sequence<int, n...>)
diff --git a/lib/glArrays.h b/lib/glArrays.h
index 86385d9..787ea17 100644
--- a/lib/glArrays.h
+++ b/lib/glArrays.h
@@ -15,7 +15,8 @@ public:
CUSTOM_MOVE(glArraysBase);
// NOLINTNEXTLINE(hicpp-explicit-conversions)
- inline operator GLuint() const
+ inline
+ operator GLuint() const
{
static_assert(N == 1, "Implicit cast only if N == 1");
return ids.front();
diff --git a/lib/glContainer.h b/lib/glContainer.h
index 993170e..8177618 100644
--- a/lib/glContainer.h
+++ b/lib/glContainer.h
@@ -9,6 +9,7 @@
template<typename I, typename Direction> class basic_glContainer_iterator {
public:
explicit basic_glContainer_iterator(I * i) : i {i} { }
+
template<typename OtherI>
basic_glContainer_iterator(const basic_glContainer_iterator<OtherI, Direction> & other) : i {&*other}
{
@@ -20,17 +21,20 @@ public:
i = Direction {}(i, 1);
return *this;
}
+
auto
operator++(int) noexcept
{
return basic_glContainer_iterator<I, Direction> {std::exchange(i, Direction {}(i, 1))};
}
+
auto &
operator--() noexcept
{
i = Direction {}(i, -1);
return *this;
}
+
auto
operator--(int) noexcept
{
@@ -76,6 +80,7 @@ public:
{
return this->i == other.i;
}
+
[[nodiscard]] bool
operator!=(const basic_glContainer_iterator & other) const noexcept
{
@@ -87,6 +92,7 @@ public:
{
return i;
}
+
[[nodiscard]] auto &
operator*() const noexcept
{
diff --git a/lib/gl_traits.h b/lib/gl_traits.h
index a930eba..934b505 100644
--- a/lib/gl_traits.h
+++ b/lib/gl_traits.h
@@ -6,9 +6,11 @@
#include <glm/fwd.hpp>
template<typename T> struct gl_traits;
+
struct gl_traits_base {
static constexpr GLint size {1};
};
+
struct gl_traits_float : public gl_traits_base {
static constexpr auto vertexAttribFunc {
[](GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) -> GLuint {
@@ -16,6 +18,7 @@ struct gl_traits_float : public gl_traits_base {
return 1;
}};
};
+
struct gl_traits_longfloat : public gl_traits_base {
static constexpr auto vertexAttribFunc {
[](GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) -> GLuint {
@@ -23,6 +26,7 @@ struct gl_traits_longfloat : public gl_traits_base {
return 1;
}};
};
+
struct gl_traits_integer : public gl_traits_base {
static constexpr auto vertexAttribFunc {
[](GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) -> GLuint {
@@ -30,27 +34,35 @@ struct gl_traits_integer : public gl_traits_base {
return 1;
}};
};
+
template<> struct gl_traits<glm::f32> : public gl_traits_float {
static constexpr GLenum type {GL_FLOAT};
};
+
template<> struct gl_traits<glm::f64> : public gl_traits_longfloat {
static constexpr GLenum type {GL_DOUBLE};
};
+
template<> struct gl_traits<glm::int8> : public gl_traits_integer {
static constexpr GLenum type {GL_BYTE};
};
+
template<> struct gl_traits<glm::int16> : public gl_traits_integer {
static constexpr GLenum type {GL_SHORT};
};
+
template<> struct gl_traits<glm::int32> : public gl_traits_integer {
static constexpr GLenum type {GL_INT};
};
+
template<> struct gl_traits<glm::uint8> : public gl_traits_integer {
static constexpr GLenum type {GL_UNSIGNED_BYTE};
};
+
template<> struct gl_traits<glm::uint16> : public gl_traits_integer {
static constexpr GLenum type {GL_UNSIGNED_SHORT};
};
+
template<> struct gl_traits<glm::uint32> : public gl_traits_integer {
static constexpr GLenum type {GL_UNSIGNED_INT};
};
diff --git a/lib/jsonParse-persistence.cpp b/lib/jsonParse-persistence.cpp
index fe8bf8d..5c0011a 100644
--- a/lib/jsonParse-persistence.cpp
+++ b/lib/jsonParse-persistence.cpp
@@ -93,17 +93,20 @@ namespace Persistence {
{
strm.put(ch);
}
+
static inline void
wrh(std::ostream & strm, char ch)
{
using namespace std::literals;
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)
{
strm << '\\' << e;
}
+
template<char E>
static inline void
wre(std::ostream & strm, char)
diff --git a/lib/maths.cpp b/lib/maths.cpp
index b8dbd34..7594b59 100644
--- a/lib/maths.cpp
+++ b/lib/maths.cpp
@@ -177,12 +177,14 @@ find_arcs_radius(glm::vec2 start, glm::vec2 ad, glm::vec2 end, glm::vec2 bd)
/ (2 * (sq(X) - 2 * X * Z + sq(Z) + sq(Y) - 2 * Y * W + sq(W) - 4));
}
-float operator"" _mph(const long double v)
+float
+operator"" _mph(const long double v)
{
return static_cast<float>(mph_to_ms(v));
}
-float operator"" _kph(const long double v)
+float
+operator"" _kph(const long double v)
{
return static_cast<float>(kph_to_ms(v));
}
diff --git a/lib/persistence.cpp b/lib/persistence.cpp
index e22d74d..38e2ac6 100644
--- a/lib/persistence.cpp
+++ b/lib/persistence.cpp
@@ -167,6 +167,7 @@ namespace Persistence {
{
throw std::logic_error("Default write op shouldn't ever get called");
}
+
/// LCOV_EXCL_STOP
ParseBase::ParseBase() : sharedObjectsInstance {std::make_shared<SharedObjects>()}
diff --git a/lib/persistence.h b/lib/persistence.h
index 5d71d4c..92f3052 100644
--- a/lib/persistence.h
+++ b/lib/persistence.h
@@ -153,6 +153,7 @@ namespace Persistence {
};
struct Persistable;
+
struct PersistenceStore {
using SelectionFactory = std::function<SelectionPtr()>;
PersistenceStore() = default;
@@ -163,6 +164,7 @@ namespace Persistence {
enum class NameAction { Push, HandleAndContinue, Ignore };
using NameActionSelection = std::pair<NameAction, SelectionPtr>;
+
template<typename Helper, typename T>
[[nodiscard]] inline bool
persistValue(const std::string_view key, T & value)
@@ -267,6 +269,7 @@ namespace Persistence {
template<glm::length_t L, typename T, glm::qualifier Q>
struct SelectionT<glm::vec<L, T, Q>> : public SelectionT<std::span<T>> {
SelectionT(glm::vec<L, T, Q> & v) : SelectionT<std::span<T>> {spn}, spn {&v[0], L} { }
+
std::span<T> spn;
};
@@ -316,6 +319,7 @@ namespace Persistence {
MapByMember(Map & m) : Persistence::SelectionT<Type> {s}, map {m} { }
using Persistence::SelectionT<Type>::SelectionT;
+
void
endObject(Persistence::Stack & stk) override
{
@@ -332,7 +336,9 @@ namespace Persistence {
template<typename Container, typename Type = typename Container::value_type>
struct Appender : public Persistence::SelectionT<Type> {
Appender(Container & c) : Persistence::SelectionT<Type> {s}, container {c} { }
+
using Persistence::SelectionT<Type>::SelectionT;
+
void
endObject(Persistence::Stack & stk) override
{
@@ -407,6 +413,7 @@ namespace Persistence {
{
return std::dynamic_pointer_cast<T>(Persistence::ParseBase::sharedObjects.lock()->at(k));
}
+
template<typename... T>
static auto
emplaceShared(T &&... v)
@@ -421,6 +428,7 @@ namespace Persistence {
inline static thread_local SharedObjectsWPtr sharedObjects;
SharedObjectsPtr sharedObjectsInstance;
};
+
// TODO Move these
using SeenSharedObjects = std::map<void *, std::string>;
inline SeenSharedObjects seenSharedObjects;
@@ -428,6 +436,7 @@ namespace Persistence {
template<typename Ptr> struct SelectionPtrBase : public SelectionV<Ptr> {
static constexpr auto shared = std::is_copy_assignable_v<Ptr>;
using T = typename Ptr::element_type;
+
struct SelectionObj : public SelectionV<Ptr> {
struct MakeObjectByTypeName : public SelectionV<Ptr> {
using SelectionV<Ptr>::SelectionV;
diff --git a/lib/ptr.h b/lib/ptr.h
index b7d15a1..fb959ab 100644
--- a/lib/ptr.h
+++ b/lib/ptr.h
@@ -55,6 +55,7 @@ public:
protected:
explicit wrapped_ptr(Obj * o) : obj {o} { }
+
Obj * obj;
};
diff --git a/lib/resource.h b/lib/resource.h
index 37dd657..9af3632 100644
--- a/lib/resource.h
+++ b/lib/resource.h
@@ -16,5 +16,6 @@ public:
Resource::setBasePath(RESDIR);
}
};
+
BOOST_GLOBAL_FIXTURE(SetResourcePath);
#endif
diff --git a/lib/saxParse-persistence.h b/lib/saxParse-persistence.h
index 6043b25..bd5db57 100644
--- a/lib/saxParse-persistence.h
+++ b/lib/saxParse-persistence.h
@@ -10,6 +10,7 @@ namespace Persistence {
private:
template<typename T> struct Root : public Persistable {
T t {};
+
bool
persist(PersistenceStore & store)
{
diff --git a/lib/stdTypeDefs.h b/lib/stdTypeDefs.h
index 317cdb3..beab630 100644
--- a/lib/stdTypeDefs.h
+++ b/lib/stdTypeDefs.h
@@ -6,18 +6,22 @@
template<typename T> struct AnyPtr {
// cppcheck-suppress noExplicitConstructor
AnyPtr(T * p) : ptr {p} { }
+
// cppcheck-suppress noExplicitConstructor
template<typename S> AnyPtr(const S & p) : ptr {p.get()} { }
+
auto
get() const
{
return ptr;
}
+
auto
operator->() const
{
return ptr;
}
+
auto &
operator*() const
{
diff --git a/lib/unicode.h b/lib/unicode.h
index f69c43c..bc491f3 100644
--- a/lib/unicode.h
+++ b/lib/unicode.h
@@ -50,6 +50,7 @@ struct utf8_string_view {
constexpr utf8_string_view(const Str & str) : begin_ {str.data()}, end_ {str.data() + str.length()}
{
}
+
// cppcheck-suppress noExplicitConstructor; NOLINTNEXTLINE(hicpp-explicit-conversions)
constexpr utf8_string_view(const char * const str) : utf8_string_view {std::string_view {str}} { }
@@ -70,6 +71,7 @@ struct utf8_string_view {
private:
const char *begin_, *end_;
};
+
template<> struct std::iterator_traits<utf8_string_view::iter> {
using difference_type = size_t;
using value_type = uint32_t;
diff --git a/lib/worker.h b/lib/worker.h
index 0d15ca2..95bb4ec 100644
--- a/lib/worker.h
+++ b/lib/worker.h
@@ -16,6 +16,7 @@ public:
class WorkItem {
protected:
WorkItem(Worker * worker) : worker {worker} { }
+
virtual ~WorkItem() = default;
NO_MOVE(WorkItem);
NO_COPY(WorkItem);
@@ -25,6 +26,7 @@ public:
{
worker->assist();
}
+
Worker * worker;
public:
@@ -57,6 +59,7 @@ public:
{
return instance.addWorkImpl(std::forward<Params>(params)...);
}
+
template<typename T> using WorkPtrT = std::shared_ptr<WorkItemT<T>>;
private: