Concrete IDataLoader that uses the filesystem.
More...
#include <le2d/file_data_loader.hpp>
|
| FileDataLoader (std::string_view root_dir=".") |
|
auto | try_load_bytes (std::vector< std::byte > &out, std::string_view uri) const -> bool final |
|
auto | try_load_spirv (std::vector< std::uint32_t > &out, std::string_view uri) const -> bool final |
|
auto | try_load_string (std::string &out, std::string_view uri) const -> bool final |
|
auto | save_bytes (std::span< std::byte const > bytes, std::string_view uri) const -> bool |
|
auto | save_string (std::string_view text, std::string_view uri) const -> bool |
|
auto | get_root_dir () const -> std::string_view |
|
auto | set_root_dir (std::string_view root_dir) -> bool |
|
auto | get_path (std::string_view uri) const -> std::string |
|
auto | get_uri (std::string_view path) const -> std::string |
|
auto | load_bytes (std::string_view uri) const -> std::vector< std::byte > |
|
auto | load_spir_v (std::string_view uri) const -> std::vector< std::uint32_t > |
|
auto | load_string (std::string_view uri) const -> std::string |
|
auto | try_load_json (dj::Json &out, std::string_view uri) const -> bool |
|
auto | load_json (std::string_view uri) const -> dj::Json |
|
auto | get_json_type_name (std::string_view uri) const -> std::string |
|
|
static auto | upfind (std::string_view suffix, std::string_view leaf_dir=".") -> std::string |
| Locate a directory by cycling upwards every iteration.
|
|
Concrete IDataLoader that uses the filesystem.
◆ FileDataLoader()
le::FileDataLoader::FileDataLoader |
( |
std::string_view |
root_dir = "." | ) |
|
|
explicit |
- Parameters
-
root_dir | Mount point. Will be prefixed to URIs for loads. |
◆ get_path()
auto le::FileDataLoader::get_path |
( |
std::string_view |
uri | ) |
const -> std::string |
- Parameters
-
uri | URI to get full path for. |
- Returns
- Full path (whether it exists or not).
◆ get_root_dir()
auto le::FileDataLoader::get_root_dir |
( |
| ) |
const -> std::string_view |
|
inline |
◆ get_uri()
auto le::FileDataLoader::get_uri |
( |
std::string_view |
path | ) |
const -> std::string |
- Parameters
-
- Returns
- URI corresponding to path, if within root dir.
◆ save_bytes()
auto le::FileDataLoader::save_bytes |
( |
std::span< std::byte const > |
bytes, |
|
|
std::string_view |
uri |
|
) |
| const -> bool |
- Parameters
-
bytes | Bytes to save to file. |
uri | URI to save file at. |
◆ save_string()
auto le::FileDataLoader::save_string |
( |
std::string_view |
text, |
|
|
std::string_view |
uri |
|
) |
| const -> bool |
- Parameters
-
text | Text to save to file. |
uri | URI to save file at. |
◆ set_root_dir()
auto le::FileDataLoader::set_root_dir |
( |
std::string_view |
root_dir | ) |
-> bool |
- Parameters
-
root_dir | Mount point. Will be prefixed to URIs for loads. |
- Returns
- true if successfully mounted.
◆ try_load_bytes()
auto le::FileDataLoader::try_load_bytes |
( |
std::vector< std::byte > & |
out, |
|
|
std::string_view |
uri |
|
) |
| const -> bool |
|
finalvirtual |
- Parameters
-
out | Destination buffer. |
uri | URI to load from. |
- Returns
- true if successfully loaded.
Implements le::IDataLoader.
◆ try_load_spirv()
auto le::FileDataLoader::try_load_spirv |
( |
std::vector< std::uint32_t > & |
out, |
|
|
std::string_view |
uri |
|
) |
| const -> bool |
|
finalvirtual |
- Parameters
-
out | Destination buffer. |
uri | URI to load from. |
- Returns
- true if successfully loaded.
Implements le::IDataLoader.
◆ try_load_string()
auto le::FileDataLoader::try_load_string |
( |
std::string & |
out, |
|
|
std::string_view |
uri |
|
) |
| const -> bool |
|
finalvirtual |
- Parameters
-
out | Destination buffer. |
uri | URI to load from. |
- Returns
- true if successfully loaded.
Implements le::IDataLoader.
◆ upfind()
static auto le::FileDataLoader::upfind |
( |
std::string_view |
suffix, |
|
|
std::string_view |
leaf_dir = "." |
|
) |
| -> std::string |
|
static |
Locate a directory by cycling upwards every iteration.
- Parameters
-
suffix | Pattern to search for (eg "assets" or "resources/data"). |
leaf_dir | Starting directory (usually working dir or exe dir). |
The documentation for this class was generated from the following file: