diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 23:02:29 -0500 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 23:02:29 -0500 |
| commit | b189449b28625cec7b6ce399f999072e50efae45 (patch) | |
| tree | e0c8355c438b23969bad384410d5e0861dbd302a | |
| parent | bf2c4bc8c719159b4ddd1b40e032c449424abd5d (diff) | |
feat: expanding FIX module.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | examples/fix/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | examples/fix/fix.cc | 22 | ||||
| -rw-r--r-- | include/ocl/core/config.hpp | 9 | ||||
| -rw-r--r-- | include/ocl/fix/checksum.hpp | 10 | ||||
| -rw-r--r-- | include/ocl/fix/parser.hpp (renamed from include/ocl/fix/fix.hpp) | 11 | ||||
| -rw-r--r-- | tests/fix_basic/fix_test.cc | 17 |
6 files changed, 52 insertions, 20 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/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/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/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); |
