diff options
Diffstat (limited to 'include')
| -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 |
5 files changed, 93 insertions, 5 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. |
