|
Porytiles
|
A service that loads metatile attributes from a CSV file. More...
#include <attributes_csv_loader.hpp>
Public Member Functions | |
| AttributesCsvLoader (gsl::not_null< const TextFormatter * > format, gsl::not_null< const InfraConfig * > config, gsl::not_null< const UserDiagnostics * > diag) | |
| Constructs an AttributesCsvLoader with required dependencies. | |
| ChainableResult< AttributesCsvLoadResult > | load (const std::filesystem::path &path, const Schema &schema, const ProviderMap &providers, const std::string &tileset_name) const |
| Loads metatile attributes from a CSV file. | |
A service that loads metatile attributes from a CSV file.
AttributesCsvLoader parses the Porytiles attributes CSV format, whose columns come from the resolved metatile attribute schema: the header is id followed by every schema field name in schema order. A provider-backed field's cells hold value constant names resolved through the field's provider; a raw field's cells hold plain unsigned integers capped at the field's maximum value. For the stock emerald schema this is:
The header row is cross-checked against the resolved schema, so a CSV written for a different schema fails with a diagnostic naming the offending column. Rich error messages with file context highlighting are produced via FileHighlightPrinter.
Definition at line 51 of file attributes_csv_loader.hpp.
|
inline |
Constructs an AttributesCsvLoader with required dependencies.
| format | The text formatter for styled output |
| config | A pointer to the InfraConfig for the loader |
| diag | A pointer to the UserDiagnostics for the loader |
Definition at line 58 of file attributes_csv_loader.hpp.
| ChainableResult< AttributesCsvLoadResult > porytiles::AttributesCsvLoader::load | ( | const std::filesystem::path & | path, |
| const Schema & | schema, | ||
| const ProviderMap & | providers, | ||
| const std::string & | tileset_name | ||
| ) | const |
Loads metatile attributes from a CSV file.
Parses the CSV file, validates the header row against the given schema, resolves each field cell (constant names through the field's provider, integers for raw fields), and returns a map of metatile ID to MetatileAttribute. All attributes are created with LayerType::normal.
The schema and providers must belong to the tileset that owns the CSV: when compiling a secondary, the paired primary's CSV parses against the primary's own resolved schema, which can differ from the secondary's. A provider-backed field missing from the ProviderMap is an internal invariant violation and panics.
| path | The path to the attributes CSV file |
| schema | The owning tileset's resolved attribute schema the CSV columns are validated and parsed against |
| providers | The provider map holding one provider per provider-backed schema field |
| tileset_name | The tileset whose config scope resolves the role_pins. When compiling a secondary this is the primary's name for the primary's CSV, so the config resolves under the file's owning tileset. |
Definition at line 470 of file attributes_csv_loader.cpp.