HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
ResourceView.hpp
1// Copyright 2019 Pokitec
2// All rights reserved.
3
4#pragma once
5
6#include <nonstd/span>
7#include <variant>
8#include <functional>
9#include <cstddef>
10#include <string_view>
11
12namespace tt {
13class URL;
14
18public:
19 ResourceView() = default;
20 virtual ~ResourceView() = default;
21 ResourceView(ResourceView const &other) = default;
22 ResourceView(ResourceView &&other) = default;
23 ResourceView &operator=(ResourceView const &other) = default;
24 ResourceView &operator=(ResourceView &&other) = default;
25
29 [[nodiscard]] virtual size_t offset() const noexcept = 0;
30
33 [[nodiscard]] virtual nonstd::span<std::byte const> bytes() const noexcept = 0;
34
37 [[nodiscard]] virtual std::string_view string_view() const noexcept = 0;
38
39 operator std::string_view () const noexcept {
40 return string_view();
41 }
42
45 [[nodiscard]] virtual size_t size() const noexcept = 0;
46
49 [[nodiscard]] virtual std::byte const *data() const noexcept = 0;
50
51
52};
53
54}
STL namespace.
A read-only memory mapping of a resource.
Definition ResourceView.hpp:17
virtual size_t size() const noexcept=0
Size of the memory mapping.
virtual nonstd::span< std::byte const > bytes() const noexcept=0
Get a span to the memory mapping.
virtual std::byte const * data() const noexcept=0
Pointer 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.