From 989d015f105ada9e0c0d2ba43c9e18010ec13385 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 3 Aug 2025 20:03:31 +0100 Subject: feat! replace deliver_modem with basic_delivery_modem, add checks for pointer too. Signed-off-by: Amlal El Mahrouss --- dev/lib/fix/network.hpp | 23 ++++++++++++++--------- dev/lib/fix/parser.hpp | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'dev/lib/fix') diff --git a/dev/lib/fix/network.hpp b/dev/lib/fix/network.hpp index e663869..9b08b5c 100644 --- a/dev/lib/fix/network.hpp +++ b/dev/lib/fix/network.hpp @@ -2,7 +2,7 @@ * File: fix/network.hpp * Purpose: Financial Information Exchange in C++ * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp all rights reserved. + * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. */ #ifndef _SNU_FIX_NETWORK_HPP @@ -10,23 +10,24 @@ #include #include +#include #include namespace snu::fix { - class delivery_modem; + class basic_delivery_modem; typedef int32_t delivery_socket_type; /// @brief a delivery modem is a container which establishes a comm. channel between the FIX session and application. - class delivery_modem final + class basic_delivery_modem final { public: - explicit delivery_modem() = default; - ~delivery_modem() = default; + explicit basic_delivery_modem() = default; + ~basic_delivery_modem() = default; - delivery_modem& operator=(const delivery_modem&) = default; - delivery_modem(const delivery_modem&) = default; + basic_delivery_modem& operator=(const basic_delivery_modem&) = default; + basic_delivery_modem(const basic_delivery_modem&) = default; public: static constexpr auto local_address = "127.0.0.1"; @@ -38,6 +39,8 @@ namespace snu::fix template bool receive(T& out, std::size_t len) noexcept { + static_assert(std::is_pointer::value, "T is not a pointer!"); + if (!out) return false; @@ -52,6 +55,8 @@ namespace snu::fix template bool transmit(T& out, std::size_t len) noexcept { + static_assert(std::is_pointer::value, "T is not a pointer!"); + if (!out) return false; @@ -64,7 +69,7 @@ namespace snu::fix } template - bool construct(const char* addr = delivery_modem::local_address, const bool& is_server = false) noexcept + bool construct(const char* addr = basic_delivery_modem::local_address, const bool& is_server = false) noexcept { static_assert(AF != 0, "AF is zero"); static_assert(Kind != 0, "Kind is zero"); @@ -88,7 +93,7 @@ namespace snu::fix return ret == 0; } - ::listen(fd_, delivery_modem::backlog_count); + ::listen(fd_, basic_delivery_modem::backlog_count); return true; } diff --git a/dev/lib/fix/parser.hpp b/dev/lib/fix/parser.hpp index a195eb3..5701783 100644 --- a/dev/lib/fix/parser.hpp +++ b/dev/lib/fix/parser.hpp @@ -2,7 +2,7 @@ * 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 all rights reserved. + * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. */ #ifndef _SNU_FIX_PARSER_HPP -- cgit v1.2.3