From df4ec096491ded6d58b9ee094d6942e3188c2d4a Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 23 Nov 2025 17:26:48 +0100 Subject: fix: lib: `visit` may now throw exceptions. Signed-off-by: Amlal El Mahrouss --- dev/lib/core/chunk_string.hpp | 2 +- dev/lib/fix/fix.hpp | 51 +++++++++++++++++++----------------------- dev/lib/logic/math.hpp | 4 ++-- dev/lib/memory/tracked_ptr.hpp | 2 +- dev/lib/net/modem.hpp | 1 - dev/lib/simd/simd.hpp | 4 ++-- dev/lib/utility/cgi.hpp | 2 +- dev/lib/utility/embfs.hpp | 2 +- 8 files changed, 31 insertions(+), 37 deletions(-) (limited to 'dev') diff --git a/dev/lib/core/chunk_string.hpp b/dev/lib/core/chunk_string.hpp index 0ecc73e..e32d030 100644 --- a/dev/lib/core/chunk_string.hpp +++ b/dev/lib/core/chunk_string.hpp @@ -94,7 +94,7 @@ namespace ocl std::basic_string str() const noexcept { static std::basic_string ret; - const auto& sz = ret.size(); + const auto& sz = ret.size(); if (chunk_total_ > sz) ret.clear(); diff --git a/dev/lib/fix/fix.hpp b/dev/lib/fix/fix.hpp index 08360d5..0c6685d 100644 --- a/dev/lib/fix/fix.hpp +++ b/dev/lib/fix/fix.hpp @@ -151,6 +151,9 @@ namespace ocl::fix return this->visit(in); } + /// @brief Visit a FIX message and parse it into a basic_range_data object. + /// @param in The input FIX message as a string. + /// @warning This function may throw exceptions. basic_range_data visit(const std::basic_string& in) { thread_local basic_range_data ret{}; @@ -160,37 +163,29 @@ namespace ocl::fix std::basic_string in_tmp{"", in.size()}; - try + for (auto& ch : in) { - for (auto& ch : in) + if (ch != basic_visitor::soh) { - if (ch != basic_visitor::soh) - { - in_tmp += ch; - continue; - } - - std::basic_string key = in_tmp.substr(0, in_tmp.find(basic_visitor::eq)); - std::basic_string val = in_tmp.substr(in_tmp.find(basic_visitor::eq) + 1); - - if (ret.magic_.empty()) - { - ret.magic_ = val; - ret.magic_len_ = ret.magic_.size(); - } - else - { - ret.body_.emplace_back(std::make_pair(key, val)); - ret.body_len_ += in_tmp.size(); - } - - in_tmp.clear(); + in_tmp += ch; + continue; } - } - catch (...) - { + + std::basic_string key = in_tmp.substr(0, in_tmp.find(basic_visitor::eq)); + std::basic_string val = in_tmp.substr(in_tmp.find(basic_visitor::eq) + 1); + + if (ret.magic_.empty()) + { + ret.magic_ = val; + ret.magic_len_ = ret.magic_.size(); + } + else + { + ret.body_.emplace_back(std::make_pair(key, val)); + ret.body_len_ += in_tmp.size(); + } + in_tmp.clear(); - return ret; } in_tmp.clear(); @@ -210,7 +205,7 @@ namespace ocl::fix using fix_tag_type = std::uint32_t; using range_data = basic_range_data; - using visitor = basic_visitor; + using visitor = basic_visitor; } // namespace ocl::fix #endif // ifndef _OCL_FIX_PARSER_HPP \ No newline at end of file diff --git a/dev/lib/logic/math.hpp b/dev/lib/logic/math.hpp index 52f4535..d131ef9 100644 --- a/dev/lib/logic/math.hpp +++ b/dev/lib/logic/math.hpp @@ -27,7 +27,7 @@ namespace ocl static constexpr const bool value = false; }; - constexpr inline auto not_a_number = __builtin_nanf (""); - constexpr inline auto positive_infinity = __builtin_inff (); + constexpr inline auto not_a_number = __builtin_nanf(""); + constexpr inline auto positive_infinity = __builtin_inff(); constexpr inline auto negative_infinity = -positive_infinity; } // namespace ocl \ No newline at end of file diff --git a/dev/lib/memory/tracked_ptr.hpp b/dev/lib/memory/tracked_ptr.hpp index 0ea0e32..2df5db5 100644 --- a/dev/lib/memory/tracked_ptr.hpp +++ b/dev/lib/memory/tracked_ptr.hpp @@ -140,7 +140,7 @@ namespace ocl::memory this->reset(); } - tracked_ptr(const tracked_ptr&) = delete; + tracked_ptr(const tracked_ptr&) = delete; tracked_ptr& operator=(const tracked_ptr&) = delete; public: diff --git a/dev/lib/net/modem.hpp b/dev/lib/net/modem.hpp index fd64f72..d86234b 100644 --- a/dev/lib/net/modem.hpp +++ b/dev/lib/net/modem.hpp @@ -165,4 +165,3 @@ namespace ocl::net } }; } // namespace ocl::net - diff --git a/dev/lib/simd/simd.hpp b/dev/lib/simd/simd.hpp index 239e512..f15f88a 100644 --- a/dev/lib/simd/simd.hpp +++ b/dev/lib/simd/simd.hpp @@ -30,11 +30,11 @@ namespace ocl::simd }; public: - real_type() = default; + real_type() = default; virtual ~real_type() = default; real_type& operator=(const real_type&) = delete; - real_type(const real_type&) = delete; + real_type(const real_type&) = delete; typename backend_type::register_type& call(const opcode& op, typename backend_type::register_type& lhs, typename backend_type::register_type& rhs) { diff --git a/dev/lib/utility/cgi.hpp b/dev/lib/utility/cgi.hpp index fd00bbf..4cc913b 100644 --- a/dev/lib/utility/cgi.hpp +++ b/dev/lib/utility/cgi.hpp @@ -37,7 +37,7 @@ namespace ocl public: explicit basic_writer() = default; - virtual ~basic_writer() = default; + virtual ~basic_writer() = default; basic_writer& operator=(const basic_writer&) = default; basic_writer(const basic_writer&) = default; diff --git a/dev/lib/utility/embfs.hpp b/dev/lib/utility/embfs.hpp index e2e5d18..8a716ce 100644 --- a/dev/lib/utility/embfs.hpp +++ b/dev/lib/utility/embfs.hpp @@ -37,7 +37,7 @@ namespace ocl::embfs #endif typedef std::int16_t sword_t; - + typedef std::int32_t sdword_t; typedef std::uint8_t utf8_char_t; -- cgit v1.2.3