summaryrefslogtreecommitdiffhomepage
path: root/dev/examples
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 02:13:48 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 02:13:48 +0100
commit65a8349aa5526d071b18cd4d42586c46faaa3823 (patch)
treef6e2063319ceaaa02f523fb5c289e4f37411a2df /dev/examples
parentdf4ec096491ded6d58b9ee094d6942e3188c2d4a (diff)
feat! breaking changes for OCL v1.0.48.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/examples')
-rw-r--r--dev/examples/allocator_system/CMakeLists.txt16
-rw-r--r--dev/examples/allocator_system/allocator_system.cc53
-rw-r--r--dev/examples/cgi/CMakeLists.txt16
-rw-r--r--dev/examples/cgi/cgi.cc75
-rw-r--r--dev/examples/equiv/CMakeLists.txt12
-rw-r--r--dev/examples/equiv/equiv.cc19
-rw-r--r--dev/examples/fix/CMakeLists.txt15
-rw-r--r--dev/examples/fix/fix.cc37
-rw-r--r--dev/examples/opt/CMakeLists.txt12
-rw-r--r--dev/examples/opt/opt.cc45
-rw-r--r--dev/examples/tracked_ptr/CMakeLists.txt12
-rw-r--r--dev/examples/tracked_ptr/tracked_ptr.cc52
12 files changed, 0 insertions, 364 deletions
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 <lib/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/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 <lib/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/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 <lib/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/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 <lib/core/error_handler.hpp>
-#include <lib/net/modem.hpp>
-#include <lib/fix/fix.hpp>
-#include <iostream>
-#include <unistd.h>
-#include <lib/io/print.hpp>
-#include <sys/socket.h>
-
-/* 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<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);
-
- 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 <lib/logic/opt.hpp>
-#include <lib/io/print.hpp>
-#include <lib/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("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 <lib/memory/tracked_ptr.hpp>
-#include <lib/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::memory::must_pass(ptr);
-
- return EXIT_SUCCESS;
-}