summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md24
-rw-r--r--compile_flags.txt2
-rw-r--r--examples/fix_tag_example/CMakeLists.txt15
-rw-r--r--examples/fix_tag_example/example.cc31
-rw-r--r--examples/hash_crc32_example/example.cc4
-rw-r--r--examples/simple_unique_socket/example.cc4
-rw-r--r--include/.keep0
-rw-r--r--include/ocl/allocator_op.hpp (renamed from include/ocl/core/allocator_op.hpp)4
-rw-r--r--include/ocl/crc_hash.hpp (renamed from include/ocl/hashing/crc_hash.hpp)2
-rw-r--r--include/ocl/detail/config.hpp (renamed from include/ocl/core/config.hpp)4
-rw-r--r--include/ocl/detail/net_config.hpp14
-rw-r--r--include/ocl/fix/checksum.hpp14
-rw-r--r--include/ocl/fix/parser.hpp165
-rw-r--r--include/ocl/is_same.hpp (renamed from include/ocl/core/is_same.hpp)2
-rw-r--r--include/ocl/option.hpp (renamed from include/ocl/core/option.hpp)2
-rw-r--r--include/ocl/print.hpp (renamed from include/ocl/io/print.hpp)4
-rw-r--r--include/ocl/unique_socket.hpp (renamed from include/ocl/net/unique_socket.hpp)17
-rw-r--r--tests/fix_basic/CMakeLists.txt23
-rw-r--r--tests/fix_basic/fix_test.cc38
-rw-r--r--tests/network_basic/network_basic_test.cc4
20 files changed, 36 insertions, 337 deletions
diff --git a/README.md b/README.md
index 203390e..e0aadcd 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,8 @@
-# Open C++ Library
+# OCL.Core
[![License: BSL](https://img.shields.io/badge/license-BSL-blue.svg)](LICENSE)
-A set of containers in C++ for developers.<br/>
-You use them to speed up your development cycle for C++ applications.
+Core set of containers from the OCL.
## Requirements:
@@ -14,21 +13,4 @@ The OCL requires the following:
- [CMake](https://cmake.org/)
- [Git](https://git-scm.com/)
-### Example: The Option container
-
-Evaluates whether an expression is passing the options.
-
-```cpp
-#include <logic/option.hpp>
-
-int main(int argc, char** argv)
-{
- auto opt = ocl::option(ocl::eval_eq(50, 50)).expect("ocl::eval_eq, does not match!");
- opt = ocl::option(ocl::eval_eq(50, 40));
- opt.expect("this time it doesn't.");
-
- return EXIT_SUCCESS;
-}
-```
-
-##### (c) 2025 Amlal El Mahrouss, licensed under the Boost Software License.
+##### (c) 2025 Amlal El Mahrouss and OCL Authors, licensed under the Boost Software License.
diff --git a/compile_flags.txt b/compile_flags.txt
index 2a37c5d..1f10106 100644
--- a/compile_flags.txt
+++ b/compile_flags.txt
@@ -1,4 +1,4 @@
--Iinclude/ocl
+-Iinclude/
-std=c++20
-DEMBFS_28BIT_LBA
-xc++
diff --git a/examples/fix_tag_example/CMakeLists.txt b/examples/fix_tag_example/CMakeLists.txt
deleted file mode 100644
index b9a80db..0000000
--- a/examples/fix_tag_example/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-
-cmake_minimum_required(VERSION 3.15...3.31)
-
-project(
- FixExample
- VERSION 1.0
- LANGUAGES CXX)
-
-find_package(Boost REQUIRED COMPONENTS container)
-
-add_executable(FixExample example.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
deleted file mode 100644
index ad9725b..0000000
--- a/examples/fix_tag_example/example.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <fix/parser.hpp>
-#include <io/print.hpp>
-
-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::enable_stdio_sync(false);
-
- 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/hash_crc32_example/example.cc b/examples/hash_crc32_example/example.cc
index cddebda..bd27662 100644
--- a/examples/hash_crc32_example/example.cc
+++ b/examples/hash_crc32_example/example.cc
@@ -1,5 +1,5 @@
-#include <hashing/crc_hash.hpp>
-#include <io/print.hpp>
+#include <ocl/crc_hash.hpp>
+#include <ocl/print.hpp>
int main(int argc, char** argv)
{
diff --git a/examples/simple_unique_socket/example.cc b/examples/simple_unique_socket/example.cc
index a0eaff2..b5bd34f 100644
--- a/examples/simple_unique_socket/example.cc
+++ b/examples/simple_unique_socket/example.cc
@@ -1,5 +1,5 @@
-#include <net/unique_socket.hpp>
-#include <io/print.hpp>
+#include <ocl/unique_socket.hpp>
+#include <ocl/print.hpp>
/// @brief Basic Send test
int main()
diff --git a/include/.keep b/include/.keep
deleted file mode 100644
index e69de29..0000000
--- a/include/.keep
+++ /dev/null
diff --git a/include/ocl/core/allocator_op.hpp b/include/ocl/allocator_op.hpp
index e25fc1c..f953391 100644
--- a/include/ocl/core/allocator_op.hpp
+++ b/include/ocl/allocator_op.hpp
@@ -1,5 +1,5 @@
/*
- * File: core/allocator_op.hpp
+ * File: allocator_op.hpp
* 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
@@ -8,7 +8,7 @@
#ifndef _OCL_ALLOCATOR_SYSTEM_HPP
#define _OCL_ALLOCATOR_SYSTEM_HPP
-#include <core/config.hpp>
+#include <ocl/detail/config.hpp>
#include <memory>
namespace ocl
diff --git a/include/ocl/hashing/crc_hash.hpp b/include/ocl/crc_hash.hpp
index 89f3eff..cbb757f 100644
--- a/include/ocl/hashing/crc_hash.hpp
+++ b/include/ocl/crc_hash.hpp
@@ -8,7 +8,7 @@
#ifndef _OCL_CRC32_HPP
#define _OCL_CRC32_HPP
-#include <core/config.hpp>
+#include <ocl/detail/config.hpp>
#include <unordered_map>
#include <cstdint>
#include <string>
diff --git a/include/ocl/core/config.hpp b/include/ocl/detail/config.hpp
index 13abae0..c3c01ea 100644
--- a/include/ocl/core/config.hpp
+++ b/include/ocl/detail/config.hpp
@@ -1,6 +1,6 @@
/*
- * File: core/config.hpp
- * Purpose: Config file of the OCL.
+ * File: detail/config.hpp
+ * Purpose: Config file of the OCL.CORE library.
* Author: Amlal El Mahrouss (amlal@nekernel.org)
* Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
*/
diff --git a/include/ocl/detail/net_config.hpp b/include/ocl/detail/net_config.hpp
new file mode 100644
index 0000000..be25d1f
--- /dev/null
+++ b/include/ocl/detail/net_config.hpp
@@ -0,0 +1,14 @@
+
+#pragma once
+
+#include <stdexcept>
+#include <unistd.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <string>
+#include <cstddef>
+#include <cstring>
+
+#ifdef OCL_WINDOWS
+#error !!! "Windows is not supported yet for <unique_socket>" !!!
+#endif // OCL_WINDOWS
diff --git a/include/ocl/fix/checksum.hpp b/include/ocl/fix/checksum.hpp
deleted file mode 100644
index 807b9b0..0000000
--- a/include/ocl/fix/checksum.hpp
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * File: fix/checksum.hpp
- * Purpose: Financial Information Exchange checksum in C++
- * Author: Amlal El Mahrouss (amlal@nekernel.org)
- * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
- */
-
-#pragma once
-
-#include <core/config.hpp>
-
-namespace ocl::fix
-{
-} \ No newline at end of file
diff --git a/include/ocl/fix/parser.hpp b/include/ocl/fix/parser.hpp
deleted file mode 100644
index 6455601..0000000
--- a/include/ocl/fix/parser.hpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * File: fix/parser.hpp
- * Purpose: Financial Information Exchange parser in C++
- * Author: Amlal El Mahrouss (amlal@nekernel.org)
- * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
- */
-
-#ifndef _OCL_FIX_PARSER_HPP
-#define _OCL_FIX_PARSER_HPP
-
-#include <core/config.hpp>
-#include <hashing/crc_hash.hpp>
-#include <io/print.hpp>
-#include <string>
-
-namespace ocl::fix
-{
- class visitor;
- struct range;
- class range_buffer;
-
- /// @brief Buffer+Length structure
- using range_ptr_type = range*;
-
- using tag_type = std::string;
- using value_type = std::string;
-
- namespace detail
- {
- inline const char* begin_fix() noexcept
- {
- return "FIX.4.2";
- }
- } // namespace detail
-
- struct range final
- {
- char* bytes_{nullptr};
- size_t length_{};
-
- bool is_valid() noexcept
- {
- return this->bytes_ && this->length_ > 0;
- }
-
- explicit operator bool()
- {
- return this->is_valid();
- }
- };
-
- /// @brief Convert range to usable string.
- /// @note This function assumes that the range is valid and contains ASCII bytes.
- inline std::string to_string(range& range) noexcept
- {
- if (range.length_ < 1)
- return std::string{};
-
- return std::string(range.bytes_, range.length_);
- }
-
- /// @brief a range object containing the FIX packet values.
- class range_buffer final
- {
- public:
- std::size_t magic_len_{};
- std::string magic_{};
- string_hash_map<value_type> message_{};
-
- static inline const char* begin = detail::begin_fix();
-
- explicit range_buffer() = default;
- ~range_buffer() = default;
-
- range_buffer& operator=(const range_buffer&) = default;
- range_buffer(const range_buffer&) = default;
-
- value_type operator[](const tag_type& key)
- {
- if (key.empty())
- return value_type{};
-
- auto it = message_.find(key);
- if (it != message_.end())
- return it->second;
-
- return value_type{};
- }
-
- bool is_valid()
- {
- return this->operator[]("8").empty() == false;
- }
-
- explicit operator bool()
- {
- return this->is_valid();
- }
- };
-
- /// @brief visitor object which returns a fix::range_buffer instance.
- class visitor final
- {
- public:
- /// AMLALE: Yeah...
- static constexpr const int soh = '\x01';
- static constexpr const char eq = '=';
- static constexpr uint32_t base = 10U;
-
- explicit visitor() = default;
- ~visitor() = default;
-
- visitor& operator=(const visitor&) = default;
- visitor(const visitor&) = default;
-
- range_buffer operator()(const std::string& in)
- {
- return this->visit(in);
- }
-
- /// @brief Visit a FIX message and parse it into a range_buffer object.
- /// @param in The input FIX message as a string.
- /// @warning This function may throw exceptions.
- range_buffer visit(const std::string& in)
- {
- range_buffer ret{};
-
- if (in.empty())
- return ret;
-
- std::string key;
-
- std::size_t off = 0UL;
-
- while (off < in.size())
- {
- std::size_t eq_pos = in.find(eq, off);
- if (eq_pos == std::string::npos)
- break;
-
- std::string tag = in.substr(off, eq_pos - off);
-
- std::size_t soh_pos = in.find(soh, eq_pos + 1);
- if (soh_pos == std::string::npos)
- soh_pos = in.size();
-
- std::string value = in.substr(eq_pos + 1, soh_pos - eq_pos - 1);
-
- if (ret.magic_.empty())
- {
- ret.magic_ = value;
- ret.magic_len_ = value.size();
- }
-
- ret.message_[tag] = value;
-
- off = soh_pos + 1;
- }
-
- return ret;
- }
- };
-} // namespace ocl::fix
-
-#endif // ifndef _OCL_FIX_PARSER_HPP \ No newline at end of file
diff --git a/include/ocl/core/is_same.hpp b/include/ocl/is_same.hpp
index 27a85d0..3e9e706 100644
--- a/include/ocl/core/is_same.hpp
+++ b/include/ocl/is_same.hpp
@@ -7,7 +7,7 @@
#pragma once
-#include <core/config.hpp>
+#include <ocl/detail/config.hpp>
/// @brief OCL equivalence namespace.
namespace ocl
diff --git a/include/ocl/core/option.hpp b/include/ocl/option.hpp
index b5a2778..73cef13 100644
--- a/include/ocl/core/option.hpp
+++ b/include/ocl/option.hpp
@@ -7,7 +7,7 @@
#ifndef _OCL_OPT_HPP
#define _OCL_OPT_HPP
-#include <core/config.hpp>
+#include <ocl/detail/config.hpp>
#include <utility>
namespace ocl
diff --git a/include/ocl/io/print.hpp b/include/ocl/print.hpp
index aab6925..53c673e 100644
--- a/include/ocl/io/print.hpp
+++ b/include/ocl/print.hpp
@@ -2,13 +2,13 @@
* File: print.hpp
* Purpose: OCL Print library
* Author: Amlal El Mahrouss. (amlal@nekernel.org)
- * Copyright 2025
+ * Copyright 2025, Amlal El Mahrouss, Licensed under the Boost Software License. Licensed under the BSL 1.0 license
*/
#ifndef _OCL_PRINT_HPP
#define _OCL_PRINT_HPP
-#include <core/config.hpp>
+#include <ocl/detail/config.hpp>
#include <iostream>
diff --git a/include/ocl/net/unique_socket.hpp b/include/ocl/unique_socket.hpp
index d5b8b49..a8e532e 100644
--- a/include/ocl/net/unique_socket.hpp
+++ b/include/ocl/unique_socket.hpp
@@ -1,5 +1,5 @@
/*
- * File: net/unique_socket.hpp
+ * File: unique_socket.hpp
* Purpose: RAII socket concept in modern C++
* Author: Amlal El Mahrouss (amlal@nekernel.org)
* Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
@@ -7,19 +7,8 @@
#pragma once
-#include <core/config.hpp>
-
-#include <stdexcept>
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
-#include <string>
-#include <cstddef>
-#include <cstring>
-
-#ifdef OCL_WINDOWS
-#error !!! "Windows is not supported yet for <unique_socket>" !!!
-#endif // _WIN32
+#include <ocl/detail/config.hpp>
+#include <ocl/detail/net_config.hpp>
namespace ocl
{
diff --git a/tests/fix_basic/CMakeLists.txt b/tests/fix_basic/CMakeLists.txt
deleted file mode 100644
index b94e3b5..0000000
--- a/tests/fix_basic/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-cmake_minimum_required(VERSION 3.10)
-project(FIXTestBasic)
-
-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(FIXTestBasic fix_test.cc)
-target_link_libraries(FIXTestBasic gtest_main)
-
-set_property(TARGET FIXTestBasic PROPERTY CXX_STANDARD 20)
-target_include_directories(FIXTestBasic PUBLIC ../../include/ocl)
-
-include(GoogleTest)
-gtest_discover_tests(FIXTestBasic)
diff --git a/tests/fix_basic/fix_test.cc b/tests/fix_basic/fix_test.cc
deleted file mode 100644
index fdffc9b..0000000
--- a/tests/fix_basic/fix_test.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * File: tests/fix_test.cc
- * Purpose: Custom FIX protocol tests.
- * Author: Amlal El Mahrouss (amlal@nekernel.org)
- * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
- */
-
-#include <fix/parser.hpp>
-#include <gtest/gtest.h>
-
-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);
-
-TEST(FIXTest, FIX1)
-{
- EXPECT_TRUE(fix.is_valid());
- EXPECT_TRUE(fix["35"].empty() == false && fix["35"] == "A");
- EXPECT_TRUE(fix["49"].empty() == false && fix["49"] == "SERVER");
-}
-
-TEST(FIXTest, FIX2)
-{
- EXPECT_TRUE(fix["133"].empty() == true && fix["133"] != "");
- EXPECT_TRUE(fix["49"].empty() == false && fix["49"] != "A");
-}
diff --git a/tests/network_basic/network_basic_test.cc b/tests/network_basic/network_basic_test.cc
index 60316d4..24ce3b1 100644
--- a/tests/network_basic/network_basic_test.cc
+++ b/tests/network_basic/network_basic_test.cc
@@ -5,8 +5,8 @@
* Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
*/
-#include <net/unique_socket.hpp>
-#include <io/print.hpp>
+#include <ocl/unique_socket.hpp>
+#include <ocl/print.hpp>
#include <gtest/gtest.h>
/// @brief Basic Send test