summaryrefslogtreecommitdiffhomepage
path: root/dev/lib/logic/opt.hpp
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-09-17 09:59:28 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-09-17 09:59:28 +0200
commitbba582964bded940f9dc280fd15ed84aa2db2d39 (patch)
tree5917d51d60b4680d09510cccde0fdf271660c0a2 /dev/lib/logic/opt.hpp
parent06202a559a54757090c04ae55ba21a24d97fdc85 (diff)
feat! lib: reorganize library (OCL v1.0.44)
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/lib/logic/opt.hpp')
-rw-r--r--dev/lib/logic/opt.hpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/dev/lib/logic/opt.hpp b/dev/lib/logic/opt.hpp
index 442756c..eff08eb 100644
--- a/dev/lib/logic/opt.hpp
+++ b/dev/lib/logic/opt.hpp
@@ -20,6 +20,7 @@ namespace ocl
count = err - okay + 1,
};
+ template <typename char_type = char>
struct opt final
{
explicit opt(const return_type& return_type)
@@ -27,16 +28,28 @@ namespace ocl
{
}
- opt& expect(const char* input)
+ opt& expect(const char_type* input)
{
if (m_ret == return_type::err)
{
- throw std::runtime_error(input);
+ throw std::runtime_error(input ? input : "opt::error");
}
return *this;
}
+ template <typename ErrorHandler>
+ opt& expect_or_handle(const char_type* input)
+ {
+ if (m_ret == return_type::err)
+ {
+ ErrorHandler err_handler;
+ err_handler(input ? input : "opt::error");
+ }
+
+ return *this;
+ }
+
private:
return_type m_ret;
};