spudplate
Template scaffolding compiler for spudlang .spud files
Loading...
Searching...
No Matches
spudplate::AssetMapSourceProvider Class Referencefinal

SourceProvider backed by a borrowed asset map. More...

#include <interpreter.h>

Inheritance diagram for spudplate::AssetMapSourceProvider:
spudplate::SourceProvider

Public Member Functions

 AssetMapSourceProvider (const std::vector< SpudpackAsset > &assets)
 Construct over a borrowed asset vector; the caller owns the lifetime.
 
std::pair< std::vector< std::uint8_t >, std::uint16_t > read (std::string_view path) const override
 Read the bytes of an asset by its normalised path.
 
std::vector< Entrylist_under (std::string_view prefix) const override
 List every entry under the given prefix, including synthesised intermediate directories.
 

Detailed Description

SourceProvider backed by a borrowed asset map.

Used by cmd_run when running an installed .spp. The provider holds a reference to the asset vector inside the decoded Spudpack; the caller must keep that pack alive for the duration of any call into the interpreter. cmd_run does so by scoping the Spudpack and the provider in the same lexical block.

Member Function Documentation

◆ read()

std::pair< std::vector< std::uint8_t >, std::uint16_t > spudplate::AssetMapSourceProvider::read ( std::string_view  path) const
overridevirtual

Read the bytes of an asset by its normalised path.

Returns the content and the asset mode (or 0 when the provider does not carry mode information).

Implements spudplate::SourceProvider.

◆ list_under()

std::vector< SourceProvider::Entry > spudplate::AssetMapSourceProvider::list_under ( std::string_view  prefix) const
overridevirtual

List every entry under the given prefix, including synthesised intermediate directories.

The returned list is in pre-order (parent before children) so callers that map entries to filesystem operations naturally satisfy the create-parent-first ordering.

Implements spudplate::SourceProvider.