summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/embed-glsl.cpp.m42
-rw-r--r--lib/msgException.h23
-rw-r--r--lib/stdTypeDefs.h12
3 files changed, 36 insertions, 1 deletions
diff --git a/lib/embed-glsl.cpp.m4 b/lib/embed-glsl.cpp.m4
index 9fe0b41..ecae004 100644
--- a/lib/embed-glsl.cpp.m4
+++ b/lib/embed-glsl.cpp.m4
@@ -5,5 +5,5 @@ changecom() dnl
#include <glad/gl.h>
constexpr Shader NAME`_'substr(TYPE,1) {
- R"GLSL-EMBED(dnl
+ R"GLSL-EMBED(// OUTPUT
include(SOURCE))GLSL-EMBED", GLTYPE };
diff --git a/lib/msgException.h b/lib/msgException.h
new file mode 100644
index 0000000..660738d
--- /dev/null
+++ b/lib/msgException.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <optional>
+#include <string>
+
+template<typename BaseException> class MsgException : public BaseException {
+protected:
+ using BaseException::BaseException;
+ [[nodiscard]] virtual std::string getMsg() const noexcept = 0;
+
+public:
+ [[nodiscard]] const char *
+ what() const noexcept override
+ {
+ if (!msg) {
+ msg.emplace(getMsg());
+ }
+ return msg->c_str();
+ }
+
+private:
+ mutable std::optional<std::string> msg;
+};
diff --git a/lib/stdTypeDefs.h b/lib/stdTypeDefs.h
index beab630..38ebe0b 100644
--- a/lib/stdTypeDefs.h
+++ b/lib/stdTypeDefs.h
@@ -28,6 +28,18 @@ template<typename T> struct AnyPtr {
return *ptr;
}
+ // NOLINTNEXTLINE(hicpp-explicit-conversions)
+ operator bool() const
+ {
+ return ptr != nullptr;
+ }
+
+ bool
+ operator!() const
+ {
+ return ptr == nullptr;
+ }
+
private:
T * ptr;
};