blob: ab91a6de10247bdf2489b093c3f2026bd88d8cdf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// SPDX-License-Identifier: BSL-1.0
// Copyright 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-foss-org/fix
#include <ocl/fix/checksum.hpp>
namespace ocl::fix
{
std::string try_index_checksum(range_buffer& fix)
{
if (fix.is_valid())
return fix["10"];
else
detail::throw_runtime_error();
detail::unreachable();
return {};
}
namespace operators
{
checksum_type
checksum(const boost::string_view& in_) noexcept
{
checksum_type cks{};
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
} // namespace ocl::fix
|