summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-07-26 01:47:32 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-07-26 01:47:32 +0100
commitc52dbf5513ae7f106634967162da5cfb01dc5af3 (patch)
treeb6715d0fdacebd48491b9b05cf85f1d92028f84b /examples
parent01565adb9cf5ef991196f56c7f5f7b6161daa005 (diff)
feat: SOCL v1.0.2, changelog soon!v1.0.2
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'examples')
-rw-r--r--examples/cgi/CMakeLists.txt12
-rw-r--r--examples/cgi/cgi.cc91
-rw-r--r--examples/equiv/CMakeLists.txt12
-rw-r--r--examples/equiv/equiv.cc19
-rw-r--r--examples/fix/CMakeLists.txt12
-rw-r--r--examples/fix/fix.cc26
-rw-r--r--examples/opt/CMakeLists.txt12
-rw-r--r--examples/opt/opt.cc44
-rw-r--r--examples/tracked_ptr/CMakeLists.txt12
-rw-r--r--examples/tracked_ptr/tracked_ptr.cc52
10 files changed, 0 insertions, 292 deletions
diff --git a/examples/cgi/CMakeLists.txt b/examples/cgi/CMakeLists.txt
deleted file mode 100644
index 391899f..0000000
--- a/examples/cgi/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-
-cmake_minimum_required(VERSION 3.15...3.31)
-
-project(
- CGI
- VERSION 1.0
- LANGUAGES CXX)
-
-add_executable(CGI cgi.cc)
-
-set_property(TARGET CGI PROPERTY CXX_STANDARD 20)
-target_include_directories(CGI PUBLIC ../../)
diff --git a/examples/cgi/cgi.cc b/examples/cgi/cgi.cc
deleted file mode 100644
index b4c0b34..0000000
--- a/examples/cgi/cgi.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- cgi example
- written by Amlal El Mahrouss.
- licensed under the MIT license
- */
-
-#include <lib/utility/cgi.hpp>
-#include <fstream>
-#include <sstream>
-#include <string>
-
-const std::string g_not_found = R"(
-<!DOCTYPE html>
-<html>
-<head>
- <meta charset="UTF-8">
- <title>error | snu-lib</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>snu'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)
-{
- // ... let's assume we serve data.
-
- snu::cgi::cgi_writer writer;
- std::stringstream ss_file;
-
- std::ifstream fp("index.html");
-
- if (fp.good())
- ss_file << fp.rdbuf();
- else
- ss_file << g_not_found;
-
- fp.close();
-
- writer.eval_html(ss_file);
-
- return 0;
-}
diff --git a/examples/equiv/CMakeLists.txt b/examples/equiv/CMakeLists.txt
deleted file mode 100644
index 8b29e23..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 ../../)
diff --git a/examples/equiv/equiv.cc b/examples/equiv/equiv.cc
deleted file mode 100644
index 896637d..0000000
--- a/examples/equiv/equiv.cc
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- string checksum example
- written by Amlal El Mahrouss.
- licensed under the MIT license
- */
-
-#include <lib/logic/equiv.hpp>
-#include <iostream>
-
-/* finally test it */
-int main(int argc, char** argv)
-{
- std::cout << std::boolalpha;
- std::cout << snu::equiv::is_same<bool, int>::value << std::endl;
- std::cout << snu::equiv::is_same<bool, bool>::value << std::endl;
- std::cout << snu::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 db8921b..0000000
--- a/examples/fix/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(Fix fix.cc)
-
-set_property(TARGET Fix PROPERTY CXX_STANDARD 20)
-target_include_directories(Fix PUBLIC ../../)
diff --git a/examples/fix/fix.cc b/examples/fix/fix.cc
deleted file mode 100644
index f67d8a0..0000000
--- a/examples/fix/fix.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- fix example
- written by Amlal El Mahrouss.
- licensed under the MIT license
- */
-
-#include <lib/fix/parser.hpp>
-#include <iostream>
-
-/* finally test it */
-int main(int argc, char** argv)
-{
- snu::fix::visitor<char> visitor;
- snu::fix::range_data<char> fix = visitor.visit("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|");
-
- std::cout << "magic: " << fix.msg_magic_ << std::endl;
- std::cout << "is_valid: " << std::boolalpha << fix.is_valid() << std::endl;
-
- for (auto fields : fix.msg_body_)
- {
- std::cout << "key: " << fields.first;
- std::cout << ", value: " << fields.second << std::endl;
- }
-
- return 0;
-}
diff --git a/examples/opt/CMakeLists.txt b/examples/opt/CMakeLists.txt
deleted file mode 100644
index b63b1de..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 ../../)
diff --git a/examples/opt/opt.cc b/examples/opt/opt.cc
deleted file mode 100644
index a914d8d..0000000
--- a/examples/opt/opt.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- string checksum example
- written by Amlal El Mahrouss.
- licensed under the MIT license
- */
-
-#include <lib/logic/opt.hpp>
-#include <lib/io/print.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 = snu::opt::opt(snu::opt::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...
-
- snu::println("Testing data...");
-
- auto opt = do_some("Ohio", "Ohio");
- opt.expect("Checksum failed, Ohio isn't Ohio!");
-
-
- return 0;
-}
diff --git a/examples/tracked_ptr/CMakeLists.txt b/examples/tracked_ptr/CMakeLists.txt
deleted file mode 100644
index 9396506..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 ../../)
diff --git a/examples/tracked_ptr/tracked_ptr.cc b/examples/tracked_ptr/tracked_ptr.cc
deleted file mode 100644
index c182494..0000000
--- a/examples/tracked_ptr/tracked_ptr.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- tracked_ptr example
- written by Amlal El Mahrouss.
- licensed under the MIT license
- */
-
-#include <lib/memory/tracked_ptr.hpp>
-#include <iostream>
-
-void summon_tracked_ptr()
-{
- snu::memory::tracked_ptr<int> ptr = snu::memory::make_tracked(42);
- std::cout << ptr.data() << "=" << ptr.manager().allocator().allocated_count_ << std::endl;
-}
-
-void summon_leak_tracked_ptr()
-{
- snu::memory::tracked_ptr<int>* ptr = new snu::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();
-
- snu::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;
-
- return 0;
-}