summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-25 00:05:50 -0500
committerGitHub <noreply@github.com>2025-11-25 00:05:50 -0500
commitb9b5224ed9d045437425ad129ffb83b9d0de850c (patch)
tree12c034291fd9d721b1eb9b8c16bcc65285936fe8
parent92921b0b156d5a8369b9133a7c37e2793954c932 (diff)
parent52399b9b2fe46e29c5ee265baf8cb7f1717a4c53 (diff)
Merge pull request #22 from amlel-el-mahrouss/develop
Expanding FIX and more patches.
-rw-r--r--examples/fix/CMakeLists.txt3
-rw-r--r--examples/fix/fix.cc22
-rw-r--r--examples/tracked_ptr/tracked_ptr.cc3
-rw-r--r--include/ocl/core/config.hpp9
-rw-r--r--include/ocl/core/error_handler.hpp4
-rw-r--r--include/ocl/fix/checksum.hpp10
-rw-r--r--include/ocl/fix/parser.hpp (renamed from include/ocl/fix/fix.hpp)11
-rw-r--r--include/ocl/memory/tracked_ptr.hpp2
-rw-r--r--tests/fix_basic/fix_test.cc17
9 files changed, 57 insertions, 24 deletions
diff --git a/examples/fix/CMakeLists.txt b/examples/fix/CMakeLists.txt
index 4c0a432..1001563 100644
--- a/examples/fix/CMakeLists.txt
+++ b/examples/fix/CMakeLists.txt
@@ -6,10 +6,7 @@ project(
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 ../../include/ocl)
diff --git a/examples/fix/fix.cc b/examples/fix/fix.cc
index b2d2915..3dbfafb 100644
--- a/examples/fix/fix.cc
+++ b/examples/fix/fix.cc
@@ -6,7 +6,7 @@
#include <core/error_handler.hpp>
#include <net/modem.hpp>
-#include <fix/fix.hpp>
+#include <fix/parser.hpp>
#include <iostream>
#include <unistd.h>
#include <io/print.hpp>
@@ -15,9 +15,20 @@
/* finally test it */
int main(int argc, char** argv)
{
- constexpr auto default_fix = "8=FIX.4.2\x01 9=65 \x01 35=A \x01 49=SERVER \x01 56=CLIENT \x01 34=177 \x01 52=20090107-18:15:16 \x01 98=0 \x01 108=30 \x01 10=062 \x01 ";
+ 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<char> basic_visitor;
+ 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;
@@ -29,8 +40,9 @@ int main(int argc, char** argv)
for (auto fields : fix.body_)
{
- ocl::io::print("key=", fields.first);
- ocl::io::print(", value=", fields.second);
+ ocl::io::print("key=", fields.first);
+ ocl::io::print(":value=", fields.second);
+ ocl::io::print("\n");
}
return 0;
diff --git a/examples/tracked_ptr/tracked_ptr.cc b/examples/tracked_ptr/tracked_ptr.cc
index 0f7c43d..3f1a4ec 100644
--- a/examples/tracked_ptr/tracked_ptr.cc
+++ b/examples/tracked_ptr/tracked_ptr.cc
@@ -46,7 +46,8 @@ 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;
- ocl::memory::must_pass(ptr);
+ ocl::standard_error_handler err;
+ ocl::memory::must_pass(ptr, err);
return EXIT_SUCCESS;
}
diff --git a/include/ocl/core/config.hpp b/include/ocl/core/config.hpp
index de1ce76..59f2491 100644
--- a/include/ocl/core/config.hpp
+++ b/include/ocl/core/config.hpp
@@ -14,6 +14,15 @@
#include <boost/container/allocator.hpp>
#include <boost/assert.hpp>
+#include <cstddef>
+#include <cassert>
+#include <utility>
+#include <string>
+#include <vector>
+#include <cstdint>
+#include <sys/types.h>
+#include <unistd.h>
+
#ifdef __cplusplus
/// DLL/Dylib/So specific macro.
# define OCL_EXPORT_DECL extern "C" BOOST_SYMBOL_EXPORT
diff --git a/include/ocl/core/error_handler.hpp b/include/ocl/core/error_handler.hpp
index 717b522..a09f450 100644
--- a/include/ocl/core/error_handler.hpp
+++ b/include/ocl/core/error_handler.hpp
@@ -20,8 +20,8 @@ namespace ocl
explicit basic_error_handler() = default;
virtual ~basic_error_handler() = default;
- basic_error_handler& operator=(const basic_error_handler&) = delete;
- basic_error_handler(const basic_error_handler&) = delete;
+ basic_error_handler& operator=(const basic_error_handler&) = default;
+ basic_error_handler(const basic_error_handler&) = default;
template <bool throw_too = false>
void error(const std::basic_string<char>& msg)
diff --git a/include/ocl/fix/checksum.hpp b/include/ocl/fix/checksum.hpp
new file mode 100644
index 0000000..9205664
--- /dev/null
+++ b/include/ocl/fix/checksum.hpp
@@ -0,0 +1,10 @@
+/*
+ * 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>
diff --git a/include/ocl/fix/fix.hpp b/include/ocl/fix/parser.hpp
index 85a8b70..a513a1f 100644
--- a/include/ocl/fix/fix.hpp
+++ b/include/ocl/fix/parser.hpp
@@ -1,5 +1,5 @@
/*
- * File: fix/fix.hpp
+ * 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.
@@ -8,14 +8,7 @@
#ifndef _OCL_FIX_PARSER_HPP
#define _OCL_FIX_PARSER_HPP
-#include <cstddef>
-#include <cassert>
-#include <utility>
-#include <string>
-#include <vector>
-#include <cstdint>
-#include <sys/types.h>
-#include <unistd.h>
+#include <core/config.hpp>
namespace ocl::fix
{
diff --git a/include/ocl/memory/tracked_ptr.hpp b/include/ocl/memory/tracked_ptr.hpp
index fcaf898..029e424 100644
--- a/include/ocl/memory/tracked_ptr.hpp
+++ b/include/ocl/memory/tracked_ptr.hpp
@@ -1,6 +1,6 @@
/*
* File: memory/tracked_ptr.hpp
- * Purpose: Custom smart pointer implementation in C++
+ * Purpose: Strict pointer type implementation in C++
* Author: Amlal El Mahrouss (amlal@nekernel.org)
* Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
*/
diff --git a/tests/fix_basic/fix_test.cc b/tests/fix_basic/fix_test.cc
index f7064b5..122d918 100644
--- a/tests/fix_basic/fix_test.cc
+++ b/tests/fix_basic/fix_test.cc
@@ -5,14 +5,25 @@
* Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
*/
-#include <fix/fix.hpp>
+#include <fix/parser.hpp>
#include <tests/hpptest.hpp>
#include <tests/gtest.hpp>
TEST(FIXTest, BasicFIXUsage)
{
- constexpr auto default_fix = "8=FIX.4.2\x01 9=65\x01 35=A\x01 49=SERVER\x01 56=CLIENT\x01 34=177\x01 52=20090107-18:15:16\x01 98=0\x01 108=30\x01 10=062\x01";
-
+ 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<char> basic_visitor;
ocl::fix::basic_range_data<char> fix = basic_visitor.visit(default_fix);