diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-01-01 19:43:19 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2026-01-01 19:43:19 +0100 |
| commit | 0ac8ded5b0046be772461e65bcb81dc09c4db810 (patch) | |
| tree | e43d4eac5d466af73635e34fb8584178cf7adeee /include/ocl/fix | |
| parent | 7ea24be51ef95a864d4e3dde7395780244a69f15 (diff) | |
feat! API and namespace improvements.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include/ocl/fix')
| -rw-r--r-- | include/ocl/fix/checksum.hpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/include/ocl/fix/checksum.hpp b/include/ocl/fix/checksum.hpp index 451e387..6492acf 100644 --- a/include/ocl/fix/checksum.hpp +++ b/include/ocl/fix/checksum.hpp @@ -27,7 +27,7 @@ namespace ocl::fix } /// \brief FIX message operators namespace. - namespace operators::fix + namespace operators { using checksum_type = long long; @@ -35,23 +35,21 @@ namespace ocl::fix /// \param in_ Pointer to the message buffer. /// \param len Length of the message in bytes. /// \return The checksum value (sum of all bytes modulo 256). - inline constexpr checksum_type - checksum(const char* in_, - const std::size_t len) + constexpr inline checksum_type + checksum(const std::string_view& in_) noexcept { - if (len < 1) - return 0L; - checksum_type cks{}; - for (std::size_t idx{}; idx < len; ++idx) - { - cks += static_cast<uint8_t>(in_[idx]); - } + for (std::size_t idx{}; + idx < in_.size(); ++idx) + cks += static_cast<uint8_t>(in_[idx]); + + // add \0 + cks += 1; return cks % 256; } - } // namespace operators::fix + } // namespace operators } // namespace ocl::fix |
