diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-02-26 22:56:57 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2026-02-26 22:56:57 +0100 |
| commit | c5b3eb06fd0fd4f1f29b5c76c1b8865c55b88ea9 (patch) | |
| tree | 7e5a272f007376d73278584f1345881d57895946 | |
| parent | 9314dede83ef22422c81388b58100d01b85dd7bb (diff) | |
feat: fix/fix.inl: introduce ocl/fix.inl header.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | include/ocl/fix.hpp | 4 | ||||
| -rw-r--r-- | include/ocl/fix.inl | 84 | ||||
| -rw-r--r-- | include/ocl/fix/checksum.hpp | 4 | ||||
| -rw-r--r-- | include/ocl/fix/detail/config.hpp | 2 | ||||
| -rw-r--r-- | include/ocl/fix/parser.hpp | 4 | ||||
| -rw-r--r-- | src/fix/parser_impl.cpp | 3 |
6 files changed, 95 insertions, 6 deletions
diff --git a/include/ocl/fix.hpp b/include/ocl/fix.hpp index 856623d..dcd9c41 100644 --- a/include/ocl/fix.hpp +++ b/include/ocl/fix.hpp @@ -2,7 +2,7 @@ * File: fix.hpp * Purpose: Financial Information Exchange function and headers in C++ * Author: Amlal El Mahrouss (amlal@nekernel.org) - * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License. + * Copyright 2025-2026, Amlal El Mahrouss, licensed under the Boost Software License. */ #ifndef OCL_FIX_HPP @@ -29,4 +29,6 @@ namespace ocl::fix } // namespace ocl::fix +#include <ocl/fix/fix.inl> + #endif diff --git a/include/ocl/fix.inl b/include/ocl/fix.inl new file mode 100644 index 0000000..44e5c1b --- /dev/null +++ b/include/ocl/fix.inl @@ -0,0 +1,84 @@ +// Copyright 2025-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// Official repository: https://github.com/ocl-org/fix + +#ifndef OCL_FIX_FIX_INL +#define OCL_FIX_FIX_INL + +namespace ocl::fix +{ + + template <typename It, class Pred> + Pred find(It begin, It end, Pred pred) + { + for (auto it = begin; it != end; ++it) + { + if (*it == pred) + { + return *it; + } + } + + return end; + } + + template <typename It, class Pred> + Pred find_if(It begin, It end, Pred pred) + { + for (auto it = begin; it != end; ++it) + { + if (pred(it)) + { + return *it; + } + } + + return end; + } + + template <typename It, class Pred> + typename Pred::size_type erase(It begin, It end, Pred pred) + { + typename Pred::size_type count{}; + + for (auto it = begin; it != end;) + { + if (*it == pred) + { + it = begin.erase(it); + ++count; + } + else + { + ++it; + } + } + + return count; + } + + template <typename It, class Pred> + typename Pred::size_type erase_if(It begin, It end, Pred) + { + typename Pred::size_type count{}; + + for (auto it = begin; it != end;) + { + if (pred(it)) + { + it = begin.erase(it); + ++count; + } + else + { + ++it; + } + } + + return count; + } + +} // namespace ocl::fix + +#endif diff --git a/include/ocl/fix/checksum.hpp b/include/ocl/fix/checksum.hpp index e1ed745..2672996 100644 --- a/include/ocl/fix/checksum.hpp +++ b/include/ocl/fix/checksum.hpp @@ -2,7 +2,7 @@ * 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. + * Copyright 2025-2026, Amlal El Mahrouss, licensed under the Boost Software License. */ #ifndef OCL_FIX_CHECKSUM @@ -34,6 +34,7 @@ namespace ocl::fix /// \brief FIX message operators namespace. namespace operators { + using checksum_type = long long; /// \brief Calculates the FIX protocol checksum for a message. @@ -53,6 +54,7 @@ namespace ocl::fix cks += 1; return cks % 256; } + } // namespace operators } // namespace ocl::fix diff --git a/include/ocl/fix/detail/config.hpp b/include/ocl/fix/detail/config.hpp index 582f349..a6e6fb9 100644 --- a/include/ocl/fix/detail/config.hpp +++ b/include/ocl/fix/detail/config.hpp @@ -2,7 +2,7 @@ * File: detail/config.hpp * Purpose: Config file of the OCL.FIX library. * Author: Amlal El Mahrouss (amlal@nekernel.org) - * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License. + * Copyright 2025-2026, Amlal El Mahrouss, licensed under the Boost Software License. */ #ifndef OCL_FIX_CONFIG diff --git a/include/ocl/fix/parser.hpp b/include/ocl/fix/parser.hpp index 560ecb9..086b6a7 100644 --- a/include/ocl/fix/parser.hpp +++ b/include/ocl/fix/parser.hpp @@ -2,7 +2,7 @@ * 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. + * Copyright 2025-2026, Amlal El Mahrouss, licensed under the Boost Software License. */ // Copyright 2025-2026, Amlal El Mahrouss (amlal@nekernel.org) @@ -123,7 +123,7 @@ namespace ocl::fix visitor(); ~visitor(); - /// \brief Alias of visit. + /// @brief Alias of visit. range_buffer operator()(const std::string& in); /// @brief Visits a FIX message and parse it into a range_buffer object. diff --git a/src/fix/parser_impl.cpp b/src/fix/parser_impl.cpp index 11333fd..4db9873 100644 --- a/src/fix/parser_impl.cpp +++ b/src/fix/parser_impl.cpp @@ -2,11 +2,12 @@ * File: fix/parser_impl.cpp * 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. + * Copyright 2025-2026, Amlal El Mahrouss, licensed under the Boost Software License. */ #define OCL_FIX_HAS_IMPL #include <ocl/fix/parser.hpp> +#include <boost/algorithm/cxx11/is_sorted.hpp> namespace ocl::fix { |
