summaryrefslogtreecommitdiffhomepage
path: root/include/ocl/core
diff options
context:
space:
mode:
Diffstat (limited to 'include/ocl/core')
-rw-r--r--include/ocl/core/allocator_op.hpp10
-rw-r--r--include/ocl/core/chunk_string.hpp8
-rw-r--r--include/ocl/core/config.hpp17
-rw-r--r--include/ocl/core/error.hpp21
-rw-r--r--include/ocl/core/error_handler.hpp46
-rw-r--r--include/ocl/core/handler.hpp42
-rw-r--r--include/ocl/core/is_same.hpp (renamed from include/ocl/core/equiv.hpp)8
-rw-r--r--include/ocl/core/option.hpp (renamed from include/ocl/core/opt.hpp)39
8 files changed, 76 insertions, 115 deletions
diff --git a/include/ocl/core/allocator_op.hpp b/include/ocl/core/allocator_op.hpp
index 8fb8ce9..c086901 100644
--- a/include/ocl/core/allocator_op.hpp
+++ b/include/ocl/core/allocator_op.hpp
@@ -40,8 +40,8 @@ namespace ocl
template <typename ret_type, typename allocator_new, typename allocator_delete>
class allocator_op
{
- allocator_new m_alloc_{};
- allocator_delete m_free_{};
+ allocator_new alloc_op_{};
+ allocator_delete free_op_{};
public:
allocator_op() = default;
@@ -52,18 +52,18 @@ namespace ocl
ret_type* claim()
{
- return m_alloc_();
+ return alloc_op_();
}
template <typename... var_type>
auto construct(var_type... args) -> std::shared_ptr<ret_type>
{
- return std::shared_ptr<ret_type>(m_alloc_.template var_alloc<var_type...>(args...), allocator_delete{});
+ return std::shared_ptr<ret_type>(alloc_op_.template var_alloc<var_type...>(args...), allocator_delete{});
}
void unclaim(ret_type* ptr)
{
- m_free_(ptr);
+ free_op_(ptr);
}
};
diff --git a/include/ocl/core/chunk_string.hpp b/include/ocl/core/chunk_string.hpp
index 17d81bd..a2380f6 100644
--- a/include/ocl/core/chunk_string.hpp
+++ b/include/ocl/core/chunk_string.hpp
@@ -24,7 +24,7 @@ namespace ocl
using condition_type = bool;
private:
- char_type packed_chunks_[max_chunk_size] = {0};
+ char_type chunk_[max_chunk_size] = {0};
std::size_t chunk_total_{};
condition_type bad_{false};
@@ -84,7 +84,7 @@ namespace ocl
if (chunk_total_ < size_max_chunk)
{
- std::memcpy(packed_chunks_ + chunk_total_, ptr, sz);
+ std::memcpy(chunk_ + chunk_total_, ptr, sz);
chunk_total_ += sz;
}
@@ -102,14 +102,14 @@ namespace ocl
else
return ret;
- ret = packed_chunks_;
+ ret = chunk_;
return ret;
}
void print() noexcept
{
- ocl::io::print(packed_chunks_);
+ ocl::io::print(chunk_);
}
};
diff --git a/include/ocl/core/config.hpp b/include/ocl/core/config.hpp
index 15439d8..c354672 100644
--- a/include/ocl/core/config.hpp
+++ b/include/ocl/core/config.hpp
@@ -8,38 +8,31 @@
#pragma once
#include <boost/config.hpp>
+#include <boost/core/addressof.hpp>
#include <boost/core/nvp.hpp>
#include <boost/core/demangle.hpp>
#include <boost/core/null_deleter.hpp>
#include <boost/container/allocator.hpp>
#include <boost/assert.hpp>
-#include <cstddef>
#include <cassert>
-#include <utility>
-#include <string>
-#include <vector>
-#include <cstdint>
+
#include <sys/types.h>
#include <unistd.h>
-#define OCL_DEPRECATED() [[deprecated]]
-#define OCL_DEPRECATED_MSG(MSG) [[deprecated( MSG )]]
+#define OCL_DEPRECATED() [[deprecated]]
+#define OCL_DEPRECATED_MSG(MSG) [[deprecated(MSG)]]
#ifdef __cplusplus
#define OCL_DECL extern "C"
/// DLL/Dylib/So specific macro.
#define OCL_EXPORT_DECL extern "C" BOOST_SYMBOL_EXPORT
#else
-#define OCL_DECL
+#define OCL_DECL
#define OCL_EXPORT_DECL
#endif
namespace ocl
{
-#ifdef OCL_USE_UTF8
- using char_type = char8_t;
-#else
using char_type = char;
-#endif
} // namespace ocl \ No newline at end of file
diff --git a/include/ocl/core/error.hpp b/include/ocl/core/error.hpp
deleted file mode 100644
index cf038f8..0000000
--- a/include/ocl/core/error.hpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * File: opt.hpp
- * Author: Amlal El Mahrouss,
- * Copyright 2023-2025, Amlal El Mahrouss, Licensed under the Boost Software License
- */
-
-#ifndef _OCL_ERR_HPP
-#define _OCL_ERR_HPP
-
-#include <stdexcept>
-#include <core/error_handler.hpp>
-
-namespace ocl::error
-{
- using runtime_error = std::runtime_error;
- using fix_error = runtime_error;
- using math_error = runtime_error;
- using cgi_error = runtime_error;
-} // namespace ocl::error
-
-#endif // _OCL_ERR_HPP \ No newline at end of file
diff --git a/include/ocl/core/error_handler.hpp b/include/ocl/core/error_handler.hpp
deleted file mode 100644
index 971d91c..0000000
--- a/include/ocl/core/error_handler.hpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * File: core/basic_error_handler.hpp
- * Purpose: Error handler container.
- * Author: Amlal El Mahrouss (amlal@nekernel.org)
- * Copyright 2025, Amlal El Mahrouss, Licensed under the Boost Software License.
- */
-
-#ifndef _OCL_ERROR_HANDLER_HPP
-#define _OCL_ERROR_HANDLER_HPP
-
-#include <core/config.hpp>
-#include <io/print.hpp>
-
-namespace ocl
-{
- struct basic_error_handler;
-
- struct basic_error_handler
- {
- explicit basic_error_handler() = default;
- virtual ~basic_error_handler() = default;
-
- basic_error_handler& operator=(const basic_error_handler&) = default;
- basic_error_handler(const basic_error_handler&) = default;
-
- template <bool throw_too = false>
- void error(const std::basic_string<char>& msg)
- {
- this->operator()(msg);
-
- if constexpr (throw_too)
- {
- throw std::runtime_error(msg);
- }
- }
-
- void operator()(const std::basic_string<char>& msg)
- {
- ocl::io::print(msg);
- }
- };
-
- using error_handler_type = basic_error_handler;
-} // namespace ocl
-
-#endif // ifndef _OCL_ERROR_HANDLER_HPP
diff --git a/include/ocl/core/handler.hpp b/include/ocl/core/handler.hpp
new file mode 100644
index 0000000..e31f0d4
--- /dev/null
+++ b/include/ocl/core/handler.hpp
@@ -0,0 +1,42 @@
+/*
+ * File: core/handler.hpp
+ * Purpose: Handler container.
+ * Author: Amlal El Mahrouss (amlal@nekernel.org)
+ * Copyright 2025, Amlal El Mahrouss, Licensed under the Boost Software License.
+ */
+
+#ifndef _OCL_ERROR_HANDLER_HPP
+#define _OCL_ERROR_HANDLER_HPP
+
+#include <core/config.hpp>
+#include <io/print.hpp>
+#include <exception>
+
+namespace ocl
+{
+ struct handler;
+
+ struct handler
+ {
+ private:
+ template <typename T>
+ void handle_impl(T element) {}
+
+ public:
+ using error_type = std::exception;
+
+ explicit handler() = default;
+ virtual ~handler() = default;
+
+ handler& operator=(const handler&) = default;
+ handler(const handler&) = default;
+
+ template <typename T>
+ void operator()(T element)
+ {
+ this->handle_impl<T>(element);
+ }
+ };
+} // namespace ocl
+
+#endif // ifndef _OCL_ERROR_HANDLER_HPP
diff --git a/include/ocl/core/equiv.hpp b/include/ocl/core/is_same.hpp
index f98d86d..e6f42c4 100644
--- a/include/ocl/core/equiv.hpp
+++ b/include/ocl/core/is_same.hpp
@@ -1,5 +1,5 @@
/*
- * File: equiv.hpp
+ * File: is_same.hpp
* Purpose: Equivalence header.
* Author: Amlal El Mahrouss (amlal@nekernel.org)
* Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
@@ -10,10 +10,10 @@
#include <core/config.hpp>
/// @brief OCL equivalence namespace.
-namespace ocl::equiv
+namespace ocl::is_same
{
template <typename T>
- struct basic_hash_trait
+ struct basic_hash
{
/// @brief hash from T's result_type.
static typename T::result_type hash()
@@ -103,4 +103,4 @@ namespace ocl::equiv
return left_ / right_ == 1;
}
};
-} // namespace ocl::equiv
+} // namespace ocl::is_same
diff --git a/include/ocl/core/opt.hpp b/include/ocl/core/option.hpp
index 506f582..5bae9a2 100644
--- a/include/ocl/core/opt.hpp
+++ b/include/ocl/core/option.hpp
@@ -1,5 +1,5 @@
/*
- * File: opt.hpp
+ * File: option.hpp
* Author: Amlal El Mahrouss,
* Copyright 2023-2025, Amlal El Mahrouss, Licensed under the Boost Software License
*/
@@ -21,37 +21,42 @@ namespace ocl
};
template <typename char_type = char>
- struct opt final
+ struct option final
{
- explicit opt(const return_type& return_type)
- : m_ret(return_type)
+ explicit option(const return_type& return_type)
+ : ret_(return_type)
{
}
- opt& expect(const char_type* input)
+ ~option() = default;
+
+ option& operator=(const option&) = default;
+ option(const option&) = default;
+
+ option& expect(const char_type* input)
{
- if (m_ret == return_type::err)
+ if (ret_ == return_type::err)
{
- throw std::runtime_error(input ? input : "opt::error");
+ throw std::runtime_error(input ? input : "option::error");
}
return *this;
}
template <typename ErrorHandler>
- opt& expect_or_handle(const char_type* input)
+ option& expect_or_handle(const char_type* input)
{
- if (m_ret == return_type::err)
+ if (ret_ == return_type::err)
{
ErrorHandler err_handler;
- err_handler(input ? input : "opt::error");
+ err_handler(input ? input : "option::error");
}
return *this;
}
private:
- return_type m_ret{return_type::invalid};
+ return_type ret_{return_type::invalid};
};
template <typename Teller, typename... Lst>
@@ -64,10 +69,6 @@ namespace ocl
{
struct int_eq_teller
{
- explicit int_eq_teller()
- {
- }
-
bool operator()(int a, int b)
{
return (a == b);
@@ -76,10 +77,6 @@ namespace ocl
struct int_greater_than_teller
{
- explicit int_greater_than_teller()
- {
- }
-
bool operator()(int a, int b)
{
return (a > b);
@@ -88,10 +85,6 @@ namespace ocl
struct int_less_than_teller
{
- explicit int_less_than_teller()
- {
- }
-
bool operator()(int a, int b)
{
return (a < b);