HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
static_resource_view.hpp
1// Copyright Take Vos 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 "resource_view.hpp"
8#include "required.hpp"
9#include <span>
10#include <cstddef>
11#include <unordered_map>
12
13namespace hi::inline v1 {
14
18public:
19 static_resource_view(std::string const &filename);
20
21 static_resource_view() = delete;
22 ~static_resource_view() = default;
23 static_resource_view(static_resource_view const &other) = default;
24 static_resource_view &operator=(static_resource_view const &other) = default;
26 static_resource_view &operator=(static_resource_view &&other) = default;
27
28 [[nodiscard]] std::size_t offset() const noexcept override
29 {
30 return 0;
31 }
32
33 [[nodiscard]] const_void_span span() const noexcept override
34 {
35 return _bytes;
36 }
37
38 [[nodiscard]] static std::unique_ptr<resource_view> loadView(std::string const &location)
39 {
40 return std::make_unique<static_resource_view>(location);
41 }
42
51
52private:
53 // Borrowed reference from a byte array inside StaticResources.
54 const_void_span _bytes;
55};
56
57} // namespace hi::inline v1
This file includes required definitions.
A read-only memory mapping of a resource.
Definition resource_view.hpp:20
A resource that was included in the executable.
Definition static_resource_view.hpp:17
const_void_span span() const noexcept override
Get a span to the memory mapping.
Definition static_resource_view.hpp:33
static const_void_span get_static_resource(std::string const &filename)
Get the data of a static resource.
std::size_t offset() const noexcept override
Offset into the resource file.
Definition static_resource_view.hpp:28
Definition void_span.hpp:156