Porytiles
Loading...
Searching...
No Matches
header_define_provider.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <filesystem>
4#include <memory>
5#include <optional>
6#include <string>
7
8#include "gsl/pointers"
9
14
15namespace porytiles {
16
17// NOTE: DO NOT EDIT THIS FILE DIRECTLY. It is AUTO-GENERATED from config_schema.yaml.
18// To add new config values or make other changes, edit config_schema.yaml and regenerate via:
19//
20// uv run scripts/generate_config.py
21
38 public:
49 std::filesystem::path project_root,
50 std::filesystem::path header_relative_path,
51 gsl::not_null<const TextFormatter *> format)
52 : format_{format}, project_root_{std::move(project_root)},
53 header_relative_path_{std::move(header_relative_path)}
54 {
55 // CParserFacade is lazily initialized on first define lookup
56 }
57
67 explicit HeaderDefineProvider(std::filesystem::path project_root, std::filesystem::path header_relative_path)
68 : owned_format_{std::make_unique<PlainTextFormatter>()}, format_{owned_format_.get()},
69 project_root_{std::move(project_root)}, header_relative_path_{std::move(header_relative_path)}
70 {
71 // CParserFacade is lazily initialized on first define lookup
72 }
73
77 [[nodiscard]] std::string name() const override;
78
79 [[nodiscard]] LayerValue<std::size_t>
80 num_tiles_in_primary(ConfigScopeType type, const std::string &scope) const override;
81
82 [[nodiscard]] LayerValue<std::size_t>
83 num_tiles_total(ConfigScopeType type, const std::string &scope) const override;
84
85 [[nodiscard]] LayerValue<std::size_t>
86 num_metatiles_in_primary(ConfigScopeType type, const std::string &scope) const override;
87
88 [[nodiscard]] LayerValue<std::size_t>
89 num_metatiles_total(ConfigScopeType type, const std::string &scope) const override;
90
91 [[nodiscard]] LayerValue<std::size_t>
92 num_palettes_in_primary(ConfigScopeType type, const std::string &scope) const override;
93
94 [[nodiscard]] LayerValue<std::size_t>
95 num_palettes_total(ConfigScopeType type, const std::string &scope) const override;
96
97 [[nodiscard]] LayerValue<std::size_t>
98 max_map_data_size(ConfigScopeType type, const std::string &scope) const override;
99
100 [[nodiscard]] LayerValue<std::size_t>
101 num_tiles_per_metatile(ConfigScopeType type, const std::string &scope) const override;
102
103 private:
104 std::unique_ptr<TextFormatter> owned_format_; // Optional owned formatter (when using default ctor)
105 const TextFormatter *format_; // Non-owning pointer to formatter
106 std::filesystem::path project_root_;
107 std::filesystem::path header_relative_path_;
108 mutable std::optional<CParserFacade> parser_driver_; // Lazy-initialized C parser
109};
110
111} // namespace porytiles
An interface which config implementations can use to load config values.
A ConfigProvider implementation that reads configuration values from #define directives in a header f...
LayerValue< std::size_t > num_palettes_in_primary(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::size_t > num_tiles_in_primary(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::size_t > num_metatiles_in_primary(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::size_t > num_palettes_total(ConfigScopeType type, const std::string &scope) const override
HeaderDefineProvider(std::filesystem::path project_root, std::filesystem::path header_relative_path)
Constructs a HeaderDefineProvider with a default PlainTextFormatter.
HeaderDefineProvider(std::filesystem::path project_root, std::filesystem::path header_relative_path, gsl::not_null< const TextFormatter * > format)
Constructs a HeaderDefineProvider that reads #define values from a header file.
LayerValue< std::size_t > num_metatiles_total(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::size_t > num_tiles_total(ConfigScopeType type, const std::string &scope) const override
std::string name() const override
Gets the name of this config layer.
LayerValue< std::size_t > num_tiles_per_metatile(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::size_t > max_map_data_size(ConfigScopeType type, const std::string &scope) const override
TextFormatter implementation that strips all styling from text.
Abstract base class for applying text styling with context-aware formatting.
ConfigScopeType
Specifies the scope type for configuration value lookups.
A small container that holds an optional-wrapped value, validation state, and metadata about the valu...