spudplate
Template scaffolding compiler for spudlang .spud files
Loading...
Searching...
No Matches
spudplate::SourceProvider Class Referenceabstract

Source of bundled assets the interpreter draws from for from/copy. More...

#include <interpreter.h>

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

Classes

struct  Entry
 One entry returned by list_under. More...
 

Public Member Functions

virtual std::pair< std::vector< std::uint8_t >, std::uint16_t > read (std::string_view path) const =0
 Read the bytes of an asset by its normalised path.
 
virtual std::vector< Entrylist_under (std::string_view prefix) const =0
 List every entry under the given prefix, including synthesised intermediate directories.
 

Detailed Description

Source of bundled assets the interpreter draws from for from/copy.

Two concrete implementations live in src/interpreter.cpp: a disk-backed provider (cwd-relative reads, used when no asset map is supplied) and an asset-map provider (used when running an installed .spp).

Asset paths are bundle-root-relative and pre-normalised by spudplate::normalize_asset_path (forward-slash, no leading /, no . or .. segments, no embedded NUL). A trailing / on a returned Entry path means "empty leaf directory".

mode == 0 is the documented "no mode information" sentinel - the disk-backed provider always reports zero so callers preserve the pre-existing nullopt-mode behaviour of bare-.spud runs.

Member Function Documentation

◆ read()

virtual std::pair< std::vector< std::uint8_t >, std::uint16_t > spudplate::SourceProvider::read ( std::string_view  path) const
pure virtual

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).

Implemented in spudplate::AssetMapSourceProvider.

◆ list_under()

virtual std::vector< Entry > spudplate::SourceProvider::list_under ( std::string_view  prefix) const
pure virtual

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.

Implemented in spudplate::AssetMapSourceProvider.