Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::svg::SandboxedFileResourceLoader Class Reference

Interface for loading external resources, such as images. More...

#include "donner/svg/resources/SandboxedFileResourceLoader.h"

Inheritance diagram for donner::svg::SandboxedFileResourceLoader:
[legend]
Collaboration diagram for donner::svg::SandboxedFileResourceLoader:
[legend]

Public Member Functions

 SandboxedFileResourceLoader (const std::filesystem::path &root, const std::filesystem::path &documentPath)
 Create a new resource loader that loads files sandboxed within the given root directory.
 
 SandboxedFileResourceLoader (const SandboxedFileResourceLoader &)=delete
 
SandboxedFileResourceLoaderoperator= (const SandboxedFileResourceLoader &)=delete
 
 SandboxedFileResourceLoader (SandboxedFileResourceLoader &&)=delete
 
SandboxedFileResourceLoaderoperator= (SandboxedFileResourceLoader &&)=delete
 
 ~SandboxedFileResourceLoader () override=default
 Destructor.
 
std::variant< std::vector< uint8_t >, ResourceLoaderErrorfetchExternalResource (std::string_view url) override
 Fetch external resource from a given URL.
 
- Public Member Functions inherited from donner::svg::ResourceLoaderInterface
 ResourceLoaderInterface ()=default
 Default constructor.
 
 ResourceLoaderInterface (const ResourceLoaderInterface &)=delete
 
ResourceLoaderInterfaceoperator= (const ResourceLoaderInterface &)=delete
 
 ResourceLoaderInterface (ResourceLoaderInterface &&)=delete
 
ResourceLoaderInterfaceoperator= (ResourceLoaderInterface &&)=delete
 
virtual ~ResourceLoaderInterface ()=default
 Destructor.
 

Detailed Description

Interface for loading external resources, such as images.

To load files from the local filesystem, use SandboxedFileResourceLoader.

Constructor & Destructor Documentation

◆ SandboxedFileResourceLoader()

donner::svg::SandboxedFileResourceLoader::SandboxedFileResourceLoader ( const std::filesystem::path & root,
const std::filesystem::path & documentPath )
explicit

Create a new resource loader that loads files sandboxed within the given root directory.

Paths should be relative to the documentPath directory. Paths that use ".." to escape the root directory will be rejected.

Parameters
rootSandbox directory, loads outside of this directory will be rejected.
documentPathPath to the document being loaded, used to resolve relative paths.

Member Function Documentation

◆ fetchExternalResource()

std::variant< std::vector< uint8_t >, ResourceLoaderError > donner::svg::SandboxedFileResourceLoader::fetchExternalResource ( std::string_view url)
overridevirtual

Fetch external resource from a given URL.

Parameters
urlURL of the external resource.
Returns
A vector containing the fetched data.

Implements donner::svg::ResourceLoaderInterface.


The documentation for this class was generated from the following files: