HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
resource_view.hpp
1// Copyright Take Vos 2019-2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include <span>
8#include <variant>
9#include <functional>
10#include <cstddef>
11#include <string_view>
12
13namespace tt {
14class URL;
15
19public:
20 resource_view() = default;
21 virtual ~resource_view() = default;
22 resource_view(resource_view const &other) = default;
23 resource_view(resource_view &&other) = default;
24 resource_view &operator=(resource_view const &other) = default;
25 resource_view &operator=(resource_view &&other) = default;
26
30 [[nodiscard]] virtual size_t offset() const noexcept = 0;
31
34 [[nodiscard]] virtual std::span<std::byte const> bytes() const noexcept = 0;
35
38 [[nodiscard]] virtual std::string_view string_view() const noexcept = 0;
39
40 operator std::span<std::byte const> () const noexcept {
41 return bytes();
42 }
43
46 [[nodiscard]] virtual size_t size() const noexcept = 0;
47
50 [[nodiscard]] virtual std::byte const *data() const noexcept = 0;
51
52
53};
54
55}
STL namespace.
A read-only memory mapping of a resource.
Definition resource_view.hpp:18
virtual std::byte const * data() const noexcept=0
Pointer to the memory mapping.
virtual std::span< std::byte const > bytes() const noexcept=0
Get a span to the memory mapping.
virtual size_t offset() const noexcept=0
Offset into the resource file.
virtual std::string_view string_view() const noexcept=0
Get a span to the memory mapping.
virtual size_t size() const noexcept=0
Size of the memory mapping.