CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
URLSession.File.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "URLSession.hpp"
11
12namespace CeresEngine {
13
16 class FileURLProtocol final : public TURLProtocol<FileURLProtocol, "File"> {
17 public:
19 class Request : public IURLRequest {
20 public:
22 bool allowMissing = false;
23
24 public:
26 explicit Request(const IURLRequest& other) : IURLRequest(other) {}
27
29 explicit Request(const URL& url, const CachePolicy& cachePolicy = CachePolicy::Default) : IURLRequest(url, cachePolicy) {}
30 };
31
33 class Response : public IURLResponse {
34 public:
36
37 public:
39 explicit Response(const URLRequest& request, const FilePath& path);
40
41 public:
44
47
50 };
51
52 public:
53 using TURLProtocol::TURLProtocol;
54
55 public:
57 [[nodiscard]] bool isRequestSupported(const URLRequest& request) final;
58
60 [[nodiscard]] Async<URLResponse> execute(Task& connection) final;
61 };
62
65
68
69} // namespace CeresEngine
General purpose class used for encapsulating the reading and writing of data from and to various sour...
Definition Stream.hpp:460
Path to file or directory.
Definition FilePath.hpp:37
The URLRequest object for FileURLProtocol.
Definition URLSession.File.hpp:19
bool allowMissing
Allows returning a response even if the file is missing.
Definition URLSession.File.hpp:22
Request(const URL &url, const CachePolicy &cachePolicy=CachePolicy::Default)
Creates a new Request object.
Definition URLSession.File.hpp:29
Request(const IURLRequest &other)
Creates a new Request object by copying from another.
Definition URLSession.File.hpp:26
The URLResponse object for FileURLProtocol.
Definition URLSession.File.hpp:33
URLInputStream openInputStream() override
const FilePath path
Definition URLSession.File.hpp:35
URLDataStream openDataStream() override
Response(const URLRequest &request, const FilePath &path)
Creates a new Response object.
URLOutputStream openOutputStream() override
A URLProtocol implementation that fetches resources from the local operating system file system.
Definition URLSession.File.hpp:16
Async< URLResponse > execute(Task &connection) final
bool isRequestSupported(const URLRequest &request) final
Checks if the given request is supported by the protocol.
A URL load request that is independent of protocol or URL scheme.
Definition URLSession.hpp:85
CachePolicy cachePolicy
The request's cache policy.
Definition URLSession.hpp:114
const URL url
The URL of the request.
Definition URLSession.hpp:106
The metadata associated with the response to a URL load request, independent of protocol and URL sche...
Definition URLSession.hpp:161
const URLRequest request
The request that triggered the response.
Definition URLSession.hpp:164
A stream that provides read-only stream functionality.
Definition Stream.hpp:210
A stream that provides write-only stream functionality.
Definition Stream.hpp:307
Creates a new URLProtocol instance.
Definition URLSession.hpp:377
A Uniform Resource Identifier (URI) is a unique sequence of characters that identifies a logical or p...
Definition URI.hpp:54
An object that manages the task for a URL request.
Definition URLSession.hpp:263
A URL load request that is independent of protocol or URL scheme.
Definition URLSession.hpp:131
Definition Application.hpp:19
cti::continuable< Args... > Async
Defines a non-copyable continuation type which uses the function2 backend for type erasure.
Definition Async.hpp:22
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
An enumeration that describes how the URLProtocol implementation should handle caching of this reques...
Definition URLSession.hpp:89