diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-23 20:16:02 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-23 20:16:02 -0500 |
| commit | 85f89ee4bb137100cbeffcbc10168eb8ea52e6cc (patch) | |
| tree | f6e2063319ceaaa02f523fb5c289e4f37411a2df /dev/lib/core | |
| parent | 9a70f32ddaec0eef99efbf7ff5597c2adf08f45a (diff) | |
| parent | 65a8349aa5526d071b18cd4d42586c46faaa3823 (diff) | |
Merge pull request #18 from amlel-el-mahrouss/developv1.0.48
OCL v1.0.48
Diffstat (limited to 'dev/lib/core')
| -rw-r--r-- | dev/lib/core/chunk_string.hpp | 121 | ||||
| -rw-r--r-- | dev/lib/core/error_handler.hpp | 47 | ||||
| -rw-r--r-- | dev/lib/core/includes.hpp | 23 |
3 files changed, 0 insertions, 191 deletions
diff --git a/dev/lib/core/chunk_string.hpp b/dev/lib/core/chunk_string.hpp deleted file mode 100644 index 0ecc73e..0000000 --- a/dev/lib/core/chunk_string.hpp +++ /dev/null @@ -1,121 +0,0 @@ -/* -* File: core/chunk_string.hpp - * Purpose: String implementation for the OCL C++ library. - * Author: Amlal El Mahrouss (amlal@nekernel.org) - * Copyright 2025, Amlal El Mahrouss - */ - -#ifndef OCL_UTILITY_CHUNK_STRING_HPP -#define OCL_UTILITY_CHUNK_STRING_HPP - -#include <lib/core/includes.hpp> -#include <lib/io/print.hpp> -#include <cstring> - -namespace ocl -{ - template <typename char_type, std::size_t max_chunk_size = 8196> - class basic_chunk_string; - - template <typename char_type, std::size_t max_chunk_size> - class basic_chunk_string final - { - private: - char_type packed_chunks_[max_chunk_size] = {0}; - std::size_t chunk_total_{}; - - bool bad_{false}; - - public: - const bool& bad{bad_}; - - basic_chunk_string() = default; - - basic_chunk_string(const char_type* in) - { - this->operator+=(in); - } - - basic_chunk_string(const std::basic_string<char_type>& in) - { - this->operator+=(in); - } - - ~basic_chunk_string() = default; - - basic_chunk_string& operator=(const basic_chunk_string&) = delete; - basic_chunk_string(const basic_chunk_string&) = delete; - - public: - /// @brief Append a std::basic_string to the chunk string. - basic_chunk_string& operator+=(const char_type* in) - { - if (in == nullptr || bad_) - return *this; - - const auto& sz = std::strlen(in); - - this->operator+=(std::basic_string<char_type>(in, sz)); - - return *this; - } - - basic_chunk_string& operator+=(const std::basic_string<char_type>& in) - { - if (in.empty() || bad_) - return *this; - - if (in.size() > max_chunk_size) - { - bad_ = true; - return *this; - } - - if (chunk_total_ > max_chunk_size) - { - bad_ = true; - return *this; - } - - const auto& sz = in.size(); - const static auto size_max_chunk = max_chunk_size; - const auto& ptr = in.data(); - - if (chunk_total_ < size_max_chunk) - { - std::memcpy(packed_chunks_ + chunk_total_, ptr, sz); - chunk_total_ += sz; - } - - return *this; - } - - /// @brief Convert to basic_string or return from cache. - std::basic_string<char_type> str() const noexcept - { - static std::basic_string<char_type> ret; - const auto& sz = ret.size(); - - if (chunk_total_ > sz) - ret.clear(); - else - return ret; - - ret = packed_chunks_; - - return ret; - } - - void print() noexcept - { - ocl::io::print(packed_chunks_); - } - }; - - template <typename char_type> - inline void print(basic_chunk_string<char_type>& fmt) noexcept - { - fmt.print(); - } -} // namespace ocl -#endif // ifndef OCL_UTILITY_CHUNK_STRING_HPP diff --git a/dev/lib/core/error_handler.hpp b/dev/lib/core/error_handler.hpp deleted file mode 100644 index 832f109..0000000 --- a/dev/lib/core/error_handler.hpp +++ /dev/null @@ -1,47 +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 <lib/core/includes.hpp> -#include <lib/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&) = delete; - basic_error_handler(const basic_error_handler&) = delete; - - 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 standard_error_handler = basic_error_handler; - using error_handler_type = basic_error_handler; -} // namespace ocl - -#endif // ifndef _OCL_ERROR_HANDLER_HPP diff --git a/dev/lib/core/includes.hpp b/dev/lib/core/includes.hpp deleted file mode 100644 index a1c6e86..0000000 --- a/dev/lib/core/includes.hpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * File: core/includes.hpp - * Purpose: Core includes for the OCL library. - * Author: Amlal El Mahrouss (amlal@nekernel.org) - * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License. - */ - -#pragma once - -#include <boost/config.hpp> -#include <boost/core/nvp.hpp> -#include <boost/core/demangle.hpp> -#include <boost/core/null_deleter.hpp> -#include <boost/container/allocator.hpp> - -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 |
