summaryrefslogtreecommitdiffhomepage
path: root/dev/lib/utility
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-09-17 10:06:29 +0200
committerGitHub <noreply@github.com>2025-09-17 10:06:29 +0200
commitb06170354225f19271627df11525857fa34a38e7 (patch)
tree68c5ba79cf2fae57eeb1d708658a99b396a9defe /dev/lib/utility
parent6789dd7d88a192e3f55b95798cb393e7d12f368a (diff)
parent1c369ccc98734e72509509e9a5798a3aaa34dd70 (diff)
(OCL: v1.0.44) Merge pull request #5 from amlel-el-mahrouss/devv1.0.44
OCL: v1.0.44
Diffstat (limited to 'dev/lib/utility')
-rw-r--r--dev/lib/utility/chunk_string.hpp102
1 files changed, 0 insertions, 102 deletions
diff --git a/dev/lib/utility/chunk_string.hpp b/dev/lib/utility/chunk_string.hpp
deleted file mode 100644
index 4fe5cc2..0000000
--- a/dev/lib/utility/chunk_string.hpp
+++ /dev/null
@@ -1,102 +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>
-
-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:
- 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;
- }
-
- std::basic_string<char_type> str() const noexcept
- {
- static std::basic_string<char_type> ret;
-
- if (ret.size() > 0)
- ret.clear();
-
- 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