Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::UrlLoader Class Reference

Utility class for loading a URI or decoding a data URL. More...

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

Classes

struct  Result
 Result of loading a URI or decoding a data URL. More...

Public Member Functions

 UrlLoader (ResourceLoaderInterface &resourceLoader, size_t maximumResourceSize=kDefaultMaximumResourceSize, size_t *remainingResourceBytes=nullptr)
 Create a new URL loader that uses the given resource loader to fetch external resources.
 ~UrlLoader ()=default
 Destructor.
 UrlLoader (const UrlLoader &)=delete
 UrlLoader (UrlLoader &&)=delete
UrlLoaderoperator= (const UrlLoader &)=delete
UrlLoaderoperator= (UrlLoader &&)=delete
std::variant< Result, UrlLoaderErrorfromUri (std::string_view uri)
 Read an image from a URI, which can be a file path, a URL, or a data URL (e.g.

Static Public Member Functions

static std::optional< UrlLoaderErrorvalidateExternalUriRepresentation (std::string_view uri)
 Validate an external URI before any copy, hash, cache lookup, or callback.

Static Public Attributes

static constexpr size_t kDefaultMaximumResourceSize = 16 * 1024 * 1024
 Default maximum decoded or fetched resource size.
static constexpr size_t kMaximumExternalUriSize = 4096
 Maximum external URI bytes accepted before copying, hashing, or invoking a callback.

Detailed Description

Utility class for loading a URI or decoding a data URL.


Class Documentation

◆ donner::svg::UrlLoader::Result

struct donner::svg::UrlLoader::Result

Result of loading a URI or decoding a data URL.

Class Members
vector< uint8_t > data Loaded data, either from a data URL or from a fetched URI.
string mimeType MIME type of the data, if known. Otherwise, an empty string.

Constructor & Destructor Documentation

◆ UrlLoader()

donner::svg::UrlLoader::UrlLoader ( ResourceLoaderInterface & resourceLoader,
size_t maximumResourceSize = kDefaultMaximumResourceSize,
size_t * remainingResourceBytes = nullptr )
inlineexplicit

Create a new URL loader that uses the given resource loader to fetch external resources.

Parameters
resourceLoaderResource loader to use for fetching external resources.

Member Function Documentation

◆ fromUri()

std::variant< Result, UrlLoaderError > donner::svg::UrlLoader::fromUri ( std::string_view uri)

Read an image from a URI, which can be a file path, a URL, or a data URL (e.g.

"data:image/png;base64,...").

Parameters
uriURI of the image, or data URL containing a base64 embedded image.
Returns
Loaded image data or an error code.

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