From bba582964bded940f9dc280fd15ed84aa2db2d39 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 17 Sep 2025 09:59:28 +0200 Subject: feat! lib: reorganize library (OCL v1.0.44) Signed-off-by: Amlal El Mahrouss --- dev/lib/logic/opt.hpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'dev/lib/logic') 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 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 + 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; }; -- cgit v1.2.3