summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-29 14:53:01 -0500
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-29 14:54:13 -0500
commita8e99f3a783069cf85b626c6cfb2fbe83ae4fd44 (patch)
tree8322b0d20dd02660c3f26fcfd37c2cc4dcd33cda
parent463a0c01f96d86c9c91f02903bc1d194c5e55b15 (diff)
chore: new version of OCL and codebase cleanup.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
-rw-r--r--.github/workflows/cmake-cgi.yml69
-rw-r--r--README.md22
-rw-r--r--examples/.keep (renamed from meta/pdf/.keep)0
-rw-r--r--examples/allocator_system/CMakeLists.txt16
-rw-r--r--examples/allocator_system/allocator_system.cc53
-rw-r--r--examples/cgi/CMakeLists.txt16
-rw-r--r--examples/cgi/cgi.cc75
-rw-r--r--examples/equiv/CMakeLists.txt12
-rw-r--r--examples/equiv/equiv.cc19
-rw-r--r--examples/fix/CMakeLists.txt15
-rw-r--r--examples/fix/fix.cc47
-rw-r--r--examples/fix_tag_example/CMakeLists.txt15
-rw-r--r--examples/fix_tag_example/example.cc30
-rw-r--r--examples/opt/CMakeLists.txt12
-rw-r--r--examples/opt/opt.cc45
-rw-r--r--examples/tracked_ptr/CMakeLists.txt12
-rw-r--r--examples/tracked_ptr/tracked_ptr.cc53
-rw-r--r--examples/url/CMakeLists.txt15
-rw-r--r--examples/url/url.cc24
-rw-r--r--include/.keep0
-rw-r--r--include/ocl/checksum/crc32.hpp (renamed from include/ocl/utility/crc32.hpp)0
-rw-r--r--include/ocl/core/allocator_op.hpp (renamed from include/ocl/memory/allocator_system.hpp)16
-rw-r--r--include/ocl/core/chunk_string.hpp2
-rw-r--r--include/ocl/core/equiv.hpp (renamed from include/ocl/logic/equiv.hpp)2
-rw-r--r--include/ocl/core/error.hpp (renamed from include/ocl/except/error.hpp)0
-rw-r--r--include/ocl/core/error_handler.hpp1
-rw-r--r--include/ocl/core/opt.hpp (renamed from include/ocl/logic/opt.hpp)2
-rw-r--r--include/ocl/fix/parser.hpp5
-rw-r--r--include/ocl/io/print.hpp5
-rw-r--r--include/ocl/logic/math.hpp33
-rw-r--r--include/ocl/memory/tracked_ptr.hpp241
-rw-r--r--include/ocl/net/modem.hpp4
-rw-r--r--include/ocl/net/url.hpp164
-rw-r--r--include/ocl/simd/basic_simd.hpp53
-rw-r--r--include/ocl/simd/simd.hpp61
-rw-r--r--include/ocl/tests/gtest.hpp10
-rw-r--r--include/ocl/tests/hpptest.hpp97
-rw-r--r--include/ocl/utility/cgi.hpp79
-rw-r--r--include/ocl/utility/embfs.hpp81
-rwxr-xr-xmake_dist_linux.sh31
-rwxr-xr-xmake_dist_osx.sh17
-rw-r--r--meta/tex/embfs.tex141
-rw-r--r--tests/chunk_string/chunk_test.cc25
-rw-r--r--tests/fix_basic/fix_test.cc29
-rw-r--r--tests/network_basic/network_basic_test.cc3
-rw-r--r--tests/tracked_ptr_basic/CMakeLists.txt23
-rw-r--r--tests/tracked_ptr_basic/tracked_ptr_test.cc25
-rw-r--r--tests/tracked_ptr_leak/CMakeLists.txt23
-rw-r--r--tests/tracked_ptr_leak/tracked_ptr_test.cc19
-rwxr-xr-xtools/hpptest.py22
50 files changed, 91 insertions, 1673 deletions
diff --git a/.github/workflows/cmake-cgi.yml b/.github/workflows/cmake-cgi.yml
deleted file mode 100644
index 957ef52..0000000
--- a/.github/workflows/cmake-cgi.yml
+++ /dev/null
@@ -1,69 +0,0 @@
-# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
-# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
-name: CMake on multiple platforms
-
-on:
- push:
- branches: [ "trunk" ]
- pull_request:
- branches: [ "trunk" ]
-
-jobs:
- build:
- runs-on: ${{ matrix.os }}
-
- strategy:
- # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
- fail-fast: false
-
- # Set up a matrix to run the following 3 configurations:
- # 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
- # 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
- # 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
- #
- # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
- matrix:
- os: [ubuntu-latest, windows-latest]
- build_type: [Release]
- c_compiler: [gcc, clang, cl]
- include:
- - os: windows-latest
- c_compiler: cl
- cpp_compiler: cl
- - os: ubuntu-latest
- c_compiler: gcc
- cpp_compiler: g++
- - os: ubuntu-latest
- c_compiler: clang
- cpp_compiler: clang++
- exclude:
- - os: windows-latest
- c_compiler: gcc
- - os: windows-latest
- c_compiler: clang
- - os: ubuntu-latest
- c_compiler: cl
-
- steps:
- - uses: actions/checkout@v4
-
- - name: Set reusable strings
- # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
- id: strings
- shell: bash
- run: |
- echo "build-output-dir=./build" >> "$GITHUB_OUTPUT"
-
- - name: Configure CMake
- # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
- # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
- run: >
- cd examples/cgi && cmake -B ${{ steps.strings.outputs.build-output-dir }}
- -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
- -DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
- -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-
- - name: Build
- # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
- run: cd examples/cgi && cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
-
diff --git a/README.md b/README.md
index 6d495db..4c9574b 100644
--- a/README.md
+++ b/README.md
@@ -4,26 +4,14 @@
## Brief:
-A C++ library with additional modules for your C++ SDLC.
+A set of containers in C++ for developers.
## Requirements:
-- Boost C++ libraries (https://www.boost.org/)
-- Clang (https://clang.llvm.org/)
-- Git (https://git-scm.com/)
-
-## Structure:
-
-- `core`: Core utilities and fundamental abstractions used across OCL.
-- `except`: Exception classes and error-handling helpers.
-- `fix`: FIX protocol utilities and helpers for Financial Information eXchange integration.
-- `io`: Input/output utilities, stream helpers, and file handling.
-- `logic`: Logic facilities, macros, and helpers for programs.
-- `memory`: Memory management utilities, allocators, and smart-pointer helpers.
-- `net`: Networking utilities and lightweight socket helpers.
-- `simd`: SIMD-optimized algorithms and low-level performance helpers.
-- `tests`: Unit and integration tests that validate OCL components.
-- `utility`: General-purpose helper functions and small algorithms.
+- [Boost](https://www.boost.org/)
+- [Clang](https://clang.llvm.org/)
+- [CMake](https://cmake.org/)
+- [Git](https://git-scm.com/)
## Examples:
diff --git a/meta/pdf/.keep b/examples/.keep
index e69de29..e69de29 100644
--- a/meta/pdf/.keep
+++ b/examples/.keep
diff --git a/examples/allocator_system/CMakeLists.txt b/examples/allocator_system/CMakeLists.txt
deleted file mode 100644
index a4bb69d..0000000
--- a/examples/allocator_system/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-
-cmake_minimum_required(VERSION 3.15...3.31)
-
-project(
- Alloc
- VERSION 1.0
- LANGUAGES CXX)
-
-find_package(Boost REQUIRED COMPONENTS container)
-
-add_executable(Alloc allocator_system.cc)
-
-target_link_libraries(Alloc PRIVATE Boost::container)
-
-set_property(TARGET Alloc PROPERTY CXX_STANDARD 20)
-target_include_directories(Alloc PUBLIC ../../include/ocl)
diff --git a/examples/allocator_system/allocator_system.cc b/examples/allocator_system/allocator_system.cc
deleted file mode 100644
index fd7ae56..0000000
--- a/examples/allocator_system/allocator_system.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * File: allocator_system.cc
- * Purpose: Allocator System container.
- * Author: Amlal El Mahrouss (amlal@nekernel.org)
- * Copyright 2025, Amlal El Mahrouss, Licensed under the Boost Software License. Licensed under the BSL 1.0 license
- */
-
-#include <memory/allocator_system.hpp>
-#include <iostream>
-
-class MyClass final
-{
-public:
- int a{};
- std::string b{};
-
- MyClass() : a(0), b("default")
- {
- std::cout << "MyClass() constructed\n";
- }
-
- MyClass(int x, std::string y) : a(x), b(std::move(y))
- {
- std::cout << "MyClass(int, string) constructed\n";
- }
-
- ~MyClass()
- {
- std::cout << "~MyClass() destroyed\n";
- }
-};
-
-int main()
-{
- ocl::standard_allocator_type<MyClass> allocator;
-
- // Test 1: claim() + unclaim()
- std::cout << "=== Test 1: claim/unclaim ===\n";
-
- MyClass* raw = allocator.claim();
-
- std::cout << "raw->a = " << raw->a << ", raw->b = " << raw->b << "\n";
- allocator.unclaim(raw); // Manual delete
-
- // Test 2: construct() → shared_ptr
- std::cout << "\n=== Test 2: construct (shared_ptr) ===\n";
-
- auto ptr = allocator.construct<int, std::string>(42, "hello");
- std::cout << "ptr->a = " << ptr->a << ", ptr->b = " << ptr->b << "\n";
-
- // `shared_ptr` will automatically delete the object
- std::cout << "\n=== End of main ===\n";
-}
diff --git a/examples/cgi/CMakeLists.txt b/examples/cgi/CMakeLists.txt
deleted file mode 100644
index e30707c..0000000
--- a/examples/cgi/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-
-cmake_minimum_required(VERSION 3.15...3.31)
-
-project(
- CGI
- VERSION 1.0
- LANGUAGES CXX)
-
-find_package(Boost REQUIRED COMPONENTS container)
-
-add_executable(CGI cgi.cc)
-
-target_link_libraries(CGI PRIVATE Boost::container)
-
-set_property(TARGET CGI PROPERTY CXX_STANDARD 20)
-target_include_directories(CGI PUBLIC ../../include/ocl)
diff --git a/examples/cgi/cgi.cc b/examples/cgi/cgi.cc
deleted file mode 100644
index b837433..0000000
--- a/examples/cgi/cgi.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- cgi example
- written by Amlal El Mahrouss.
- licensed under the Boost Software License
- */
-
-#include <utility/cgi.hpp>
-
-static ocl::basic_chunk_string<char> text_sample = R"(
-<!DOCTYPE html>
-<html>
-<head>
- <meta charset="UTF-8">
- <title>Error | OCL</title>
- <style>
- body {
- font-family: monospace;
- background: white;
- color: black;
- margin: 2em;
- }
- h1 {
- font-size: 1.5em;
- }
- hr {
- border: none;
- border-top: 1px solid #ccc;
- }
- table {
- width: 100%;
- border-collapse: collapse;
- }
- td {
- padding: 0.2em 0.5em;
- }
- td:first-child {
- white-space: nowrap;
- }
- a {
- color: blue;
- text-decoration: none;
- }
- a:hover {
- text-decoration: underline;
- }
- </style>
-</head>
-<body>
- <h1>Uh Oh!</h1>
- <address>No index file was found in this directory.</address>
- <hr>
- <table>
- <tr><th>Name</th></tr>
- <tr><td colspan="3"><hr></td></tr>
-
- <tr>
- <td><a href="javascript:window.location.reload();">Refresh</a></td>
- </tr>
-
- <tr><td colspan="3"><hr></td></tr>
- </table>
- <address>OCL's Common Gateway Server.</address>
-</body>
-</html>
-)";
-
-/* finally test it */
-/* @brief this stub loads a 'index.html' or returns an error message if not found. */
-int main(int argc, char** argv)
-{
- ocl::cgi::basic_writer<> writer;
- writer << text_sample;
-
- return 0;
-}
diff --git a/examples/equiv/CMakeLists.txt b/examples/equiv/CMakeLists.txt
deleted file mode 100644
index 4a374ce..0000000
--- a/examples/equiv/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-
-cmake_minimum_required(VERSION 3.15...3.31)
-
-project(
- Equiv
- VERSION 1.0
- LANGUAGES CXX)
-
-add_executable(Equiv equiv.cc)
-
-set_property(TARGET Equiv PROPERTY CXX_STANDARD 20)
-target_include_directories(Equiv PUBLIC ../../include/ocl)
diff --git a/examples/equiv/equiv.cc b/examples/equiv/equiv.cc
deleted file mode 100644
index 0c68e21..0000000
--- a/examples/equiv/equiv.cc
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- string checksum example
- written by Amlal El Mahrouss.
- licensed under the Boost Software License
- */
-
-#include <logic/equiv.hpp>
-#include <iostream>
-
-/* finally test it */
-int main(int argc, char** argv)
-{
- std::cout << std::boolalpha;
- std::cout << ocl::equiv::is_same<bool, int>::value << std::endl;
- std::cout << ocl::equiv::is_same<bool, bool>::value << std::endl;
- std::cout << ocl::equiv::is_same<int, int>::value << std::endl;
-
- return 0;
-}
diff --git a/examples/fix/CMakeLists.txt b/examples/fix/CMakeLists.txt
deleted file mode 100644
index 143b1c4..0000000
--- a/examples/fix/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-
-cmake_minimum_required(VERSION 3.15...3.31)
-
-project(
- Fix
- VERSION 1.0
- LANGUAGES CXX)
-
-find_package(Boost REQUIRED COMPONENTS container)
-
-add_executable(Fix fix.cc)
-
-set_property(TARGET Fix PROPERTY CXX_STANDARD 20)
-target_include_directories(Fix PUBLIC ../../include/ocl)
-target_link_libraries(Fix PRIVATE Boost::container)
diff --git a/examples/fix/fix.cc b/examples/fix/fix.cc
deleted file mode 100644
index f52246f..0000000
--- a/examples/fix/fix.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- fix example
- Written by Amlal El Mahrouss.
- Licensed under the Boost Software License
- */
-
-#include <core/error_handler.hpp>
-#include <fix/parser.hpp>
-#include <iostream>
-#include <unistd.h>
-#include <io/print.hpp>
-#include <sys/socket.h>
-
-/* finally test it */
-int main(int argc, char** argv)
-{
- constexpr const char default_fix[] = {
- '8', '=', 'F', 'I', 'X', '.', '4', '.', '2', 0x01,
- '9', '=', '6', '3', 0x01, // BodyLength = 63
- '3', '5', '=', 'A', 0x01,
- '4', '9', '=', 'S', 'E', 'R', 'V', 'E', 'R', 0x01,
- '5', '6', '=', 'C', 'L', 'I', 'E', 'N', 'T', 0x01,
- '3', '4', '=', '1', '7', '7', 0x01,
- '5', '2', '=', '2', '0', '0', '9', '0', '1', '0', '7', '-', '1', '8', ':', '1', '5', ':', '1', '6', 0x01,
- '9', '8', '=', '0', 0x01,
- '1', '0', '8', '=', '3', '0', 0x01,
- '1', '0', '=', '1', '4', '3', 0x01, 0x00 // CheckSum = 143
- };
-
- ocl::fix::basic_visitor<char> basic_visitor;
- ocl::fix::basic_range_data<char> fix = basic_visitor.visit(default_fix);
-
- std::cout << "magic=" << fix.magic_ << std::endl;
- std::cout << "magic_len=" << fix.magic_len_ << std::endl;
- std::cout << "is_valid=" << std::boolalpha << fix.is_valid() << std::endl;
-
- ocl::basic_error_handler handler;
- ocl::fix::must_pass<char, ocl::basic_error_handler>(fix, handler);
-
- ocl::io::print(":key=35\n");
- ocl::io::print(":value=", fix["35"], "\n");
-
- ocl::io::print(":key=49\n");
- ocl::io::print(":value=", fix["49"], "\n");
-
- return 0;
-}
diff --git a/examples/fix_tag_example/CMakeLists.txt b/examples/fix_tag_example/CMakeLists.txt
new file mode 100644
index 0000000..e3b9cca
--- /dev/null
+++ b/examples/fix_tag_example/CMakeLists.txt
@@ -0,0 +1,15 @@
+
+cmake_minimum_required(VERSION 3.15...3.31)
+
+project(
+ FixExample
+ VERSION 1.0
+ LANGUAGES CXX)
+
+find_package(Boost REQUIRED COMPONENTS container)
+
+add_executable(FixExample fix.cc)
+
+set_property(TARGET FixExample PROPERTY CXX_STANDARD 20)
+target_include_directories(FixExample PUBLIC ../../include/ocl)
+target_link_libraries(FixExample PRIVATE Boost::container)
diff --git a/examples/fix_tag_example/example.cc b/examples/fix_tag_example/example.cc
new file mode 100644
index 0000000..ce1f6c8
--- /dev/null
+++ b/examples/fix_tag_example/example.cc
@@ -0,0 +1,30 @@
+#include <core/error_handler.hpp>
+#include <fix/parser.hpp>
+#include <io/print.hpp>
+
+constexpr const char default_fix[] = {
+ '8', '=', 'F', 'I', 'X', '.', '4', '.', '2', 0x01,
+ '9', '=', '6', '3', 0x01, // BodyLength = 63
+ '3', '5', '=', 'A', 0x01,
+ '4', '9', '=', 'S', 'E', 'R', 'V', 'E', 'R', 0x01,
+ '5', '6', '=', 'C', 'L', 'I', 'E', 'N', 'T', 0x01,
+ '3', '4', '=', '1', '7', '7', 0x01,
+ '5', '2', '=', '2', '0', '0', '9', '0', '1', '0', '7', '-', '1', '8', ':', '1', '5', ':', '1', '6', 0x01,
+ '9', '8', '=', '0', 0x01,
+ '1', '0', '8', '=', '3', '0', 0x01,
+ '1', '0', '=', '1', '4', '3', 0x01, 0x00 // CheckSum = 143
+};
+
+int main(int argc, char** argv)
+{
+ ocl::fix::visitor basic_visitor;
+ ocl::fix::range_data fix = basic_visitor.visit(default_fix);
+
+ ocl::io::print(":key=35\n");
+ ocl::io::print(":value=", fix["35"], "\n");
+
+ ocl::io::print(":key=49\n");
+ ocl::io::print(":value=", fix["49"], "\n");
+
+ return 0;
+}
diff --git a/examples/opt/CMakeLists.txt b/examples/opt/CMakeLists.txt
deleted file mode 100644
index e537cec..0000000
--- a/examples/opt/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-
-cmake_minimum_required(VERSION 3.15...3.31)
-
-project(
- Opt
- VERSION 1.0
- LANGUAGES CXX)
-
-add_executable(Opt opt.cc)
-
-set_property(TARGET Opt PROPERTY CXX_STANDARD 20)
-target_include_directories(Opt PUBLIC ../../include/ocl)
diff --git a/examples/opt/opt.cc b/examples/opt/opt.cc
deleted file mode 100644
index dbeab2f..0000000
--- a/examples/opt/opt.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- String checksum example
- Written by Amlal El Mahrouss.
- Licensed under the Boost Software License
- */
-
-#include <logic/opt.hpp>
-#include <io/print.hpp>
-#include <utility/crc32.hpp>
-#include <string>
-
-static const char do_hash(const std::string& in)
-{
- int hash = 0;
-
- for (long index = 0; index < in.size(); ++index)
- {
- hash += in[index];
- }
-
- return hash;
-}
-
-static auto do_some(const std::string recv_data, const std::string check_data)
-{
- const int hash_to_check = do_hash(check_data); /* here we assume this should match opt_hash */
- const int opt_hash = do_hash(recv_data); /* we assume that the hash is correct */
-
- auto opt = ocl::opt(ocl::eval_eq(hash_to_check, opt_hash)); /* do the compute */
- return opt;
-}
-
-/* finally test it */
-int main(int argc, char** argv)
-{
- // ... let's assume we fetch data from network...
-
- ocl::io::println("Testing data...");
-
- auto opt = do_some("Foo", "Foo");
- opt.expect("Checksum failed, Foo isn't Foo!");
-
-
- return 0;
-}
diff --git a/examples/tracked_ptr/CMakeLists.txt b/examples/tracked_ptr/CMakeLists.txt
deleted file mode 100644
index ea1312a..0000000
--- a/examples/tracked_ptr/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-
-cmake_minimum_required(VERSION 3.15...3.31)
-
-project(
- Fix
- VERSION 1.0
- LANGUAGES CXX)
-
-add_executable(TrackedPtr tracked_ptr.cc)
-
-set_property(TARGET TrackedPtr PROPERTY CXX_STANDARD 20)
-target_include_directories(TrackedPtr PUBLIC ../../include/ocl)
diff --git a/examples/tracked_ptr/tracked_ptr.cc b/examples/tracked_ptr/tracked_ptr.cc
deleted file mode 100644
index 3f1a4ec..0000000
--- a/examples/tracked_ptr/tracked_ptr.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- tracked_ptr example
- written by Amlal El Mahrouss.
- licensed under the Boost Software License
- */
-
-#include <memory/tracked_ptr.hpp>
-#include <io/print.hpp>
-
-static void summon_tracked_ptr()
-{
- ocl::memory::tracked_ptr<int> ptr = ocl::memory::make_tracked<int>(42);
- std::cout << ptr.data() << "=" << ptr.manager().allocator().allocated_count_ << std::endl;
-}
-
-static void summon_leak_tracked_ptr()
-{
- ocl::memory::tracked_ptr<int>* ptr = new ocl::memory::tracked_ptr<int>(42);
- std::cout << ptr->data() << "=" << ptr->manager().allocator().allocated_count_ << std::endl;
-}
-
-/* finally test it */
-int main(int argc, char** argv)
-{
- summon_tracked_ptr();
- summon_tracked_ptr();
- summon_tracked_ptr();
- summon_tracked_ptr();
-
- ocl::memory::tracked_ptr<int> ptr;
-
- std::cout << ptr.data() << "=" << ptr.manager().allocator().allocated_count_ << std::endl;
-
- std::cout << "total=" << ptr.manager().allocator().deallocated_count_ << std::endl;
- std::cout << "leak-detected=" << std::boolalpha << (ptr.manager().allocator().allocated_count_ > ptr.manager().allocator().deallocated_count_) << std::endl;
-
- summon_leak_tracked_ptr();
- summon_leak_tracked_ptr();
- summon_leak_tracked_ptr();
- summon_leak_tracked_ptr();
- summon_leak_tracked_ptr();
- summon_leak_tracked_ptr();
- summon_leak_tracked_ptr();
- summon_leak_tracked_ptr();
-
- std::cout << "total=" << ptr.manager().allocator().deallocated_count_ << std::endl;
- std::cout << "leak-detected=" << std::boolalpha << (ptr.manager().allocator().allocated_count_ > ptr.manager().allocator().deallocated_count_) << std::endl;
-
- ocl::standard_error_handler err;
- ocl::memory::must_pass(ptr, err);
-
- return EXIT_SUCCESS;
-}
diff --git a/examples/url/CMakeLists.txt b/examples/url/CMakeLists.txt
deleted file mode 100644
index 7195d6c..0000000
--- a/examples/url/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-
-cmake_minimum_required(VERSION 3.15...3.31)
-
-project(
- Url
- VERSION 1.0
- LANGUAGES CXX)
-
-find_package(Boost REQUIRED COMPONENTS container)
-
-add_executable(Url fix.cc)
-
-set_property(TARGET Url PROPERTY CXX_STANDARD 20)
-target_include_directories(Url PUBLIC ../../include/ocl)
-target_link_libraries(Url PRIVATE Boost::container)
diff --git a/examples/url/url.cc b/examples/url/url.cc
deleted file mode 100644
index b4cc924..0000000
--- a/examples/url/url.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- fix example
- Written by Amlal El Mahrouss.
- Licensed under the Boost Software License
- */
-
-#include <core/error_handler.hpp>
-#include <net/url.hpp>
-#include <unistd.h>
-#include <io/print.hpp>
-#include <sys/socket.h>
-
-/* finally test it */
-int main(int argc, char** argv)
-{
- ocl::net::url url_type(ocl::net::url::file);
-
- url_type /= "bin";
- url_type /= "ls";
-
- ocl::io::println(url_type.assemble());
-
- return EXIT_SUCCESS;
-}
diff --git a/include/.keep b/include/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/include/.keep
diff --git a/include/ocl/utility/crc32.hpp b/include/ocl/checksum/crc32.hpp
index 2bcab29..2bcab29 100644
--- a/include/ocl/utility/crc32.hpp
+++ b/include/ocl/checksum/crc32.hpp
diff --git a/include/ocl/memory/allocator_system.hpp b/include/ocl/core/allocator_op.hpp
index 345b612..8fb8ce9 100644
--- a/include/ocl/memory/allocator_system.hpp
+++ b/include/ocl/core/allocator_op.hpp
@@ -1,5 +1,5 @@
/*
- * File: core/allocator_system.hpp
+ * File: core/allocator_op.hpp
* Purpose: Allocator System container.
* Author: Amlal El Mahrouss (amlal@nekernel.org)
* Copyright 2025, Amlal El Mahrouss, Licensed under the Boost Software License. Licensed under the BSL 1.0 license
@@ -38,19 +38,19 @@ namespace ocl
};
template <typename ret_type, typename allocator_new, typename allocator_delete>
- class allocator_system
+ class allocator_op
{
allocator_new m_alloc_{};
allocator_delete m_free_{};
public:
- allocator_system() = default;
- ~allocator_system() = default;
+ allocator_op() = default;
+ ~allocator_op() = default;
- allocator_system& operator=(const allocator_system&) = delete;
- allocator_system(const allocator_system&) = delete;
+ allocator_op& operator=(const allocator_op&) = delete;
+ allocator_op(const allocator_op&) = delete;
- ret_type* claim() noexcept
+ ret_type* claim()
{
return m_alloc_();
}
@@ -68,7 +68,7 @@ namespace ocl
};
template <typename type>
- using standard_allocator_type = allocator_system<type, new_op<type>, delete_op<type>>;
+ using allocator_type = allocator_op<type, new_op<type>, delete_op<type>>;
} // namespace ocl
#endif // ifndef _OCL_ALLOCATOR_SYSTEM_HPP \ No newline at end of file
diff --git a/include/ocl/core/chunk_string.hpp b/include/ocl/core/chunk_string.hpp
index ebcfda3..17d81bd 100644
--- a/include/ocl/core/chunk_string.hpp
+++ b/include/ocl/core/chunk_string.hpp
@@ -1,6 +1,6 @@
/*
* File: core/chunk_string.hpp
- * Purpose: String implementation for the OCL C++ library.
+ * Purpose: Chunked String implementation for the OCL C++ library.
* Author: Amlal El Mahrouss (amlal@nekernel.org)
* Copyright 2025, Amlal El Mahrouss
*/
diff --git a/include/ocl/logic/equiv.hpp b/include/ocl/core/equiv.hpp
index 1bdb6d9..f98d86d 100644
--- a/include/ocl/logic/equiv.hpp
+++ b/include/ocl/core/equiv.hpp
@@ -7,6 +7,8 @@
#pragma once
+#include <core/config.hpp>
+
/// @brief OCL equivalence namespace.
namespace ocl::equiv
{
diff --git a/include/ocl/except/error.hpp b/include/ocl/core/error.hpp
index cf038f8..cf038f8 100644
--- a/include/ocl/except/error.hpp
+++ b/include/ocl/core/error.hpp
diff --git a/include/ocl/core/error_handler.hpp b/include/ocl/core/error_handler.hpp
index dcb0c89..971d91c 100644
--- a/include/ocl/core/error_handler.hpp
+++ b/include/ocl/core/error_handler.hpp
@@ -40,7 +40,6 @@ namespace ocl
}
};
- using standard_error_handler = basic_error_handler;
using error_handler_type = basic_error_handler;
} // namespace ocl
diff --git a/include/ocl/logic/opt.hpp b/include/ocl/core/opt.hpp
index ba76885..506f582 100644
--- a/include/ocl/logic/opt.hpp
+++ b/include/ocl/core/opt.hpp
@@ -7,7 +7,7 @@
#ifndef _OCL_OPT_HPP
#define _OCL_OPT_HPP
-#include <except/error.hpp>
+#include <core/config.hpp>
#include <utility>
namespace ocl
diff --git a/include/ocl/fix/parser.hpp b/include/ocl/fix/parser.hpp
index 02ab50c..3d24cf0 100644
--- a/include/ocl/fix/parser.hpp
+++ b/include/ocl/fix/parser.hpp
@@ -8,11 +8,12 @@
#ifndef _OCL_FIX_PARSER_HPP
#define _OCL_FIX_PARSER_HPP
-#include <algorithm>
#include <core/config.hpp>
-#include <string>
#include <io/print.hpp>
+#include <algorithm>
+#include <string>
+
namespace ocl::fix
{
template <typename char_type>
diff --git a/include/ocl/io/print.hpp b/include/ocl/io/print.hpp
index c710156..9629e05 100644
--- a/include/ocl/io/print.hpp
+++ b/include/ocl/io/print.hpp
@@ -8,6 +8,7 @@
#ifndef _OCL_PRINT_HPP
#define _OCL_PRINT_HPP
+#include <core/config.hpp>
#include <iostream>
namespace ocl::io
@@ -18,9 +19,7 @@ namespace ocl::io
std::cout << fmt;
}
- inline void print() noexcept
- {
- }
+ inline void print() noexcept {}
template <typename... Args>
inline void print(Args... fmt) noexcept
diff --git a/include/ocl/logic/math.hpp b/include/ocl/logic/math.hpp
deleted file mode 100644
index d131ef9..0000000
--- a/include/ocl/logic/math.hpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * File: math.hpp
- * Purpose: Mathematics c++ header.
- * Author: Amlal El Mahrouss (amlal@nekernel.org)
- * Copyright 2025, Amlal El Mahrouss, Licensed under the Boost Software License.
- */
-
-#pragma once
-
-namespace ocl
-{
- template <__SIZE_TYPE__ T>
- struct is_non_boolean_integer final
- {
- static constexpr const bool value = true;
- };
-
- template <>
- struct is_non_boolean_integer<false> final
- {
- static constexpr const bool value = false;
- };
-
- template <>
- struct is_non_boolean_integer<true> final
- {
- static constexpr const bool value = false;
- };
-
- constexpr inline auto not_a_number = __builtin_nanf("");
- constexpr inline auto positive_infinity = __builtin_inff();
- constexpr inline auto negative_infinity = -positive_infinity;
-} // namespace ocl \ No newline at end of file
diff --git a/include/ocl/memory/tracked_ptr.hpp b/include/ocl/memory/tracked_ptr.hpp
deleted file mode 100644
index f763802..0000000
--- a/include/ocl/memory/tracked_ptr.hpp
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * File: memory/tracked_ptr.hpp
- * Purpose: Strict pointer type implementation in C++
- * Author: Amlal El Mahrouss (amlal@nekernel.org)
- * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
- */
-
-#pragma once
-
-#include <cstddef>
-#include <utility>
-#include <new>
-#include <atomic>
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <signal.h>
-
-namespace ocl::memory
-{
- template <typename T>
- class tracked_allocator;
-
- template <typename T>
- class tracked_mgr;
-
- template <typename T, typename Mgr>
- class tracked_ptr;
-
- template <typename T>
- class tracked_allocator
- {
- public:
- std::atomic<size_t> allocated_count_ = 0;
- std::atomic<size_t> deallocated_count_ = 0;
-
- public:
- explicit tracked_allocator() = default;
- virtual ~tracked_allocator() = default;
-
- tracked_allocator& operator=(const tracked_allocator&) = default;
- tracked_allocator(const tracked_allocator&) = default;
-
- public:
- using pointer_type = T*;
-
- template <typename... U>
- void retain(pointer_type& ptr, U&&... args)
- {
- ptr = new T(std::forward<U>(args)...);
-
- if (ptr)
- {
- ++allocated_count_;
- return;
- }
-
- throw std::bad_alloc();
- }
-
- template <typename... U>
- void must_retain(pointer_type& ptr, U&&... args) noexcept
- {
- this->retain(ptr, args...);
- }
-
- void dispose(pointer_type& ptr) noexcept
- {
- if (ptr)
- {
- if (allocated_count_)
- --allocated_count_;
-
- ++deallocated_count_;
-
- delete ptr;
- ptr = nullptr;
- }
- }
- };
-
- template <typename T>
- class tracked_mgr
- {
- private:
- tracked_allocator<T> allocator_;
-
- public:
- explicit tracked_mgr() = default;
- virtual ~tracked_mgr() = default;
-
- tracked_mgr& operator=(const tracked_mgr&) = default;
- tracked_mgr(const tracked_mgr&) = default;
-
- public:
- using pointer_type = T*;
-
- const tracked_allocator<T>& allocator() noexcept
- {
- return allocator_;
- }
-
- template <typename... U>
- pointer_type retain(U&&... args)
- {
- pointer_type ptr = nullptr;
- allocator_.retain(ptr, std::forward<U>(args)...);
-
- return ptr;
- }
-
- template <typename... U>
- pointer_type must_retain(U&&... args) noexcept
- {
- return this->retain(std::forward<U>(args)...);
- }
-
- void dispose(pointer_type& ptr) noexcept
- {
- allocator_.dispose(ptr);
- }
- };
-
- template <typename T, typename Mgr = tracked_mgr<T>>
- class tracked_ptr
- {
- public:
- static Mgr& manager() noexcept
- {
- static Mgr mgr;
- return mgr;
- }
-
- public:
- template <typename... U>
- tracked_ptr(U&&... args)
- : ptr_(nullptr)
- {
- ptr_ = tracked_ptr::manager().retain(std::forward<U>(args)...);
- }
-
- virtual ~tracked_ptr() noexcept
- {
- this->reset();
- }
-
- tracked_ptr(const tracked_ptr&) = delete;
- tracked_ptr& operator=(const tracked_ptr&) = delete;
-
- public:
- using pointer_type = T*;
-
- void reset()
- {
- if (ptr_)
- {
- tracked_ptr::manager().dispose(ptr_);
- }
- }
-
- pointer_type get() const
- {
- return ptr_;
- }
-
- pointer_type data()
- {
- return ptr_;
- }
-
- T& operator*() const
- {
- return *ptr_;
- }
-
- pointer_type operator->() const
- {
- return ptr_;
- }
-
- explicit operator bool() const
- {
- return ptr_ != nullptr;
- }
-
- void swap(tracked_ptr& other)
- {
- std::swap(ptr_, other.ptr_);
- }
-
- public:
- tracked_ptr(tracked_ptr&& other) noexcept
- : ptr_(other.ptr_)
- {
- other.ptr_ = nullptr;
- }
-
- tracked_ptr& operator=(tracked_ptr&& other) noexcept
- {
- if (this != &other)
- {
- this->reset();
- ptr_ = other.ptr_;
- other.ptr_ = nullptr;
- }
-
- return *this;
- }
-
- private:
- pointer_type ptr_{nullptr};
- };
-
- template <typename T>
- inline auto make_tracked() -> tracked_ptr<T>
- {
- return tracked_ptr<T>();
- }
-
- template <typename U, typename... T>
- inline auto make_tracked(T&&... arg) -> tracked_ptr<U>
- {
- return tracked_ptr<U>(std::forward<T>(arg)...);
- }
-
- template <typename T>
- inline void swap(tracked_ptr<T>& a, tracked_ptr<T>& b)
- {
- a.swap(b);
- }
-
- /// @brief a Must Pass function is a standard way to verify a container' validity, inspired from NeKernel/VMKernel.
- template <typename T, typename error_handler>
- inline void must_pass(tracked_ptr<T>& ptr, error_handler handler)
- {
- if (ptr.manager().allocator().allocated_count_ < ptr.manager().allocator().deallocated_count_)
- {
- handler.template error<true>("Invalid TrackedPtr detected: Deallocated count exceeds allocated count.");
- }
- }
-} // namespace ocl::memory
diff --git a/include/ocl/net/modem.hpp b/include/ocl/net/modem.hpp
index 29db748..1e58d1d 100644
--- a/include/ocl/net/modem.hpp
+++ b/include/ocl/net/modem.hpp
@@ -7,7 +7,7 @@
#pragma once
-#include <tests/hpptest.hpp>
+#include <core/config.hpp>
#include <unistd.h>
#include <arpa/inet.h>
@@ -24,8 +24,6 @@
namespace ocl::net
{
- using namespace hpptest;
-
class modem;
/// =============================================================================
diff --git a/include/ocl/net/url.hpp b/include/ocl/net/url.hpp
deleted file mode 100644
index 71c18d6..0000000
--- a/include/ocl/net/url.hpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * File: net/url.hpp
- * Purpose: URL container in modern C++
- * Author: Amlal El Mahrouss (amlal@nekernel.org)
- * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
- */
-
-#pragma once
-
-#include <core/config.hpp>
-
-#include <string>
-#include <sstream>
-
-/// @author Amlal El Mahrouss (amlal@nekernel.org)
-/// @brief Parse URIs/URLs/URNs (Non rfc3986 compliant.)
-
-namespace ocl::net
-{
- template <typename char_type>
- class basic_url;
-
- /// @brief Basic URL parser container.
- template <typename char_type>
- class basic_url final
- {
- public:
- enum
- {
- invalid = 0,
- http = 100,
- https,
- file,
- ftp,
- mailto = 200,
- tel,
- bad = 0xff,
- };
-
- private:
- auto to_string_()
- {
- if (m_protocol_ == https)
- return "https://";
-
- if (m_protocol_ == http)
- return "http://";
-
- if (m_protocol_ == file)
- return "file://";
-
- if (m_protocol_ == tel)
- return "tel:";
-
- if (m_protocol_ == mailto)
- return "mailto:";
-
- return "invalid:";
- }
-
- auto to_enum_(const std::basic_string<char_type>& protocol)
- {
- if (protocol == "https")
- return https;
-
- if (protocol == "http")
- return http;
-
- if (protocol == "file")
- return file;
-
- if (protocol == "tel")
- return tel;
-
- if (protocol == "mailto")
- return mailto;
-
- return invalid;
- }
-
- uint32_t m_protocol_{basic_url::invalid};
- std::basic_stringstream<char_type> m_ss_{};
- std::basic_string<char_type> m_port_{""};
-
- public:
- using ref_type = basic_url&;
-
- explicit basic_url(const uint32_t& protocol)
- {
- m_protocol_ = protocol;
- }
-
- ~basic_url() = default;
-
- basic_url& operator=(const basic_url&) = default;
- basic_url(const basic_url&) = default;
-
- public:
- ref_type operator/=(const std::basic_string<char_type>& in)
- {
- if (in.empty())
- return *this;
-
- if (in.starts_with(":"))
- {
- if (m_protocol_ == tel || m_protocol_ == mailto)
- return *this;
-
- m_port_ = in.substr(1);
- }
- else if (in.starts_with("+"))
- {
- if (m_protocol_ != tel)
- return *this;
-
- for (auto& ch : in)
- {
- if (ch == ' ')
- return *this;
- }
- }
-
- m_ss_ << in;
-
- if (!in.ends_with("/"))
- m_ss_ << "/";
-
- return *this;
- }
-
- explicit operator bool()
- {
- return this->is_valid();
- }
-
- public:
- uint32_t protocol() const noexcept
- {
- return this->m_protocol_;
- }
-
- std::basic_string<char_type> port() const noexcept
- {
- return this->m_port_;
- }
-
- std::basic_string<char_type> assemble() noexcept
- {
- std::basic_string<char_type> out = to_string_();
- out += this->m_ss_.str();
-
- out.pop_back();
-
- return out;
- }
-
- bool is_valid() const noexcept
- {
- return m_ss_.size() > 0 && this->m_protocol_ != basic_url::bad || this->m_protocol_ != basic_url::invalid;
- }
- };
-
- using url = basic_url<char>;
-} // namespace ocl::net
diff --git a/include/ocl/simd/basic_simd.hpp b/include/ocl/simd/basic_simd.hpp
deleted file mode 100644
index d9d405e..0000000
--- a/include/ocl/simd/basic_simd.hpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * File: simd/basic_simd.hpp
- * Purpose: Basic SIMD backend C++ library.
- * Author: Amlal El Mahrouss (amlal@nekernel.org)
- * Copyright 2025, Amlal El Mahrouss, licensed under the BSL 1.0 license.
- */
-
-#pragma once
-
-#include <core/config.hpp>
-
-#ifdef __x86_64__
-#include <immintrin.h>
-#endif
-
-#ifdef __aarch64__
-#include <arm_neon.h>
-#endif
-
-namespace ocl::simd
-{
- struct OCL_DEPRECATED_MSG("Unmaintained since v1.0.51") basic_simd final
- {
-#ifdef __x86_64__
- using simd_type = __m256;
-#endif
-
-#ifdef __aarch64__
- using simd_type = float32x4_t;
-#endif
-
- struct simd_traits final
- {
- simd_type __val;
-
- private:
- static bool bad;
- friend class basic_simd;
- };
-
- using register_type = simd_traits;
-
- const bool& is_bad() noexcept
- {
- return register_type::bad;
- }
-
- std::basic_string<char> isa()
- {
- return "basic_simd";
- }
- };
-} // namespace ocl::simd
diff --git a/include/ocl/simd/simd.hpp b/include/ocl/simd/simd.hpp
deleted file mode 100644
index 14d6922..0000000
--- a/include/ocl/simd/simd.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * File: simd/simd.hpp
- * Purpose: SIMD C++ library.
- * Author: Amlal El Mahrouss (amlal@nekernel.org)
- * Copyright 2025, Amlal El Mahrouss, licensed under the BSL 1.0 license.
- */
-
-#pragma once
-
-#include <core/config.hpp>
-
-/// @author Amlal El Mahrouss
-/// @brief Basic SIMD processor.
-
-namespace ocl::simd
-{
- template <typename backend_type>
- class OCL_DEPRECATED_MSG("Unmaintained since v1.0.51") real_type
- {
- private:
- backend_type backend_;
-
- enum opcode
- {
- bad = 0,
- add,
- mul,
- div,
- invalid = 0xfff,
- };
-
- public:
- real_type() = default;
- virtual ~real_type() = default;
-
- real_type& operator=(const real_type&) = delete;
- real_type(const real_type&) = delete;
-
- typename backend_type::register_type& call(const opcode& op, typename backend_type::register_type& lhs, typename backend_type::register_type& rhs)
- {
- switch (op)
- {
- case add:
- return backend_.add(lhs, rhs);
- case mul:
- return backend_.mul(lhs, rhs);
- case div:
- return backend_.div(lhs, rhs);
- default:
- break;
- }
-
- return backend_.is_bad();
- }
-
- std::basic_string<char> isa()
- {
- return backend_.isa();
- }
- };
-} // namespace ocl::simd
diff --git a/include/ocl/tests/gtest.hpp b/include/ocl/tests/gtest.hpp
deleted file mode 100644
index ee328b0..0000000
--- a/include/ocl/tests/gtest.hpp
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * File: tests/gtest.hpp
- * Purpose: Google Test wrapper 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 <gtest/gtest.h>
diff --git a/include/ocl/tests/hpptest.hpp b/include/ocl/tests/hpptest.hpp
deleted file mode 100644
index 0b5c54e..0000000
--- a/include/ocl/tests/hpptest.hpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * File: tests/hpptest.hpp
- * Purpose: HPP Test wrapper 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 <core/config.hpp>
-#include <io/print.hpp>
-#include <string.h>
-#include <unistd.h>
-
-namespace ocl::hpptest
-{
- /// @brief Standard termination error handler, called when a test fails.
- struct standard_terminate final
- {
- template <bool stop_execution = true>
- static void error() noexcept
- {
- ocl::io::print("standard_terminate::error, terminating...\n");
-
- if (stop_execution)
- std::terminate();
- }
- };
-
-#ifdef __linux__
- using errno_t = error_t;
-#endif
-
- struct posix_terminate final
- {
- template <bool stop_execution = true, errno_t args>
- static void error(errno_t err) noexcept
- {
- ocl::io::print("posix_terminate::error: expected=", strerror(args), ", got=", strerror(err), "\n");
-
- if (stop_execution)
- std::terminate();
- }
- };
-
- typedef bool condition_type;
-
- template <condition_type expr = true>
- consteval inline void must_pass()
- {
-#ifdef OCL_HPPTEST
- OCL_HPPTEST_ASSERT(expr);
-#endif // _WIN32
- }
-
- template <condition_type expect, typename on_fail>
- inline void must_pass(condition_type cond) noexcept
- {
- if (cond != expect)
- {
- on_fail::template error<true>();
- }
- }
-
- template <errno_t expect = 0>
- inline void must_pass(errno_t ern) noexcept
- {
- if (ern != expect)
- {
- posix_terminate::error<true, expect>(ern);
- }
- }
-
-#ifdef _WIN32
- struct win32_terminate final
- {
- template <bool stop_execution = false>
- static void error(HRESULT err) noexcept
- {
- ocl::io::print("win32_terminate::error: expected=S_OK, got=", err, "\n");
-
- if (stop_execution)
- std::terminate();
- }
- };
-
- template <HRESULT expect = S_OK>
- inline void must_pass(HRESULT hr) noexcept
- {
- if (hr != expect)
- {
- win32_terminate::error<true>(hr);
- }
- }
-#endif // _WIN32
-} // namespace ocl::hpptest
diff --git a/include/ocl/utility/cgi.hpp b/include/ocl/utility/cgi.hpp
deleted file mode 100644
index 8849c2d..0000000
--- a/include/ocl/utility/cgi.hpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * File: cgi.hpp
- * Author: Amlal El Mahrouss,
- * Copyright 2023-2025, Amlal El Mahrouss, Licensed under the Boost Software License.
- */
-
-#ifndef _OCL_CGI_HPP
-#define _OCL_CGI_HPP
-
-#include <io/print.hpp>
-#include <core/chunk_string.hpp>
-#include <sstream>
-#include <format>
-
-namespace ocl
-{
- namespace cgi
- {
- /// @brief CGI Writer class, writes to stdout; as CGI expects.
- template <typename char_type = char>
- class basic_writer
- {
- private:
- basic_writer& eval_(const basic_chunk_string<char_type>& mime, const basic_chunk_string<char_type>& ss) noexcept
- {
- std::basic_stringstream<char_type> ss_out;
-
- ss_out << std::format("Content-Type: {}\r\n", mime.str());
- ss_out << std::format("Server: {}\r\n", "OCL/1.0");
- ss_out << std::format("Content-Length: {}\r\n\r\n", ss.str().size());
- ss_out << ss.str();
-
- io::print(ss_out.str());
-
- return *this;
- }
-
- public:
- explicit basic_writer() = default;
- virtual ~basic_writer() = default;
-
- basic_writer& operator=(const basic_writer&) = default;
- basic_writer(const basic_writer&) = default;
-
- public:
- friend void operator<<(basic_writer& self, const basic_chunk_string<char_type>& ss_in)
- {
- self = self.eval_("text/plain", ss_in);
- }
-
- basic_writer& binary(const basic_chunk_string<char_type>& ss_in)
- {
- return this->eval_("application/octet-stream", ss_in);
- }
-
- basic_writer& html(const basic_chunk_string<char_type>& ss_in)
- {
- return this->eval_("text/html", ss_in);
- }
-
- basic_writer& xml(const basic_chunk_string<char_type>& ss_in)
- {
- return this->eval_("application/xml", ss_in);
- }
-
- basic_writer& json(const basic_chunk_string<char_type>& ss_in)
- {
- return this->eval_("application/json", ss_in);
- }
-
- basic_writer& js(const basic_chunk_string<char_type>& ss_in)
- {
- return this->eval_("text/javascript", ss_in);
- }
- };
- } // namespace cgi
-} // namespace ocl
-
-#endif // ifndef _OCL_CGI_HPP
diff --git a/include/ocl/utility/embfs.hpp b/include/ocl/utility/embfs.hpp
deleted file mode 100644
index 8a716ce..0000000
--- a/include/ocl/utility/embfs.hpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * File: embfs.hpp
- * Purpose: Embedded File System.
- * Author: Amlal El Mahrouss (amlal@nekernel.org)
- * Copyright 2025, Amlal El Mahrouss, Licensed under the Boost Software License.
- */
-
-#ifndef _OCL_EMBFS_HPP
-#define _OCL_EMBFS_HPP
-
-#include <cstdint>
-#include <cstddef>
-
-/// @brief A filesystem designed for tiny storage medias.
-/// @author Amlal EL Mahrouss (amlal@nekernel.org)
-
-namespace ocl::embfs
-{
- namespace traits
- {
- struct embfs_superblock;
- struct embfs_inode;
-
- inline constexpr const size_t _superblock_name_len = 16;
- inline constexpr const size_t _superblock_reserve_len = 462;
-
- inline constexpr const size_t _inode_name_len = 128;
- inline constexpr const size_t _inode_arr_len = 12;
- inline constexpr const size_t _inode_lookup_len = 8;
-
-#if defined(EMBFS_28BIT_LBA)
- typedef std::uint32_t lba_t;
-#elif defined(EMBFS_48BIT_LBA)
- typedef std::uint64_t lba_t;
-#else
- typedef std::uint32_t lba_t;
-#endif
-
- typedef std::int16_t sword_t;
-
- typedef std::int32_t sdword_t;
-
- typedef std::uint8_t utf8_char_t;
-
- /// @brief Superblock data structure
- struct embfs_superblock
- {
- sword_t s_block_mag;
- sdword_t s_num_inodes;
- sdword_t s_part_size;
- sdword_t s_part_used;
- sdword_t s_version;
- sword_t s_sector_sz;
- lba_t s_inode_start;
- lba_t s_inode_end;
- utf8_char_t s_name[_superblock_name_len];
- utf8_char_t s_reserved[_superblock_reserve_len];
- };
-
- /// @brief Indexed node structure.
- /// @brief i_name file name
- /// @brief i_size_virt, i_size_phys: virtual and physical (sector count) size.
- /// @brief i_offset direct block pointer.
- /// @brief i_checksum crc32 checksum.
- /// @brief i_flags_perms flags and permissions
- /// @brief i_acl_* ACL to keep track of inode allocation status.
- struct embfs_inode
- {
- utf8_char_t i_name[_inode_name_len];
- sword_t i_size_virt, i_size_phys;
- lba_t i_offset[_inode_lookup_len];
- sword_t i_checksum, i_flags_perms;
- lba_t i_acl_creat, i_acl_edit, i_acl_delet;
- };
-
- /// @brief Indexed node linear array.
- typedef embfs_inode embfs_inode_arr_t[_inode_arr_len];
- } // namespace traits
-} // namespace ocl::embfs
-
-#endif // ifndef _OCL_EMBFS_HPP \ No newline at end of file
diff --git a/make_dist_linux.sh b/make_dist_linux.sh
deleted file mode 100755
index d576b98..0000000
--- a/make_dist_linux.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#! /bin/sh
-
-outputDir=dist/include/ocl/
-
-mkdir -p $outputDir
-mkdir -p $outputDir'fix'
-mkdir -p $outputDir'io'
-mkdir -p $outputDir'except'
-mkdir -p $outputDir'core'
-mkdir -p $outputDir'logic'
-mkdir -p $outputDir'memory'
-mkdir -p $outputDir'net'
-mkdir -p $outputDir'simd'
-mkdir -p $outputDir'tests'
-mkdir -p $outputDir'utility'
-mkdir -p 'dist/tools'
-
-outputDirCmd=dist/
-outputDirTools=dist/
-
-for f in include/ocl/*/*.hpp; do
-baseName=`echo $f | cut -d "." -f 1`
-echo "RUN:" cp $f $outputDir$baseName'.hpp'
-cp $f $outputDirCmd$baseName'.hpp'
-done
-
-for f in tools/*.py; do
-baseName=`echo $f | cut -d "." -f 1`
-echo "RUN:" cp $baseName'.py' $outputDirTools$baseName'.py'
-cp $baseName'.py' $outputDirTools$baseName'.py'
-done
diff --git a/make_dist_osx.sh b/make_dist_osx.sh
deleted file mode 100755
index f6796f4..0000000
--- a/make_dist_osx.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#! /bin/sh
-
-outputDir=dist/
-
-mkdir -p $outputDir
-
-for f in include/ocl/*/*.hpp; do
-baseName=`echo $f | cut -d "." -f 1`
-echo "RUN:" ditto $baseName.hpp $outputDir$baseName'.hpp'
-ditto $baseName.hpp $outputDir$baseName'.hpp'
-done
-
-for f in tools/*.py; do
-baseName=`echo $f | cut -d "." -f 1`
-echo "RUN:" ditto $baseName.py $outputDir$baseName
-ditto $baseName.py $outputDir$baseName'.py'
-done
diff --git a/meta/tex/embfs.tex b/meta/tex/embfs.tex
deleted file mode 100644
index 2d5c60e..0000000
--- a/meta/tex/embfs.tex
+++ /dev/null
@@ -1,141 +0,0 @@
-\documentclass{article}
-\usepackage[a4paper,margin=1in]{geometry}
-\usepackage{listings}
-\usepackage{xcolor}
-\usepackage{amsmath}
-\usepackage{hyperref}
-\usepackage{longtable}
-\usepackage{graphicx}
-\usepackage{fancyhdr}
-\usepackage{titlesec}
-\usepackage{caption}
-
-\titleformat{\section}{\normalfont\Large\bfseries}{\thesection}{1em}{}
-
-\definecolor{codegray}{gray}{0.95}
-\lstset{
- backgroundcolor=\color{codegray},
- basicstyle=\ttfamily\small,
- breaklines=true,
- frame=single,
- tabsize=4,
- language=C++,
- showstringspaces=false
-}
-
-\title{Embedded File System (EMBFS) Specification}
-\author{Amlal El Mahrouss}
-\date{\today}
-
-\begin{document}
-
-\maketitle
-
-\section{Overview}
-The \textbf{Embedded File System (EMBFS)} is a compact and minimal filesystem designed for use in embedded environments with limited storage media. This specification describes its key data structures, constants, and layout.
-
-\section{Namespace}
-The EMBFS implementation resides under:
-\begin{lstlisting}
-namespace ocl::embfs
-\end{lstlisting}
-
-\section{Supported Logical Block Addressing (LBA) Modes}
-Two LBA addressing modes are supported via macro definitions:
-\begin{itemize}
- \item \texttt{EMBFS\_28BIT\_LBA} — Uses \texttt{uint32\_t}.
- \item \texttt{EMBFS\_48BIT\_LBA} — Uses \texttt{uint64\_t}.
-\end{itemize}
-
-\section{Fundamental Types}
-\begin{longtable}{|l|l|}
-\hline
-\textbf{Type} & \textbf{Definition} \\
-\hline
-\texttt{lba\_t} & 28-bit or 48-bit logical block address \\
-\texttt{sword\_t} & \texttt{int16\_t} \\
-\texttt{sdword\_t} & \texttt{int32\_t} \\
-\texttt{utf8\_char\_t} & \texttt{uint8\_t}, used for file names and labels \\
-\hline
-\end{longtable}
-
-\section{Constants}
-\begin{longtable}{|l|l|}
-\hline
-\textbf{Constant} & \textbf{Description} \\
-\hline
-\texttt{\_superblock\_name\_len} & Length of superblock name (16 bytes) \\
-\texttt{\_superblock\_reserve\_len} & Reserved bytes in superblock (462 bytes) \\
-\texttt{\_inode\_name\_len} & Length of inode file name (128 bytes) \\
-\texttt{\_inode\_arr\_len} & Number of inodes per partition (12) \\
-\texttt{\_inode\_lookup\_len} & Number of direct LBA pointers in inode (8) \\
-\hline
-\end{longtable}
-
-\section{Superblock Structure}
-\textbf{Structure:} \texttt{embfs\_superblock}
-\begin{lstlisting}
-struct embfs_superblock {
- sword_t s_block_mag;
- sdword_t s_num_inodes;
- sdword_t s_part_size;
- sdword_t s_part_used;
- sdword_t s_version;
- sword_t s_sector_sz;
- lba_t s_inode_start;
- lba_t s_inode_end;
- utf8_char_t s_name[16];
- utf8_char_t s_reserved[462];
-};
-\end{lstlisting}
-
-\textbf{Description:}
-\begin{itemize}
- \item \texttt{s\_block\_mag} — Magic number identifying the filesystem
- \item \texttt{s\_num\_inodes} — Total number of inodes
- \item \texttt{s\_part\_size} — Total size of the partition (in sectors)
- \item \texttt{s\_part\_used} — Used size of the partition
- \item \texttt{s\_version} — Filesystem version
- \item \texttt{s\_sector\_sz} — Sector size (in bytes)
- \item \texttt{s\_inode\_start}, \texttt{s\_inode\_end} — LBA range where inodes are stored
- \item \texttt{s\_name} — Filesystem label
- \item \texttt{s\_reserved} — Reserved for future use
-\end{itemize}
-
-\section{Inode Structure}
-\textbf{Structure:} \texttt{embfs\_inode}
-\begin{lstlisting}
-struct embfs_inode {
- utf8_char_t i_name[128];
- sword_t i_size_virt, i_size_phys;
- lba_t i_offset[8];
- sword_t i_checksum, i_flags_perms;
- lba_t i_acl_creat, i_acl_edit, i_acl_delet;
-};
-\end{lstlisting}
-
-\textbf{Description:}
-\begin{itemize}
- \item \texttt{i\_name} — UTF-8 encoded file name
- \item \texttt{i\_size\_virt} — Virtual file size (logical size)
- \item \texttt{i\_size\_phys} — Physical size in sectors
- \item \texttt{i\_offset} — Array of direct LBA pointers
- \item \texttt{i\_checksum} — CRC32 checksum of file contents
- \item \texttt{i\_flags\_perms} — Flags and permissions field
- \item \texttt{i\_acl\_creat}, \texttt{i\_acl\_edit}, \texttt{i\_acl\_delet} — ACLs for access control
-\end{itemize}
-
-\section{Inode Array Type}
-\begin{lstlisting}
-typedef embfs_inode embfs_inode_arr_t[12];
-\end{lstlisting}
-Represents a fixed-size array of 12 inodes within a given partition.
-
-\section{License}
-\begin{itemize}
- \item Copyright © 2025 Amlal El Mahrouss
- \item All rights reserved.
- \item For questions or licensing requests, contact: \texttt{amlal@nekernel.org}
-\end{itemize}
-
-\end{document} \ No newline at end of file
diff --git a/tests/chunk_string/chunk_test.cc b/tests/chunk_string/chunk_test.cc
index 6b2d290..37f5cb1 100644
--- a/tests/chunk_string/chunk_test.cc
+++ b/tests/chunk_string/chunk_test.cc
@@ -6,26 +6,17 @@
*/
#include <io/print.hpp>
-#include <tests/gtest.hpp>
+#include <gtest/gtest.h>
#include <core/chunk_string.hpp>
+const char* test_string = "HELLO, WORLD!\r\n";
+const auto iterations = 1024000;
+const auto limit = 30;
+
TEST(ChunkTest, BasicChunkUsage)
{
- const char* test_string = "HELLO, WORLD!\r\n";
- const auto iterations = 1024000;
- const auto limit = 30;
-
- auto start = std::chrono::high_resolution_clock::now();
-
ocl::basic_chunk_string<char, iterations> optimized;
-
- for (unsigned i = 0; i < iterations; ++i)
- {
- optimized += test_string;
- }
-
- auto end = std::chrono::high_resolution_clock::now();
- auto optimized_time = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
-
- EXPECT_TRUE(optimized_time.count() < 100U);
+ optimized += test_string;
+
+ EXPECT_TRUE(optimized.str() == test_string);
}
diff --git a/tests/fix_basic/fix_test.cc b/tests/fix_basic/fix_test.cc
index 122d918..84ab290 100644
--- a/tests/fix_basic/fix_test.cc
+++ b/tests/fix_basic/fix_test.cc
@@ -6,24 +6,23 @@
*/
#include <fix/parser.hpp>
-#include <tests/hpptest.hpp>
-#include <tests/gtest.hpp>
+#include <gtest/gtest.h>
+
+constexpr const char default_fix[] = {
+ '8', '=', 'F', 'I', 'X', '.', '4', '.', '2', 0x01,
+ '9', '=', '6', '3', 0x01, // BodyLength = 63
+ '3', '5', '=', 'A', 0x01,
+ '4', '9', '=', 'S', 'E', 'R', 'V', 'E', 'R', 0x01,
+ '5', '6', '=', 'C', 'L', 'I', 'E', 'N', 'T', 0x01,
+ '3', '4', '=', '1', '7', '7', 0x01,
+ '5', '2', '=', '2', '0', '0', '9', '0', '1', '0', '7', '-', '1', '8', ':', '1', '5', ':', '1', '6', 0x01,
+ '9', '8', '=', '0', 0x01,
+ '1', '0', '8', '=', '3', '0', 0x01,
+ '1', '0', '=', '1', '4', '3', 0x01, 0x00 // CheckSum = 143
+};
TEST(FIXTest, BasicFIXUsage)
{
- constexpr const char default_fix[] = {
- '8', '=', 'F', 'I', 'X', '.', '4', '.', '2', 0x01,
- '9', '=', '6', '3', 0x01, // BodyLength = 63
- '3', '5', '=', 'A', 0x01,
- '4', '9', '=', 'S', 'E', 'R', 'V', 'E', 'R', 0x01,
- '5', '6', '=', 'C', 'L', 'I', 'E', 'N', 'T', 0x01,
- '3', '4', '=', '1', '7', '7', 0x01,
- '5', '2', '=', '2', '0', '0', '9', '0', '1', '0', '7', '-', '1', '8', ':', '1', '5', ':', '1', '6', 0x01,
- '9', '8', '=', '0', 0x01,
- '1', '0', '8', '=', '3', '0', 0x01,
- '1', '0', '=', '1', '4', '3', 0x01, 0x00 // CheckSum = 143
- };
-
ocl::fix::basic_visitor<char> basic_visitor;
ocl::fix::basic_range_data<char> fix = basic_visitor.visit(default_fix);
diff --git a/tests/network_basic/network_basic_test.cc b/tests/network_basic/network_basic_test.cc
index 22f5aab..cb218c8 100644
--- a/tests/network_basic/network_basic_test.cc
+++ b/tests/network_basic/network_basic_test.cc
@@ -7,8 +7,7 @@
#include <net/modem.hpp>
#include <io/print.hpp>
-#include <tests/gtest.hpp>
-#include <cstring>
+#include <gtest/gtest.h>
/// @brief Basic Send Test
TEST(NetworkTest, BasicNetworkTransmit)
diff --git a/tests/tracked_ptr_basic/CMakeLists.txt b/tests/tracked_ptr_basic/CMakeLists.txt
deleted file mode 100644
index 7c3dac6..0000000
--- a/tests/tracked_ptr_basic/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-cmake_minimum_required(VERSION 3.10)
-project(TrackedPtrTestBasic)
-
-include(FetchContent)
-FetchContent_Declare(
- googletest
- URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
-)
-
-# For Windows: Prevent overriding the parent project's compiler/linker settings
-set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
-FetchContent_MakeAvailable(googletest)
-
-enable_testing()
-
-add_executable(TrackedPtrTestBasic tracked_ptr_test.cc)
-target_link_libraries(TrackedPtrTestBasic gtest_main)
-
-set_property(TARGET TrackedPtrTestBasic PROPERTY CXX_STANDARD 20)
-target_include_directories(TrackedPtrTestBasic PUBLIC ../../include/ocl)
-
-include(GoogleTest)
-gtest_discover_tests(TrackedPtrTestBasic)
diff --git a/tests/tracked_ptr_basic/tracked_ptr_test.cc b/tests/tracked_ptr_basic/tracked_ptr_test.cc
deleted file mode 100644
index 652974a..0000000
--- a/tests/tracked_ptr_basic/tracked_ptr_test.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * File: tests/tracked_ptr_test.cc
- * Purpose: Custom smart pointer unit tests in C++
- * Author: Amlal El Mahrouss (amlal@nekernel.org)
- * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
- */
-
-#include <memory/tracked_ptr.hpp>
-#include <tests/gtest.hpp>
-
-TEST(TrackedPtrTest, BasicTrackedPtrUsage)
-{
- ocl::memory::tracked_ptr<int> ptr = ocl::memory::make_tracked<int>(42);
-
- ASSERT_TRUE(ptr);
- EXPECT_EQ(*ptr, 42);
-
- ocl::memory::tracked_ptr<int> ptr2;
-
- ocl::memory::swap(ptr, ptr2);
-
- ptr2.reset();
-
- EXPECT_EQ(ocl::memory::tracked_ptr<int>::manager().allocator().allocated_count_, 1);
-} \ No newline at end of file
diff --git a/tests/tracked_ptr_leak/CMakeLists.txt b/tests/tracked_ptr_leak/CMakeLists.txt
deleted file mode 100644
index 314e666..0000000
--- a/tests/tracked_ptr_leak/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-cmake_minimum_required(VERSION 3.10)
-project(TrackedPtrTestLeak)
-
-include(FetchContent)
-FetchContent_Declare(
- googletest
- URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
-)
-
-# For Windows: Prevent overriding the parent project's compiler/linker settings
-set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
-FetchContent_MakeAvailable(googletest)
-
-enable_testing()
-
-add_executable(TrackedPtrTestLeak tracked_ptr_test.cc)
-target_link_libraries(TrackedPtrTestLeak gtest_main)
-
-set_property(TARGET TrackedPtrTestLeak PROPERTY CXX_STANDARD 20)
-target_include_directories(TrackedPtrTestLeak PUBLIC ../../include/ocl)
-
-include(GoogleTest)
-gtest_discover_tests(TrackedPtrTestLeak)
diff --git a/tests/tracked_ptr_leak/tracked_ptr_test.cc b/tests/tracked_ptr_leak/tracked_ptr_test.cc
deleted file mode 100644
index 14d8f8e..0000000
--- a/tests/tracked_ptr_leak/tracked_ptr_test.cc
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * File: tests/tracked_ptr_test.cc
- * Purpose: Custom smart pointer unit tests in C++
- * Author: Amlal El Mahrouss (amlal@nekernel.org)
- * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
- */
-
-#include <memory/tracked_ptr.hpp>
-#include <tests/gtest.hpp>
-
-TEST(TrackedPtrTest, LeakTrackedPtrUsage)
-{
- ocl::memory::tracked_ptr<int>* ptr = new ocl::memory::tracked_ptr<int>(42);
- ocl::memory::tracked_ptr<int>* ptr2 = new ocl::memory::tracked_ptr<int>(42);
- ocl::memory::tracked_ptr<int>* ptr3 = new ocl::memory::tracked_ptr<int>(42);
-
- EXPECT_EQ(ocl::memory::tracked_ptr<int>::manager().allocator().allocated_count_, 3);
- ASSERT_TRUE(ocl::memory::tracked_ptr<int>::manager().allocator().deallocated_count_ == 0);
-} \ No newline at end of file
diff --git a/tools/hpptest.py b/tools/hpptest.py
deleted file mode 100755
index 76366c1..0000000
--- a/tools/hpptest.py
+++ /dev/null
@@ -1,22 +0,0 @@
-#! /usr/bin/env python3
-# -*- coding: utf-8 -*-
-
-# HPPTEST: Header-only C++ library test runner.
-# Author: Amlal El Mahrouss.
-# License Boost Software License 1.0
-
-import sys, os
-
-CXX_COMPILER="clang++"
-CXX_INCLUDE_DIR="./include/"
-CXX_STD="c++20"
-
-# Runs a simple compilation command to check if the test passes or not.
-if __name__ == '__main__':
- if len(sys.argv) == 3:
- ret = os.system(f"{CXX_COMPILER} -I{CXX_INCLUDE_DIR} -I{sys.argv[2]} -std={CXX_STD} -DOCL_HPPTEST '-DOCL_HPPTEST_ASSERT(x)=static_assert(x, #x)' {sys.argv[1]}")
- if ret == 0:
- print("[HPPTEST] TEST PASS.")
- else:
- print(f"[HPPTEST] TEST FAILED: RETURN CODE: {ret}")
- print(f"COMMAND: {CXX_COMPILER} -I{CXX_INCLUDE_DIR} -I{sys.argv[2]} -std={CXX_STD} -DOCL_HPPTEST '-DOCL_HPPTEST_ASSERT(x)=static_assert(x, #x)' {sys.argv[1]}")