MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
SliceRange.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Contributors to the Media eXchange Layer project.
2//
3// SPDX-License-Identifier: Apache-2.0
4
5#pragma once
6
7#include <cstdint>
8
10{
16 {
17 public:
26 [[nodiscard]]
27 static SliceRange make(std::uint16_t start, std::uint16_t end);
28
31 [[nodiscard]]
32 std::uint16_t start() const noexcept;
33
36 [[nodiscard]]
37 std::uint16_t end() const noexcept;
38
42 [[nodiscard]]
43 std::uint32_t transferSize(std::uint32_t sliceSize) const noexcept;
44
48 [[nodiscard]]
49 std::uint32_t transferOffset(std::uint32_t payloadOffset, std::uint32_t sliceSize) const noexcept;
50
51 private:
52 SliceRange(std::uint16_t start, std::uint16_t end) noexcept
53 : _start(start)
54 , _end(end)
55 {}
56
57 private:
58 std::uint16_t _start;
59 std::uint16_t _end;
60 };
61}
SliceRange(std::uint16_t start, std::uint16_t end) noexcept
std::uint32_t transferSize(std::uint32_t sliceSize) const noexcept
Get the size of the range (end - start).
std::uint32_t transferOffset(std::uint32_t payloadOffset, std::uint32_t sliceSize) const noexcept
Get the offset within the payload for the start of the range.
std::uint16_t end() const noexcept
Get the exclusive end of the range.
std::uint16_t start() const noexcept
Get the inclusive start of the range.
static SliceRange make(std::uint16_t start, std::uint16_t end)
Create a SliceRange representing the range [start, end).