|
dasmig-core 1.2.0
Shared random engine, distributions and data tiers for the dasmig generator libraries
|
Finding a library's data: compiled-in files, or a resources/ directory found on disk.
More...
#include "dataset.hpp"#include "tsv.hpp"#include <cstddef>#include <filesystem>#include <optional>#include <span>#include <string>#include <string_view>#include <system_error>#include <utility>#include <vector>Go to the source code of this file.
Classes | |
| struct | dasmig::core::embedded_file |
| A data file compiled into the program. More... | |
Functions | |
| constexpr std::string_view | dasmig::core::tier_name (dataset tier) noexcept |
| The directory name of a data tier. | |
| constexpr const embedded_file * | dasmig::core::find_embedded (std::span< const embedded_file > files, std::string_view path) noexcept |
| Find a compiled-in file by path. | |
| std::vector< std::filesystem::path > | dasmig::core::resource_candidates (std::string_view library, const std::filesystem::path &base=std::filesystem::current_path()) |
The directories searched for a library's resources/, in order. | |
| std::optional< std::filesystem::path > | dasmig::core::find_resources (std::string_view library, std::string_view marker, const std::filesystem::path &base=std::filesystem::current_path()) |
| The first candidate directory that contains a marker file. | |
| std::optional< tsv_document > | dasmig::core::load_resource (std::string_view path, std::span< const embedded_file > embedded, const std::optional< std::filesystem::path > &root, std::vector< std::string > columns={}) |
| Load a data file, compiled-in if available, otherwise from disk. | |
Finding a library's data: compiled-in files, or a resources/ directory found on disk.
Definition in file resources.hpp.
|
constexprnoexcept |
Find a compiled-in file by path.
| files | The embedded files (empty when none are compiled in). |
| path | Path below resources/, with / separators. |
Definition at line 64 of file resources.hpp.
|
inline |
The first candidate directory that contains a marker file.
The marker tells a library's resources/ apart from another library's (for example lite/biodata.tsv).
| library | Repository name, e.g. biodata-generator. |
| marker | A file path below resources/ that the library ships. |
| base | Directory to search from (default: the working directory). |
resources/ directory, or empty when none is found. Definition at line 103 of file resources.hpp.
|
inline |
Load a data file, compiled-in if available, otherwise from disk.
Embedded files win, so a build with compiled-in data never depends on the working directory. The two give the same tsv_document::content_hash(), so seeds replay the same either way.
| path | Path below resources/, e.g. lite/biodata.tsv. |
| embedded | Compiled-in files (empty when none). |
| root | A resources/ directory (from find_resources()), or empty. |
| columns | Column names for a headerless file; empty when the first line names them. |
root. | tsv_error | If the file exists but cannot be parsed. |
Definition at line 129 of file resources.hpp.
|
inline |
The directories searched for a library's resources/, in order.
Relative to base: resources, ../resources, <library>/resources and ../<library>/resources. These cover running from the repository, from its build directory, and from a parent directory holding several libraries side by side.
| library | Repository name, e.g. biodata-generator. |
| base | Directory to search from (default: the working directory). |
Definition at line 84 of file resources.hpp.
|
constexprnoexcept |
The directory name of a data tier.
| tier | The tier. |
"lite" or "full". Definition at line 31 of file resources.hpp.