From 65a8349aa5526d071b18cd4d42586c46faaa3823 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 24 Nov 2025 02:13:48 +0100 Subject: feat! breaking changes for OCL v1.0.48. Signed-off-by: Amlal El Mahrouss --- dev/examples/allocator_system/CMakeLists.txt | 16 ----- dev/examples/allocator_system/allocator_system.cc | 53 ---------------- dev/examples/cgi/CMakeLists.txt | 16 ----- dev/examples/cgi/cgi.cc | 75 ----------------------- dev/examples/equiv/CMakeLists.txt | 12 ---- dev/examples/equiv/equiv.cc | 19 ------ dev/examples/fix/CMakeLists.txt | 15 ----- dev/examples/fix/fix.cc | 37 ----------- dev/examples/opt/CMakeLists.txt | 12 ---- dev/examples/opt/opt.cc | 45 -------------- dev/examples/tracked_ptr/CMakeLists.txt | 12 ---- dev/examples/tracked_ptr/tracked_ptr.cc | 52 ---------------- 12 files changed, 364 deletions(-) delete mode 100644 dev/examples/allocator_system/CMakeLists.txt delete mode 100644 dev/examples/allocator_system/allocator_system.cc delete mode 100644 dev/examples/cgi/CMakeLists.txt delete mode 100644 dev/examples/cgi/cgi.cc delete mode 100644 dev/examples/equiv/CMakeLists.txt delete mode 100644 dev/examples/equiv/equiv.cc delete mode 100644 dev/examples/fix/CMakeLists.txt delete mode 100644 dev/examples/fix/fix.cc delete mode 100644 dev/examples/opt/CMakeLists.txt delete mode 100644 dev/examples/opt/opt.cc delete mode 100644 dev/examples/tracked_ptr/CMakeLists.txt delete mode 100644 dev/examples/tracked_ptr/tracked_ptr.cc (limited to 'dev/examples') diff --git a/dev/examples/allocator_system/CMakeLists.txt b/dev/examples/allocator_system/CMakeLists.txt deleted file mode 100644 index ee19842..0000000 --- a/dev/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 ../../) diff --git a/dev/examples/allocator_system/allocator_system.cc b/dev/examples/allocator_system/allocator_system.cc deleted file mode 100644 index 6bf1de7..0000000 --- a/dev/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/dev/examples/cgi/CMakeLists.txt b/dev/examples/cgi/CMakeLists.txt deleted file mode 100644 index 9c3cbf6..0000000 --- a/dev/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 ../../) diff --git a/dev/examples/cgi/cgi.cc b/dev/examples/cgi/cgi.cc deleted file mode 100644 index 3eef7b2..0000000 --- a/dev/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/dev/examples/equiv/CMakeLists.txt b/dev/examples/equiv/CMakeLists.txt deleted file mode 100644 index 8b29e23..0000000 --- a/dev/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 ../../) diff --git a/dev/examples/equiv/equiv.cc b/dev/examples/equiv/equiv.cc deleted file mode 100644 index 41128a2..0000000 --- a/dev/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/dev/examples/fix/CMakeLists.txt b/dev/examples/fix/CMakeLists.txt deleted file mode 100644 index 5ed31e7..0000000 --- a/dev/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) - -target_link_libraries(Fix PRIVATE Boost::container) -set_property(TARGET Fix PROPERTY CXX_STANDARD 20) -target_include_directories(Fix PUBLIC ../../) diff --git a/dev/examples/fix/fix.cc b/dev/examples/fix/fix.cc deleted file mode 100644 index e09178b..0000000 --- a/dev/examples/fix/fix.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* - fix example - written by Amlal El Mahrouss. - licensed under the Boost Software License - */ - -#include -#include -#include -#include -#include -#include -#include - -/* finally test it */ -int main(int argc, char** argv) -{ - constexpr auto default_fix = "8=FIX.4.2|9=65|35=A|49=SERVER|56=CLIENT|34=177|52=20090107-18:15:16|98=0|108=30|10=062|"; - - 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); - - for (auto fields : fix.body_) - { - ocl::io::print("key=", fields.first); - ocl::io::print(", value=", fields.second); - } - - return 0; -} diff --git a/dev/examples/opt/CMakeLists.txt b/dev/examples/opt/CMakeLists.txt deleted file mode 100644 index b63b1de..0000000 --- a/dev/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 ../../) diff --git a/dev/examples/opt/opt.cc b/dev/examples/opt/opt.cc deleted file mode 100644 index acd59fd..0000000 --- a/dev/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("Ohio", "Ohio"); - opt.expect("Checksum failed, Ohio isn't Ohio!"); - - - return 0; -} diff --git a/dev/examples/tracked_ptr/CMakeLists.txt b/dev/examples/tracked_ptr/CMakeLists.txt deleted file mode 100644 index 9396506..0000000 --- a/dev/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 ../../) diff --git a/dev/examples/tracked_ptr/tracked_ptr.cc b/dev/examples/tracked_ptr/tracked_ptr.cc deleted file mode 100644 index 27d942c..0000000 --- a/dev/examples/tracked_ptr/tracked_ptr.cc +++ /dev/null @@ -1,52 +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::memory::must_pass(ptr); - - return EXIT_SUCCESS; -} -- cgit v1.2.3