From fba6a836e1e6ec8a234da9bd4b5e7c7f53faa0fb Mon Sep 17 00:00:00 2001 From: Amlal Date: Sun, 17 Aug 2025 14:12:13 +0200 Subject: feat: tracked_ptr: make use of static keyword for good c++ practice. Signed-off-by: Amlal --- dev/examples/tracked_ptr/tracked_ptr.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'dev/examples') diff --git a/dev/examples/tracked_ptr/tracked_ptr.cc b/dev/examples/tracked_ptr/tracked_ptr.cc index 61073a6..6d37691 100644 --- a/dev/examples/tracked_ptr/tracked_ptr.cc +++ b/dev/examples/tracked_ptr/tracked_ptr.cc @@ -5,15 +5,15 @@ */ #include -#include +#include -void summon_tracked_ptr() +static void summon_tracked_ptr() { snu::memory::tracked_ptr ptr = snu::memory::make_tracked(42); std::cout << ptr.data() << "=" << ptr.manager().allocator().allocated_count_ << std::endl; } -void summon_leak_tracked_ptr() +static void summon_leak_tracked_ptr() { snu::memory::tracked_ptr* ptr = new snu::memory::tracked_ptr(42); std::cout << ptr->data() << "=" << ptr->manager().allocator().allocated_count_ << std::endl; @@ -32,7 +32,6 @@ int main(int argc, char** argv) 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(); -- cgit v1.2.3 From 23d52c3cb72d595c971f189363c6cf9b222581c7 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 21 Aug 2025 15:10:31 +0200 Subject: feat: chunk_string: new work in progress string container. Signed-off-by: Amlal El Mahrouss --- dev/examples/cgi/cgi.cc | 2 +- dev/lib/core/includes.hpp | 1 + dev/lib/utility/cgi.hpp | 69 ------------------------------ dev/lib/utility/cgi_writer.hpp | 69 ++++++++++++++++++++++++++++++ dev/lib/utility/chunk_string.hpp | 79 +++++++++++++++++++++++++++++++++++ dev/tests/chunk_string/CMakeLists.txt | 26 ++++++++++++ dev/tests/chunk_string/chunk_test.cc | 30 +++++++++++++ dev/tests/network_basic/net_test.cc | 4 +- 8 files changed, 208 insertions(+), 72 deletions(-) delete mode 100644 dev/lib/utility/cgi.hpp create mode 100644 dev/lib/utility/cgi_writer.hpp create mode 100644 dev/lib/utility/chunk_string.hpp create mode 100644 dev/tests/chunk_string/CMakeLists.txt create mode 100644 dev/tests/chunk_string/chunk_test.cc (limited to 'dev/examples') diff --git a/dev/examples/cgi/cgi.cc b/dev/examples/cgi/cgi.cc index 2cb8f3a..4872cb5 100644 --- a/dev/examples/cgi/cgi.cc +++ b/dev/examples/cgi/cgi.cc @@ -4,7 +4,7 @@ licensed under the MIT license */ -#include +#include #include #include #include diff --git a/dev/lib/core/includes.hpp b/dev/lib/core/includes.hpp index 6bddba9..4beec1c 100644 --- a/dev/lib/core/includes.hpp +++ b/dev/lib/core/includes.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/dev/lib/utility/cgi.hpp b/dev/lib/utility/cgi.hpp deleted file mode 100644 index 57625b8..0000000 --- a/dev/lib/utility/cgi.hpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * File: cgi.hpp - * Author: Amlal El Mahrouss, - * Copyright 2023-2025, Amlal El Mahrouss. - */ - -#ifndef _SNU_CGI_HPP -#define _SNU_CGI_HPP - -#include -#include -#include - -namespace snu -{ - namespace cgi - { - /// @brief CGI Writer class, writes to stdout; as CGI expects. - template - class basic_writer - { - private: - basic_writer& eval_(const std::basic_string& mime, const std::basic_stringstream& ss) noexcept - { - std::printf("Content-Type: %s\r\n", mime.c_str()); - std::printf("Server: %s\r\n", "socl-cgi-system"); - std::printf("Content-Length: %ld\r\n\r\n", ss.str().size()); - std::printf("%s", ss.str().c_str()); - - return *this; - } - - public: - explicit basic_writer() = default; - ~basic_writer() = default; - - basic_writer& operator=(const basic_writer&) = default; - basic_writer(const basic_writer&) = default; - - public: - basic_writer& binary(const std::basic_stringstream& ss_in) - { - return this->eval_("application/octet-stream", ss_in); - } - - basic_writer& html(const std::basic_stringstream& ss_in) - { - return this->eval_("text/html", ss_in); - } - - basic_writer& xml(const std::basic_stringstream& ss_in) - { - return this->eval_("application/xml", ss_in); - } - - basic_writer& json(const std::basic_stringstream& ss_in) - { - return this->eval_("application/json", ss_in); - } - - basic_writer& js(const std::basic_stringstream& ss_in) - { - return this->eval_("text/javascript", ss_in); - } - }; - } // namespace cgi -} // namespace snu - -#endif // ifndef _SNU_CGI_HPP \ No newline at end of file diff --git a/dev/lib/utility/cgi_writer.hpp b/dev/lib/utility/cgi_writer.hpp new file mode 100644 index 0000000..2c30adf --- /dev/null +++ b/dev/lib/utility/cgi_writer.hpp @@ -0,0 +1,69 @@ +/* + * File: cgi_writer.hpp + * Author: Amlal El Mahrouss, + * Copyright 2023-2025, Amlal El Mahrouss. + */ + +#ifndef _SNU_CGI_HPP +#define _SNU_CGI_HPP + +#include +#include +#include + +namespace snu +{ + namespace cgi + { + /// @brief CGI Writer class, writes to stdout; as CGI expects. + template + class basic_writer + { + private: + basic_writer& eval_(const std::basic_string& mime, const std::basic_stringstream& ss) noexcept + { + std::printf("Content-Type: %s\r\n", mime.c_str()); + std::printf("Server: %s\r\n", "socl-cgi-system"); + std::printf("Content-Length: %ld\r\n\r\n", ss.str().size()); + std::printf("%s", ss.str().c_str()); + + return *this; + } + + public: + explicit basic_writer() = default; + ~basic_writer() = default; + + basic_writer& operator=(const basic_writer&) = default; + basic_writer(const basic_writer&) = default; + + public: + basic_writer& binary(const std::basic_stringstream& ss_in) + { + return this->eval_("application/octet-stream", ss_in); + } + + basic_writer& html(const std::basic_stringstream& ss_in) + { + return this->eval_("text/html", ss_in); + } + + basic_writer& xml(const std::basic_stringstream& ss_in) + { + return this->eval_("application/xml", ss_in); + } + + basic_writer& json(const std::basic_stringstream& ss_in) + { + return this->eval_("application/json", ss_in); + } + + basic_writer& js(const std::basic_stringstream& ss_in) + { + return this->eval_("text/javascript", ss_in); + } + }; + } // namespace cgi +} // namespace snu + +#endif // ifndef _SNU_CGI_HPP \ No newline at end of file diff --git a/dev/lib/utility/chunk_string.hpp b/dev/lib/utility/chunk_string.hpp new file mode 100644 index 0000000..ae52c39 --- /dev/null +++ b/dev/lib/utility/chunk_string.hpp @@ -0,0 +1,79 @@ +/* +* File: core/chunk_string.hpp + * Purpose: String implementation for the SOCL C++ library. + * Author: Amlal El Mahrouss (founder@snu.systems) + * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + */ + +#ifndef SOCL_UTILITY_CHUNK_STRING_HPP +#define SOCL_UTILITY_CHUNK_STRING_HPP + +#include +#include + +namespace snu +{ + template + class basic_chunk_string; + + template + struct basic_chunk_string final + { + private: + std::unique_ptr> next_chunk_string_{}; + basic_chunk_string* prev_chunk_string_{nullptr}; + + std::basic_string packed_chunks_{}; + int64_t chunk_total{}; + + constexpr const static auto max_chunk_size = 4096; + + public: + explicit basic_chunk_string() = default; + virtual ~basic_chunk_string() = default; + + basic_chunk_string& operator=(const basic_chunk_string&) = default; + basic_chunk_string(const basic_chunk_string&) = default; + + basic_chunk_string& operator+=(const std::basic_string& in) + { + if (in.empty()) + return *this; + + if (chunk_total > max_chunk_size) + { + next_chunk_string_ = std::make_unique>(); + *next_chunk_string_ += in; + + next_chunk_string_->prev_chunk_string_ = this; + + return *next_chunk_string_; + } + + packed_chunks_ += in; + chunk_total += in.size(); + + return *this; + } + + const std::basic_string& str() noexcept + { + return packed_chunks_; + } + + inline void print() noexcept + { + snu::io::print(packed_chunks_); + + if (next_chunk_string_) + this->next_chunk_string_->print(); + } + }; + + template + inline void print(basic_chunk_string& fmt) noexcept + { + std::cout << fmt.print(); + } +} // namespace snu +#endif // ifndef SOCL_UTILITY_CHUNK_STRING_HPP \ No newline at end of file diff --git a/dev/tests/chunk_string/CMakeLists.txt b/dev/tests/chunk_string/CMakeLists.txt new file mode 100644 index 0000000..defa761 --- /dev/null +++ b/dev/tests/chunk_string/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.27) +project(BasicChunkUsage LANGUAGES CXX) + +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(BasicChunkUsage chunk_test.cc) +target_link_libraries(BasicChunkUsage gtest_main) + +set_property(TARGET BasicChunkUsage PROPERTY CXX_STANDARD 20) +target_include_directories(BasicChunkUsage PUBLIC ../../) + +# FIXME: Make a pkg-config for the boost library here! +target_include_directories(BasicChunkUsage PUBLIC /opt/homebrew/Cellar/boost/1.87.0/include) + +include(GoogleTest) +gtest_discover_tests(BasicChunkUsage) diff --git a/dev/tests/chunk_string/chunk_test.cc b/dev/tests/chunk_string/chunk_test.cc new file mode 100644 index 0000000..e93f11d --- /dev/null +++ b/dev/tests/chunk_string/chunk_test.cc @@ -0,0 +1,30 @@ +/* + * File: tests/net_test.cc + * Purpose: Network unit tests in C++ + * Author: Amlal El Mahrouss (founder@snu.systems) + * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + */ + +#include +#include +#include + +TEST(ChunkTest, BasicChunkUsage) +{ + const std::string test_string = "HELLO, WORLD!"; + const unsigned iterations = 1024000; + + auto start = std::chrono::high_resolution_clock::now(); + + snu::basic_chunk_string 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(end - start); + + EXPECT_TRUE(optimized_time.count() < 200U); +} diff --git a/dev/tests/network_basic/net_test.cc b/dev/tests/network_basic/net_test.cc index 34f6ebe..f16fb06 100644 --- a/dev/tests/network_basic/net_test.cc +++ b/dev/tests/network_basic/net_test.cc @@ -5,7 +5,7 @@ * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. */ -#include +#include #include #include #include @@ -18,5 +18,5 @@ TEST(NetworkTest, BasicNetworkUsage) EXPECT_TRUE(modem.is_valid()); std::basic_string buf_dst = "HELLO, NET!"; - modem.transmit(buf_dst); + EXPECT_TRUE(modem.transmit(buf_dst)); } -- cgit v1.2.3 From b0d0e894a4394eed25dbb5cead12edd08a510a92 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 24 Aug 2025 14:13:34 +0200 Subject: feat! use `chunk_string` in the CGI module. Add additional constructors for `chunk_string` Signed-off-by: Amlal El Mahrouss --- compile_flags.txt | 3 ++- dev/examples/cgi/CMakeLists.txt | 4 ++++ dev/examples/cgi/cgi.cc | 11 ++--------- dev/examples/fix/fix.cc | 2 +- dev/lib/core/includes.hpp | 4 ---- dev/lib/except/error.hpp | 4 ++-- dev/lib/fix/parser.hpp | 2 ++ dev/lib/io/print.hpp | 1 - dev/lib/logic/math.hpp | 4 ++-- dev/lib/memory/tracked_ptr.hpp | 30 ++++++++++++++++++++--------- dev/lib/utility/cgi_writer.hpp | 36 +++++++++++++++++++---------------- dev/lib/utility/chunk_string.hpp | 17 ++++++++++++++--- dev/tests/chunk_string/CMakeLists.txt | 3 --- 13 files changed, 70 insertions(+), 51 deletions(-) (limited to 'dev/examples') diff --git a/compile_flags.txt b/compile_flags.txt index b820259..1c9f6fb 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -1,4 +1,5 @@ -Idev -std=c++20 -DEMBFS_28BIT_LBA --xc++ \ No newline at end of file +-xc++ +-I/opt/homebrew/Cellar/boost/1.87.0/include \ No newline at end of file diff --git a/dev/examples/cgi/CMakeLists.txt b/dev/examples/cgi/CMakeLists.txt index 391899f..9c3cbf6 100644 --- a/dev/examples/cgi/CMakeLists.txt +++ b/dev/examples/cgi/CMakeLists.txt @@ -6,7 +6,11 @@ project( 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 index 4872cb5..7d8353a 100644 --- a/dev/examples/cgi/cgi.cc +++ b/dev/examples/cgi/cgi.cc @@ -5,11 +5,8 @@ */ #include -#include -#include -#include -const std::string error_html = R"( +static snu::basic_chunk_string text_sample = R"( @@ -72,11 +69,7 @@ const std::string error_html = R"( int main(int argc, char** argv) { snu::cgi::basic_writer<> writer; - - std::stringstream ss_file; - ss_file << error_html; - - writer.html(ss_file); + writer << text_sample; return 0; } diff --git a/dev/examples/fix/fix.cc b/dev/examples/fix/fix.cc index ce48186..8730cad 100644 --- a/dev/examples/fix/fix.cc +++ b/dev/examples/fix/fix.cc @@ -4,7 +4,7 @@ licensed under the MIT license */ -#include +#include #include #include #include diff --git a/dev/lib/core/includes.hpp b/dev/lib/core/includes.hpp index 4beec1c..3238342 100644 --- a/dev/lib/core/includes.hpp +++ b/dev/lib/core/includes.hpp @@ -12,7 +12,3 @@ #include #include #include - -#include -#include -#include diff --git a/dev/lib/except/error.hpp b/dev/lib/except/error.hpp index 486d2e6..862dc3e 100644 --- a/dev/lib/except/error.hpp +++ b/dev/lib/except/error.hpp @@ -9,12 +9,12 @@ #include -namespace snu::except +namespace snu { using runtime_error = std::runtime_error; using fix_error = runtime_error; using math_error = runtime_error; using cgi_error = runtime_error; -} // namespace snu::except +} // namespace snu #endif // _SNU_ERR_HPP \ No newline at end of file diff --git a/dev/lib/fix/parser.hpp b/dev/lib/fix/parser.hpp index 8181359..1ace160 100644 --- a/dev/lib/fix/parser.hpp +++ b/dev/lib/fix/parser.hpp @@ -209,6 +209,8 @@ namespace snu::fix ::kill(::getpid(), SIGTRAP); } } + + using fix_tag_type = std::uint32_t; } // namespace snu::fix #endif // ifndef _SNU_FIX_PARSER_HPP diff --git a/dev/lib/io/print.hpp b/dev/lib/io/print.hpp index eb425c1..840b373 100644 --- a/dev/lib/io/print.hpp +++ b/dev/lib/io/print.hpp @@ -8,7 +8,6 @@ #ifndef _SNU_PRINT_HPP #define _SNU_PRINT_HPP -#include #include #include diff --git a/dev/lib/logic/math.hpp b/dev/lib/logic/math.hpp index cab995a..155251b 100644 --- a/dev/lib/logic/math.hpp +++ b/dev/lib/logic/math.hpp @@ -9,7 +9,7 @@ #include -namespace snu::math +namespace snu { template struct is_non_boolean_integer final @@ -32,4 +32,4 @@ namespace snu::math constexpr inline auto not_a_number = NAN; constexpr inline auto positive_infinity = INFINITY; constexpr inline auto negative_infinity = -positive_infinity; -} // namespace snu::math \ No newline at end of file +} // namespace snu \ No newline at end of file diff --git a/dev/lib/memory/tracked_ptr.hpp b/dev/lib/memory/tracked_ptr.hpp index da7e46c..7030f40 100644 --- a/dev/lib/memory/tracked_ptr.hpp +++ b/dev/lib/memory/tracked_ptr.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -45,19 +45,24 @@ namespace snu::memory template void retain(T*& ptr, U&&... args) { - ptr = new T(args...); + ptr = new T(std::forward(args)...); if (ptr) { ++allocated_count_; + return; } - else - { - throw std::bad_alloc(); - } + + throw std::bad_alloc(); + } + + template + void must_retain(T*& ptr, U&&... args) noexcept + { + this->retain(ptr, args...); } - void dispose(T*& ptr) + void dispose(T*& ptr) noexcept { if (ptr) { @@ -96,10 +101,17 @@ namespace snu::memory { T* ptr = nullptr; allocator_.retain(ptr, std::forward(args)...); + return ptr; } - void dispose(T*& ptr) + template + T* must_retain(U&&... args) noexcept + { + return this->retain(std::forward(args)...); + } + + void dispose(T*& ptr) noexcept { allocator_.dispose(ptr); } @@ -190,7 +202,7 @@ namespace snu::memory } private: - T* ptr_ = nullptr; + T* ptr_{nullptr}; }; template diff --git a/dev/lib/utility/cgi_writer.hpp b/dev/lib/utility/cgi_writer.hpp index 69d0170..70b32cf 100644 --- a/dev/lib/utility/cgi_writer.hpp +++ b/dev/lib/utility/cgi_writer.hpp @@ -7,9 +7,10 @@ #ifndef _SNU_CGI_WRITER_HPP #define _SNU_CGI_WRITER_HPP -#include -#include +#include +#include #include +#include namespace snu { @@ -20,18 +21,16 @@ namespace snu class basic_writer { private: - basic_writer& eval_(const std::basic_string& mime, const std::basic_stringstream& ss) noexcept + basic_writer& eval_(const snu::basic_chunk_string& mime, const snu::basic_chunk_string& ss) noexcept { - std::printf("Content-Type: %s\r\n", mime.c_str()); - std::printf("Server: %s\r\n", "socl-cgi-system"); - std::printf("Content-Length: %ld\r\n\r\n", ss.str().size()); + std::basic_stringstream ss_out; - auto ss_cc = ss.str(); + ss_out << std::format("Content-Type: {}\r\n", mime.str()); + ss_out << std::format("Server: {}\r\n", "SOCL-CGI/1.0"); + ss_out << std::format("Content-Length: {}\r\n\r\n", ss.str().size()); + ss_out << ss.str(); - for (auto& ch : ss_cc) - { - std::printf("%c", ch); - } + snu::io::print(ss_out.str()); return *this; } @@ -44,27 +43,32 @@ namespace snu basic_writer(const basic_writer&) = default; public: - basic_writer& binary(const std::basic_stringstream& ss_in) + friend void operator<<(basic_writer& self, const snu::basic_chunk_string& ss_in) + { + self = self.eval_("text/plain", ss_in); + } + + basic_writer& binary(const snu::basic_chunk_string& ss_in) { return this->eval_("application/octet-stream", ss_in); } - basic_writer& html(const std::basic_stringstream& ss_in) + basic_writer& html(const snu::basic_chunk_string& ss_in) { return this->eval_("text/html", ss_in); } - basic_writer& xml(const std::basic_stringstream& ss_in) + basic_writer& xml(const snu::basic_chunk_string& ss_in) { return this->eval_("application/xml", ss_in); } - basic_writer& json(const std::basic_stringstream& ss_in) + basic_writer& json(const snu::basic_chunk_string& ss_in) { return this->eval_("application/json", ss_in); } - basic_writer& js(const std::basic_stringstream& ss_in) + basic_writer& js(const snu::basic_chunk_string& ss_in) { return this->eval_("text/javascript", ss_in); } diff --git a/dev/lib/utility/chunk_string.hpp b/dev/lib/utility/chunk_string.hpp index 6b060ae..79e0dd6 100644 --- a/dev/lib/utility/chunk_string.hpp +++ b/dev/lib/utility/chunk_string.hpp @@ -29,8 +29,19 @@ namespace snu constexpr const static auto max_chunk_size = 4096; public: - explicit basic_chunk_string() = default; - virtual ~basic_chunk_string() = default; + basic_chunk_string() = default; + + basic_chunk_string(const char_type* in) + { + this->operator+=(in); + } + + basic_chunk_string(const std::basic_string& in) + { + this->operator+=(in); + } + + ~basic_chunk_string() = default; basic_chunk_string& operator=(const basic_chunk_string&) = default; basic_chunk_string(const basic_chunk_string&) = default; @@ -56,7 +67,7 @@ namespace snu return *this; } - const std::basic_string& str() noexcept + const std::basic_string& str() const noexcept { return packed_chunks_; } diff --git a/dev/tests/chunk_string/CMakeLists.txt b/dev/tests/chunk_string/CMakeLists.txt index ae0e1e7..5a4a27c 100644 --- a/dev/tests/chunk_string/CMakeLists.txt +++ b/dev/tests/chunk_string/CMakeLists.txt @@ -21,8 +21,5 @@ target_link_libraries(BasicChunkUsage PRIVATE gtest_main Boost::container) set_property(TARGET BasicChunkUsage PROPERTY CXX_STANDARD 20) target_include_directories(BasicChunkUsage PUBLIC ../../) -# FIXME: Make a pkg-config for the boost library here! -target_include_directories(BasicChunkUsage PUBLIC /opt/homebrew/Cellar/boost/1.87.0/include) - include(GoogleTest) gtest_discover_tests(BasicChunkUsage) -- cgit v1.2.3 From b4f35dbe44e07b597c3e7bb6d7562757069a7cb4 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 27 Aug 2025 12:28:55 +0200 Subject: feat: moved SOCL into OCL, without SNU's baggage. Signed-off-by: Amlal El Mahrouss --- Doxyfile | 6 +++--- MailMap | 2 +- README.md | 8 ++++---- dev/examples/cgi/cgi.cc | 4 ++-- dev/examples/equiv/equiv.cc | 6 +++--- dev/examples/fix/fix.cc | 6 +++--- dev/examples/opt/opt.cc | 4 ++-- dev/examples/tracked_ptr/tracked_ptr.cc | 8 ++++---- dev/lib/core/includes.hpp | 4 ++-- dev/lib/except/error.hpp | 12 ++++++------ dev/lib/fix/parser.hpp | 14 ++++++------- dev/lib/io/print.hpp | 16 +++++++-------- dev/lib/logic/equiv.hpp | 8 ++++---- dev/lib/logic/math.hpp | 6 +++--- dev/lib/logic/opt.hpp | 12 ++++++------ dev/lib/memory/tracked_ptr.hpp | 8 ++++---- dev/lib/net/modem.hpp | 16 +++++++-------- dev/lib/net/url.hpp | 10 +++++----- dev/lib/tests/gtest.hpp | 4 ++-- dev/lib/tests/hpptest.hpp | 12 ++++++------ dev/lib/utility/cgi_writer.hpp | 26 ++++++++++++------------- dev/lib/utility/chunk_string.hpp | 16 +++++++-------- dev/lib/utility/crc32.hpp | 12 ++++++------ dev/lib/utility/embfs.hpp | 14 ++++++------- dev/tests/chunk_string/chunk_test.cc | 6 +++--- dev/tests/fix_basic/fix_test.cc | 10 +++++----- dev/tests/network_basic/net_test.cc | 8 ++++---- dev/tests/tracked_ptr_basic/tracked_ptr_test.cc | 12 ++++++------ dev/tests/tracked_ptr_leak/tracked_ptr_test.cc | 14 ++++++------- meta/tex/embfs.tex | 6 +++--- tools/hpptest.py | 2 +- 31 files changed, 146 insertions(+), 146 deletions(-) (limited to 'dev/examples') diff --git a/Doxyfile b/Doxyfile index 9534c89..efda577 100644 --- a/Doxyfile +++ b/Doxyfile @@ -42,7 +42,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "SNU Open C++ Library" +PROJECT_NAME = "Open C++ Library" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -74,7 +74,7 @@ PROJECT_ICON = # entered, it will be relative to the location where Doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = /Volumes/Projects/src/snu-lib/docs +OUTPUT_DIRECTORY = ./ocl/docs # If the CREATE_SUBDIRS tag is set to YES then Doxygen will create up to 4096 # sub-directories (in 2 levels) under the output directory of each output format @@ -991,7 +991,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = /Volumes/Projects/src/snu-lib +INPUT = /Volumes/Projects/src/ocl # This tag can be used to specify the character encoding of the source files # that Doxygen parses. Internally Doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/MailMap b/MailMap index 426870d..e927bf1 100644 --- a/MailMap +++ b/MailMap @@ -1 +1 @@ -@amlel-el-mahrouss - founder@snu.systems - Library Author and Chief Architect +@amlel-el-mahrouss - amlal@nekernel.org - Library Author and Chief Architect diff --git a/README.md b/README.md index c7bf8c4..b7790c3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# SNU Open C++ Library +# Open C++ Library [![License: GPL-2.0](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) @@ -21,12 +21,12 @@ A C++ library with additional modules for your C++ SDLC. int main(int argc, char** argv) { - auto opt = snu::opt(snu::eval_eq(50, 50)).expect("snu::eval_eq, does not match!"); - opt = snu::opt(snu::eval_eq(50, 40)); + auto opt = ocl::opt(ocl::eval_eq(50, 50)).expect("ocl::eval_eq, does not match!"); + opt = ocl::opt(ocl::eval_eq(50, 40)); opt.expect("this time it doesn't."); return EXIT_SUCCESS; } ``` -##### (c) 2025 SNU Systems, Corp. +##### (c) 2025 Amlal El Mahrouss, licensed under the MIT license. diff --git a/dev/examples/cgi/cgi.cc b/dev/examples/cgi/cgi.cc index 7d8353a..e594c4b 100644 --- a/dev/examples/cgi/cgi.cc +++ b/dev/examples/cgi/cgi.cc @@ -6,7 +6,7 @@ #include -static snu::basic_chunk_string text_sample = R"( +static ocl::basic_chunk_string text_sample = R"( @@ -68,7 +68,7 @@ static snu::basic_chunk_string text_sample = R"( /* @brief this stub loads a 'index.html' or returns an error message if not found. */ int main(int argc, char** argv) { - snu::cgi::basic_writer<> writer; + ocl::cgi::basic_writer<> writer; writer << text_sample; return 0; diff --git a/dev/examples/equiv/equiv.cc b/dev/examples/equiv/equiv.cc index 896637d..12207f4 100644 --- a/dev/examples/equiv/equiv.cc +++ b/dev/examples/equiv/equiv.cc @@ -11,9 +11,9 @@ int main(int argc, char** argv) { std::cout << std::boolalpha; - std::cout << snu::equiv::is_same::value << std::endl; - std::cout << snu::equiv::is_same::value << std::endl; - std::cout << snu::equiv::is_same::value << std::endl; + 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/fix.cc b/dev/examples/fix/fix.cc index 8730cad..e3d669b 100644 --- a/dev/examples/fix/fix.cc +++ b/dev/examples/fix/fix.cc @@ -15,14 +15,14 @@ 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|"; - snu::fix::basic_visitor basic_visitor; - snu::fix::basic_range_data fix = basic_visitor.visit(default_fix); + 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; - snu::fix::must_pass(fix); + ocl::fix::must_pass(fix); for (auto fields : fix.body_) { diff --git a/dev/examples/opt/opt.cc b/dev/examples/opt/opt.cc index c1c2745..b34f2c7 100644 --- a/dev/examples/opt/opt.cc +++ b/dev/examples/opt/opt.cc @@ -26,7 +26,7 @@ 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(snu::eval_eq(hash_to_check, opt_hash)); /* do the compute */ + auto opt = ocl::opt(ocl::eval_eq(hash_to_check, opt_hash)); /* do the compute */ return opt; } @@ -35,7 +35,7 @@ int main(int argc, char** argv) { // ... let's assume we fetch data from network... - snu::io::println("Testing data..."); + ocl::io::println("Testing data..."); auto opt = do_some("Ohio", "Ohio"); opt.expect("Checksum failed, Ohio isn't Ohio!"); diff --git a/dev/examples/tracked_ptr/tracked_ptr.cc b/dev/examples/tracked_ptr/tracked_ptr.cc index 6d37691..5b70afd 100644 --- a/dev/examples/tracked_ptr/tracked_ptr.cc +++ b/dev/examples/tracked_ptr/tracked_ptr.cc @@ -9,13 +9,13 @@ static void summon_tracked_ptr() { - snu::memory::tracked_ptr ptr = snu::memory::make_tracked(42); + 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() { - snu::memory::tracked_ptr* ptr = new snu::memory::tracked_ptr(42); + ocl::memory::tracked_ptr* ptr = new ocl::memory::tracked_ptr(42); std::cout << ptr->data() << "=" << ptr->manager().allocator().allocated_count_ << std::endl; } @@ -27,7 +27,7 @@ int main(int argc, char** argv) summon_tracked_ptr(); summon_tracked_ptr(); - snu::memory::tracked_ptr ptr; + ocl::memory::tracked_ptr ptr; std::cout << ptr.data() << "=" << ptr.manager().allocator().allocated_count_ << std::endl; @@ -46,7 +46,7 @@ int main(int argc, char** argv) 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; - snu::memory::must_pass(ptr); + ocl::memory::must_pass(ptr); return EXIT_SUCCESS; } diff --git a/dev/lib/core/includes.hpp b/dev/lib/core/includes.hpp index 3238342..9feff2a 100644 --- a/dev/lib/core/includes.hpp +++ b/dev/lib/core/includes.hpp @@ -1,8 +1,8 @@ /* * File: core/includes.hpp * Purpose: Core includes for the SOCL library. - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ #pragma once diff --git a/dev/lib/except/error.hpp b/dev/lib/except/error.hpp index 862dc3e..16bf5eb 100644 --- a/dev/lib/except/error.hpp +++ b/dev/lib/except/error.hpp @@ -1,20 +1,20 @@ /* * File: opt.hpp * Author: Amlal El Mahrouss, - * Copyright 2023-2025, Amlal El Mahrouss/SNU Systems Corp. + * Copyright 2023-2025, Amlal El Mahrouss */ -#ifndef _SNU_ERR_HPP -#define _SNU_ERR_HPP +#ifndef _OCL_ERR_HPP +#define _OCL_ERR_HPP #include -namespace snu +namespace ocl { using runtime_error = std::runtime_error; using fix_error = runtime_error; using math_error = runtime_error; using cgi_error = runtime_error; -} // namespace snu +} // namespace ocl -#endif // _SNU_ERR_HPP \ No newline at end of file +#endif // _OCL_ERR_HPP \ No newline at end of file diff --git a/dev/lib/fix/parser.hpp b/dev/lib/fix/parser.hpp index ad6870a..a93b846 100644 --- a/dev/lib/fix/parser.hpp +++ b/dev/lib/fix/parser.hpp @@ -1,12 +1,12 @@ /* * File: fix/parser.hpp * Purpose: Financial Information Exchange parser in C++ - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ -#ifndef _SNU_FIX_PARSER_HPP -#define _SNU_FIX_PARSER_HPP +#ifndef _OCL_FIX_PARSER_HPP +#define _OCL_FIX_PARSER_HPP #include #include @@ -18,7 +18,7 @@ #include #include -namespace snu::fix +namespace ocl::fix { template class basic_visitor; @@ -211,6 +211,6 @@ namespace snu::fix } using fix_tag_type = std::uint32_t; -} // namespace snu::fix +} // namespace ocl::fix -#endif // ifndef _SNU_FIX_PARSER_HPP +#endif // ifndef _OCL_FIX_PARSER_HPP diff --git a/dev/lib/io/print.hpp b/dev/lib/io/print.hpp index 840b373..4b32ddb 100644 --- a/dev/lib/io/print.hpp +++ b/dev/lib/io/print.hpp @@ -1,17 +1,17 @@ /* * File: print.hpp - * Purpose: SNU Print library - * Author: Amlal El Mahrouss. (founder@snu.systems) - * Copyright 2025, SNU Systems Corp. + * Purpose: OCL Print library + * Author: Amlal El Mahrouss. (amlal@nekernel.org) + * Copyright 2025 */ -#ifndef _SNU_PRINT_HPP -#define _SNU_PRINT_HPP +#ifndef _OCL_PRINT_HPP +#define _OCL_PRINT_HPP #include #include -namespace snu::io +namespace ocl::io { template inline void print(T fmt, Args... other) noexcept @@ -36,6 +36,6 @@ namespace snu::io { print(fmt...); } -} // namespace snu::io +} // namespace ocl::io -#endif // ifndef _SNU_PRINT_HPP +#endif // ifndef _OCL_PRINT_HPP diff --git a/dev/lib/logic/equiv.hpp b/dev/lib/logic/equiv.hpp index 75fd8ee..c2d12dd 100644 --- a/dev/lib/logic/equiv.hpp +++ b/dev/lib/logic/equiv.hpp @@ -1,14 +1,14 @@ /* * File: equiv.hpp * Purpose: Equivalence runtime c++ header. - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ #pragma once /// @brief SOCL equivalence namespace. -namespace snu::equiv +namespace ocl::equiv { template struct basic_hash_trait @@ -101,4 +101,4 @@ namespace snu::equiv return left_ / right_ == 1; } }; -} // namespace snu::equiv +} // namespace ocl::equiv diff --git a/dev/lib/logic/math.hpp b/dev/lib/logic/math.hpp index 155251b..e796eae 100644 --- a/dev/lib/logic/math.hpp +++ b/dev/lib/logic/math.hpp @@ -1,7 +1,7 @@ /* * File: math.hpp * Purpose: Mathematics c++ header. - * Author: Amlal El Mahrouss (founder@snu.systems) + * Author: Amlal El Mahrouss (amlal@nekernel.org) * Copyright 2025, Amlal El Mahrouss. */ @@ -9,7 +9,7 @@ #include -namespace snu +namespace ocl { template struct is_non_boolean_integer final @@ -32,4 +32,4 @@ namespace snu constexpr inline auto not_a_number = NAN; constexpr inline auto positive_infinity = INFINITY; constexpr inline auto negative_infinity = -positive_infinity; -} // namespace snu \ No newline at end of file +} // namespace ocl \ No newline at end of file diff --git a/dev/lib/logic/opt.hpp b/dev/lib/logic/opt.hpp index a8e66b4..442756c 100644 --- a/dev/lib/logic/opt.hpp +++ b/dev/lib/logic/opt.hpp @@ -1,16 +1,16 @@ /* * File: opt.hpp * Author: Amlal El Mahrouss, - * Copyright 2023-2025, Amlal El Mahrouss/SNU Systems Corp. + * Copyright 2023-2025, Amlal El Mahrouss */ -#ifndef _SNU_OPT_HPP -#define _SNU_OPT_HPP +#ifndef _OCL_OPT_HPP +#define _OCL_OPT_HPP #include #include -namespace snu +namespace ocl { enum class return_type { @@ -116,6 +116,6 @@ namespace snu { return return_type::err; } -} // namespace snu +} // namespace ocl -#endif /* ifndef _SNU_OPT_HPP */ +#endif /* ifndef _OCL_OPT_HPP */ diff --git a/dev/lib/memory/tracked_ptr.hpp b/dev/lib/memory/tracked_ptr.hpp index 7030f40..d2f8450 100644 --- a/dev/lib/memory/tracked_ptr.hpp +++ b/dev/lib/memory/tracked_ptr.hpp @@ -1,8 +1,8 @@ /* * File: memory/tracked_ptr.hpp * Purpose: Custom smart pointer implementation in C++ - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ #pragma once @@ -16,7 +16,7 @@ #include #include -namespace snu::memory +namespace ocl::memory { template class tracked_allocator; @@ -232,4 +232,4 @@ namespace snu::memory ::kill(::getpid(), SIGTRAP); } } -} // namespace snu::memory +} // namespace ocl::memory diff --git a/dev/lib/net/modem.hpp b/dev/lib/net/modem.hpp index f6796be..e350f91 100644 --- a/dev/lib/net/modem.hpp +++ b/dev/lib/net/modem.hpp @@ -1,12 +1,12 @@ /* * File: net/modem.hpp * Purpose: Modem concept in modern C++ - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ -#ifndef _SNU_NET_NETWORK_HPP -#define _SNU_NET_NETWORK_HPP +#ifndef _OCL_NET_NETWORK_HPP +#define _OCL_NET_NETWORK_HPP #include #include @@ -15,9 +15,9 @@ #include #include -#define SNU_MODEM_INTERFACE : protected snu::net::basic_modem +#define OCL_MODEM_INTERFACE : protected ocl::net::basic_modem -namespace snu::net +namespace ocl::net { template class basic_modem; @@ -139,6 +139,6 @@ namespace snu::net return true; } }; -} // namespace snu::net +} // namespace ocl::net -#endif // ifndef _SNU_NET_NETWORK_HPP +#endif // ifndef _OCL_NET_NETWORK_HPP diff --git a/dev/lib/net/url.hpp b/dev/lib/net/url.hpp index f6dba95..ff6aebe 100644 --- a/dev/lib/net/url.hpp +++ b/dev/lib/net/url.hpp @@ -1,8 +1,8 @@ /* * File: net/url.hpp * Purpose: URL container in modern C++ - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ #pragma once @@ -11,9 +11,9 @@ #include #include -/// @author Amlal El Mahrouss (founder@snu.systems) +/// @author Amlal El Mahrouss (amlal@nekernel.org) -namespace snu::net +namespace ocl::net { template class basic_url; @@ -61,4 +61,4 @@ namespace snu::net return ss_.size() > 0; } }; -} // namespace snu::net +} // namespace ocl::net diff --git a/dev/lib/tests/gtest.hpp b/dev/lib/tests/gtest.hpp index 14474c0..126ce90 100644 --- a/dev/lib/tests/gtest.hpp +++ b/dev/lib/tests/gtest.hpp @@ -1,8 +1,8 @@ /* * File: tests/gtest.hpp * Purpose: Google Test wrapper for the SOCL library. - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ #include diff --git a/dev/lib/tests/hpptest.hpp b/dev/lib/tests/hpptest.hpp index 0d6ed39..085275f 100644 --- a/dev/lib/tests/hpptest.hpp +++ b/dev/lib/tests/hpptest.hpp @@ -1,21 +1,21 @@ /* * File: tests/hpptest.hpp * Purpose: HPP Test wrapper for the SOCL library. - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ #pragma once -#ifdef SOCL_HPPTEST -namespace snu::hpptest +#ifdef OCL_HPPTEST +namespace ocl::hpptest { typedef bool condition_type; template consteval inline void must_pass() { - SOCL_HPPTEST_ASSERT(expr); + OCL_HPPTEST_ASSERT(expr); } -} // namespace snu::hpptest +} // namespace ocl::hpptest #endif diff --git a/dev/lib/utility/cgi_writer.hpp b/dev/lib/utility/cgi_writer.hpp index 70b32cf..12de9ec 100644 --- a/dev/lib/utility/cgi_writer.hpp +++ b/dev/lib/utility/cgi_writer.hpp @@ -4,15 +4,15 @@ * Copyright 2023-2025, Amlal El Mahrouss. */ -#ifndef _SNU_CGI_WRITER_HPP -#define _SNU_CGI_WRITER_HPP +#ifndef _OCL_CGI_WRITER_HPP +#define _OCL_CGI_WRITER_HPP #include #include #include #include -namespace snu +namespace ocl { namespace cgi { @@ -21,7 +21,7 @@ namespace snu class basic_writer { private: - basic_writer& eval_(const snu::basic_chunk_string& mime, const snu::basic_chunk_string& ss) noexcept + basic_writer& eval_(const ocl::basic_chunk_string& mime, const ocl::basic_chunk_string& ss) noexcept { std::basic_stringstream ss_out; @@ -30,7 +30,7 @@ namespace snu ss_out << std::format("Content-Length: {}\r\n\r\n", ss.str().size()); ss_out << ss.str(); - snu::io::print(ss_out.str()); + ocl::io::print(ss_out.str()); return *this; } @@ -43,37 +43,37 @@ namespace snu basic_writer(const basic_writer&) = default; public: - friend void operator<<(basic_writer& self, const snu::basic_chunk_string& ss_in) + friend void operator<<(basic_writer& self, const ocl::basic_chunk_string& ss_in) { self = self.eval_("text/plain", ss_in); } - basic_writer& binary(const snu::basic_chunk_string& ss_in) + basic_writer& binary(const ocl::basic_chunk_string& ss_in) { return this->eval_("application/octet-stream", ss_in); } - basic_writer& html(const snu::basic_chunk_string& ss_in) + basic_writer& html(const ocl::basic_chunk_string& ss_in) { return this->eval_("text/html", ss_in); } - basic_writer& xml(const snu::basic_chunk_string& ss_in) + basic_writer& xml(const ocl::basic_chunk_string& ss_in) { return this->eval_("application/xml", ss_in); } - basic_writer& json(const snu::basic_chunk_string& ss_in) + basic_writer& json(const ocl::basic_chunk_string& ss_in) { return this->eval_("application/json", ss_in); } - basic_writer& js(const snu::basic_chunk_string& ss_in) + basic_writer& js(const ocl::basic_chunk_string& ss_in) { return this->eval_("text/javascript", ss_in); } }; } // namespace cgi -} // namespace snu +} // namespace ocl -#endif // ifndef _SNU_CGI_WRITER_HPP +#endif // ifndef _OCL_CGI_WRITER_HPP diff --git a/dev/lib/utility/chunk_string.hpp b/dev/lib/utility/chunk_string.hpp index 79e0dd6..79a3881 100644 --- a/dev/lib/utility/chunk_string.hpp +++ b/dev/lib/utility/chunk_string.hpp @@ -1,17 +1,17 @@ /* * File: core/chunk_string.hpp * Purpose: String implementation for the SOCL C++ library. - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ -#ifndef SOCL_UTILITY_CHUNK_STRING_HPP -#define SOCL_UTILITY_CHUNK_STRING_HPP +#ifndef OCL_UTILITY_CHUNK_STRING_HPP +#define OCL_UTILITY_CHUNK_STRING_HPP #include #include -namespace snu +namespace ocl { template class basic_chunk_string; @@ -74,7 +74,7 @@ namespace snu void print() noexcept { - snu::io::print(packed_chunks_); + ocl::io::print(packed_chunks_); if (next_chunk_string_) this->next_chunk_string_->print(); @@ -86,5 +86,5 @@ namespace snu { fmt.print(); } -} // namespace snu -#endif // ifndef SOCL_UTILITY_CHUNK_STRING_HPP \ No newline at end of file +} // namespace ocl +#endif // ifndef OCL_UTILITY_CHUNK_STRING_HPP \ No newline at end of file diff --git a/dev/lib/utility/crc32.hpp b/dev/lib/utility/crc32.hpp index f7e5fc9..ea09b94 100644 --- a/dev/lib/utility/crc32.hpp +++ b/dev/lib/utility/crc32.hpp @@ -5,17 +5,17 @@ * Copyright 2025, Amlal El Mahrouss. */ -#ifndef _SNU_CRC32_HPP -#define _SNU_CRC32_HPP +#ifndef _OCL_CRC32_HPP +#define _OCL_CRC32_HPP #include #include #include /// @brief Crc32 implementation in C++ -/// @author Amlal EL Mahrouss (founder@snu.systems) +/// @author Amlal EL Mahrouss (amlal@nekernel.org) -namespace snu::crc32 +namespace ocl::crc32 { namespace detail { @@ -76,6 +76,6 @@ namespace snu::crc32 { return detail::crc32(in.c_str(), in.size()); } -} // namespace snu::crc32 +} // namespace ocl::crc32 -#endif // !_SNU_CRC32_HPP \ No newline at end of file +#endif // !_OCL_CRC32_HPP \ No newline at end of file diff --git a/dev/lib/utility/embfs.hpp b/dev/lib/utility/embfs.hpp index 3acc867..0f20596 100644 --- a/dev/lib/utility/embfs.hpp +++ b/dev/lib/utility/embfs.hpp @@ -1,20 +1,20 @@ /* * File: embfs.hpp * Purpose: Embedded File System. - * Author: Amlal El Mahrouss (founder@snu.systems) + * Author: Amlal El Mahrouss (amlal@nekernel.org) * Copyright 2025, Amlal El Mahrouss. */ -#ifndef _SNU_EMBFS_HPP -#define _SNU_EMBFS_HPP +#ifndef _OCL_EMBFS_HPP +#define _OCL_EMBFS_HPP #include #include /// @brief A filesystem designed for tiny storage medias. -/// @author Amlal EL Mahrouss (founder@snu.systems) +/// @author Amlal EL Mahrouss (amlal@nekernel.org) -namespace snu::embfs +namespace ocl::embfs { namespace traits { @@ -75,6 +75,6 @@ namespace snu::embfs /// @brief Indexed node linear array. typedef embfs_inode embfs_inode_arr_t[_inode_arr_len]; } // namespace traits -} // namespace snu::embfs +} // namespace ocl::embfs -#endif // ifndef _SNU_EMBFS_HPP \ No newline at end of file +#endif // ifndef _OCL_EMBFS_HPP \ No newline at end of file diff --git a/dev/tests/chunk_string/chunk_test.cc b/dev/tests/chunk_string/chunk_test.cc index 3e1f3db..2929754 100644 --- a/dev/tests/chunk_string/chunk_test.cc +++ b/dev/tests/chunk_string/chunk_test.cc @@ -1,8 +1,8 @@ /* * File: tests/chunk_test.cc * Purpose: Chunk unit tests in C++ - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ #include @@ -16,7 +16,7 @@ TEST(ChunkTest, BasicChunkUsage) auto start = std::chrono::high_resolution_clock::now(); - snu::basic_chunk_string optimized; + ocl::basic_chunk_string optimized; for (unsigned i = 0; i < iterations; ++i) { diff --git a/dev/tests/fix_basic/fix_test.cc b/dev/tests/fix_basic/fix_test.cc index bd04d07..bdde392 100644 --- a/dev/tests/fix_basic/fix_test.cc +++ b/dev/tests/fix_basic/fix_test.cc @@ -1,8 +1,8 @@ /* * File: tests/tracked_ptr_test.cc * Purpose: Custom smart pointer unit tests in C++ - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ #include @@ -10,9 +10,9 @@ TEST(FIXTest, BasicFIXUsage) { - snu::fix::basic_visitor basic_visitor; - snu::fix::basic_range_data fix = basic_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|"); + ocl::fix::basic_visitor basic_visitor; + ocl::fix::basic_range_data fix = basic_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|"); - EXPECT_EQ(fix.magic_, snu::fix::detail::begin_fix()); + EXPECT_EQ(fix.magic_, ocl::fix::detail::begin_fix()); EXPECT_TRUE(fix.is_valid()); } \ No newline at end of file diff --git a/dev/tests/network_basic/net_test.cc b/dev/tests/network_basic/net_test.cc index f16fb06..9c90bcd 100644 --- a/dev/tests/network_basic/net_test.cc +++ b/dev/tests/network_basic/net_test.cc @@ -1,8 +1,8 @@ /* * File: tests/net_test.cc * Purpose: Network unit tests in C++ - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ #include @@ -12,8 +12,8 @@ TEST(NetworkTest, BasicNetworkUsage) { - snu::net::basic_modem modem; - modem.construct(snu::net::basic_modem::local_address_ip4, true); + ocl::net::basic_modem modem; + modem.construct(ocl::net::basic_modem::local_address_ip4, true); EXPECT_TRUE(modem.is_valid()); diff --git a/dev/tests/tracked_ptr_basic/tracked_ptr_test.cc b/dev/tests/tracked_ptr_basic/tracked_ptr_test.cc index 0e72e77..1e97188 100644 --- a/dev/tests/tracked_ptr_basic/tracked_ptr_test.cc +++ b/dev/tests/tracked_ptr_basic/tracked_ptr_test.cc @@ -1,8 +1,8 @@ /* * File: tests/tracked_ptr_test.cc * Purpose: Custom smart pointer unit tests in C++ - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ #include @@ -10,16 +10,16 @@ TEST(TrackedPtrTest, BasicTrackedPtrUsage) { - snu::memory::tracked_ptr ptr = snu::memory::make_tracked(42); + ocl::memory::tracked_ptr ptr = ocl::memory::make_tracked(42); ASSERT_TRUE(ptr); EXPECT_EQ(*ptr, 42); - snu::memory::tracked_ptr ptr2; + ocl::memory::tracked_ptr ptr2; - snu::memory::swap(ptr, ptr2); + ocl::memory::swap(ptr, ptr2); ptr2.reset(); - EXPECT_EQ(snu::memory::tracked_ptr::manager().allocator().allocated_count_, 1); + EXPECT_EQ(ocl::memory::tracked_ptr::manager().allocator().allocated_count_, 1); } \ No newline at end of file diff --git a/dev/tests/tracked_ptr_leak/tracked_ptr_test.cc b/dev/tests/tracked_ptr_leak/tracked_ptr_test.cc index 6818b7c..f349f47 100644 --- a/dev/tests/tracked_ptr_leak/tracked_ptr_test.cc +++ b/dev/tests/tracked_ptr_leak/tracked_ptr_test.cc @@ -1,8 +1,8 @@ /* * File: tests/tracked_ptr_test.cc * Purpose: Custom smart pointer unit tests in C++ - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss */ #include @@ -10,10 +10,10 @@ TEST(TrackedPtrTest, LeakTrackedPtrUsage) { - snu::memory::tracked_ptr* ptr = new snu::memory::tracked_ptr(42); - snu::memory::tracked_ptr* ptr2 = new snu::memory::tracked_ptr(42); - snu::memory::tracked_ptr* ptr3 = new snu::memory::tracked_ptr(42); + ocl::memory::tracked_ptr* ptr = new ocl::memory::tracked_ptr(42); + ocl::memory::tracked_ptr* ptr2 = new ocl::memory::tracked_ptr(42); + ocl::memory::tracked_ptr* ptr3 = new ocl::memory::tracked_ptr(42); - EXPECT_EQ(snu::memory::tracked_ptr::manager().allocator().allocated_count_, 3); - ASSERT_TRUE(snu::memory::tracked_ptr::manager().allocator().deallocated_count_ == 0); + EXPECT_EQ(ocl::memory::tracked_ptr::manager().allocator().allocated_count_, 3); + ASSERT_TRUE(ocl::memory::tracked_ptr::manager().allocator().deallocated_count_ == 0); } \ No newline at end of file diff --git a/meta/tex/embfs.tex b/meta/tex/embfs.tex index e72d4b4..2d5c60e 100644 --- a/meta/tex/embfs.tex +++ b/meta/tex/embfs.tex @@ -25,7 +25,7 @@ \title{Embedded File System (EMBFS) Specification} \author{Amlal El Mahrouss} -\date{2025} +\date{\today} \begin{document} @@ -37,7 +37,7 @@ The \textbf{Embedded File System (EMBFS)} is a compact and minimal filesystem de \section{Namespace} The EMBFS implementation resides under: \begin{lstlisting} -namespace snu::embfs +namespace ocl::embfs \end{lstlisting} \section{Supported Logical Block Addressing (LBA) Modes} @@ -135,7 +135,7 @@ Represents a fixed-size array of 12 inodes within a given partition. \begin{itemize} \item Copyright © 2025 Amlal El Mahrouss \item All rights reserved. - \item For questions or licensing requests, contact: \texttt{founder@snu.systems} + \item For questions or licensing requests, contact: \texttt{amlal@nekernel.org} \end{itemize} \end{document} \ No newline at end of file diff --git a/tools/hpptest.py b/tools/hpptest.py index f9fcd1c..744ffde 100755 --- a/tools/hpptest.py +++ b/tools/hpptest.py @@ -5,6 +5,6 @@ import sys, os if __name__ == '__main__': if len(sys.argv) == 2: - os.system(f"clang++ -std=c++20 -DSOCL_HPPTEST '-DSOCL_HPPTEST_ASSERT(x)=static_assert(x, #x)' {sys.argv[1]}") + os.system(f"clang++ -std=c++20 -DOCL_HPPTEST '-DOCL_HPPTEST_ASSERT(x)=static_assert(x, #x)' {sys.argv[1]}") print("[TEST] HEADER COMPILATION PASSES") -- cgit v1.2.3 From c4f4155f6f5a30641180050a1a5ea8967f6392fa Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 27 Aug 2025 12:41:09 +0200 Subject: feat: final refactors (SOCL -> OCL) Signed-off-by: Amlal El Mahrouss --- Doxyfile | 2 +- dev/examples/cgi/cgi.cc | 4 ++-- dev/lib/core/includes.hpp | 2 +- dev/lib/logic/equiv.hpp | 2 +- dev/lib/tests/gtest.hpp | 2 +- dev/lib/tests/hpptest.hpp | 2 +- dev/lib/utility/cgi_writer.hpp | 2 +- dev/lib/utility/chunk_string.hpp | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) (limited to 'dev/examples') diff --git a/Doxyfile b/Doxyfile index efda577..a558fb4 100644 --- a/Doxyfile +++ b/Doxyfile @@ -54,7 +54,7 @@ PROJECT_NUMBER = dev # for a project that appears at the top of each page and should give viewers a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = SOCL +PROJECT_BRIEF = OCL # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 diff --git a/dev/examples/cgi/cgi.cc b/dev/examples/cgi/cgi.cc index e594c4b..692f90c 100644 --- a/dev/examples/cgi/cgi.cc +++ b/dev/examples/cgi/cgi.cc @@ -11,7 +11,7 @@ static ocl::basic_chunk_string text_sample = R"( - Error | SOCL + Error | OCL