From a8e99f3a783069cf85b626c6cfb2fbe83ae4fd44 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 29 Nov 2025 14:53:01 -0500 Subject: chore: new version of OCL and codebase cleanup. Signed-off-by: Amlal El Mahrouss --- examples/.keep | 0 examples/allocator_system/CMakeLists.txt | 16 ------ examples/allocator_system/allocator_system.cc | 53 ------------------- examples/cgi/CMakeLists.txt | 16 ------ examples/cgi/cgi.cc | 75 --------------------------- examples/equiv/CMakeLists.txt | 12 ----- examples/equiv/equiv.cc | 19 ------- examples/fix/CMakeLists.txt | 15 ------ examples/fix/fix.cc | 47 ----------------- examples/fix_tag_example/CMakeLists.txt | 15 ++++++ examples/fix_tag_example/example.cc | 30 +++++++++++ examples/opt/CMakeLists.txt | 12 ----- examples/opt/opt.cc | 45 ---------------- examples/tracked_ptr/CMakeLists.txt | 12 ----- examples/tracked_ptr/tracked_ptr.cc | 53 ------------------- examples/url/CMakeLists.txt | 15 ------ examples/url/url.cc | 24 --------- 17 files changed, 45 insertions(+), 414 deletions(-) create mode 100644 examples/.keep delete mode 100644 examples/allocator_system/CMakeLists.txt delete mode 100644 examples/allocator_system/allocator_system.cc delete mode 100644 examples/cgi/CMakeLists.txt delete mode 100644 examples/cgi/cgi.cc delete mode 100644 examples/equiv/CMakeLists.txt delete mode 100644 examples/equiv/equiv.cc delete mode 100644 examples/fix/CMakeLists.txt delete mode 100644 examples/fix/fix.cc create mode 100644 examples/fix_tag_example/CMakeLists.txt create mode 100644 examples/fix_tag_example/example.cc delete mode 100644 examples/opt/CMakeLists.txt delete mode 100644 examples/opt/opt.cc delete mode 100644 examples/tracked_ptr/CMakeLists.txt delete mode 100644 examples/tracked_ptr/tracked_ptr.cc delete mode 100644 examples/url/CMakeLists.txt delete mode 100644 examples/url/url.cc (limited to 'examples') diff --git a/examples/.keep b/examples/.keep new file mode 100644 index 0000000..e69de29 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 -#include - -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 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(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 - -static ocl::basic_chunk_string text_sample = R"( - - - - - Error | OCL - - - -

Uh Oh!

-
No index file was found in this directory.
-
- - - - - - - - - -
Name

Refresh

-
OCL's Common Gateway Server.
- - -)"; - -/* 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 -#include - -/* finally test it */ -int main(int argc, char** argv) -{ - std::cout << std::boolalpha; - std::cout << ocl::equiv::is_same::value << std::endl; - std::cout << ocl::equiv::is_same::value << std::endl; - std::cout << ocl::equiv::is_same::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 -#include -#include -#include -#include -#include - -/* 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 basic_visitor; - ocl::fix::basic_range_data 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(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 +#include +#include + +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 -#include -#include -#include - -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 -#include - -static void summon_tracked_ptr() -{ - ocl::memory::tracked_ptr ptr = ocl::memory::make_tracked(42); - std::cout << ptr.data() << "=" << ptr.manager().allocator().allocated_count_ << std::endl; -} - -static void summon_leak_tracked_ptr() -{ - ocl::memory::tracked_ptr* ptr = new ocl::memory::tracked_ptr(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 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 -#include -#include -#include -#include - -/* 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; -} -- cgit v1.2.3