summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-02-27 22:37:31 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2026-02-27 22:37:31 +0100
commitf7a6fd9a6efd7a603e534242f3aa21e782a61958 (patch)
treeeb442cdbdc2e21593d2acc2659328f09e97cb5a9 /src
parentc5b3eb06fd0fd4f1f29b5c76c1b8865c55b88ea9 (diff)
feat: moving checksum to sources directory, update file structure.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src')
-rw-r--r--src/fix/checksum.cpp44
-rw-r--r--src/fix/parser.cpp (renamed from src/fix/parser_impl.cpp)4
-rw-r--r--src/test/.keep0
3 files changed, 46 insertions, 2 deletions
diff --git a/src/fix/checksum.cpp b/src/fix/checksum.cpp
new file mode 100644
index 0000000..e8e155f
--- /dev/null
+++ b/src/fix/checksum.cpp
@@ -0,0 +1,44 @@
+/*
+ * File: fix/checksum.cpp
+ * Purpose: Financial Information Exchange parser in C++
+ * Author: Amlal El Mahrouss (amlal@nekernel.org)
+ * Copyright 2026, Amlal El Mahrouss, licensed under the Boost Software License.
+ */
+
+#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
diff --git a/src/fix/parser_impl.cpp b/src/fix/parser.cpp
index 4db9873..d12056b 100644
--- a/src/fix/parser_impl.cpp
+++ b/src/fix/parser.cpp
@@ -1,5 +1,5 @@
/*
- * File: fix/parser_impl.cpp
+ * File: fix/parser.cpp
* Purpose: Financial Information Exchange parser in C++
* Author: Amlal El Mahrouss (amlal@nekernel.org)
* Copyright 2025-2026, Amlal El Mahrouss, licensed under the Boost Software License.
@@ -84,7 +84,7 @@ namespace ocl::fix
visitor::visitor() = default;
visitor::~visitor() = default;
- /// \brief Alias of visit.
+ /// @brief Alias of visit.
range_buffer visitor::operator()(const std::string& in)
{
return impl_->visit(in.data());
diff --git a/src/test/.keep b/src/test/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/test/.keep