Porytiles
Loading...
Searching...
No Matches
porytiles::HeaderDefineProvider Class Referencefinal

A ConfigProvider implementation that reads configuration values from #define directives in a header file. More...

#include <header_define_provider.hpp>

Inheritance diagram for porytiles::HeaderDefineProvider:
[legend]
Collaboration diagram for porytiles::HeaderDefineProvider:
[legend]

Public Member Functions

 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.
 
 HeaderDefineProvider (std::filesystem::path project_root, std::filesystem::path header_relative_path)
 Constructs a HeaderDefineProvider with a default PlainTextFormatter.
 
std::string name () const override
 Gets the name of this config layer.
 
LayerValue< std::size_t > num_tiles_in_primary (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::size_t > num_tiles_total (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_metatiles_total (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::size_t > num_pals_in_primary (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::size_t > num_pals_total (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::size_t > max_map_data_size (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::size_t > num_tiles_per_metatile (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< Rgba32extrinsic_transparency (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< ArtifactEditModetiles_edit_mode (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< ArtifactEditModepals_edit_mode (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< bool > pal_hints_enabled (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::vector< PaletteHint > > pal_hints (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< PackingStrategyTypepacking_strategy (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< PackingStrategyParamspacking_strategy_params (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< TileSharingPackingtile_sharing_packing (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< TileSharingAlignmenttile_sharing_alignment (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< TilesPalModetiles_pal_mode (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< AnimPalResolutionStrategyglobal_anim_pal_resolution_strategy (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< AnimKeyFrameResolutionStrategyglobal_anim_key_frame_resolution_strategy (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< AnimMultiPalSubtileResolutionStrategyglobal_anim_multi_pal_subtile_resolution_strategy (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< FrameLinkingglobal_frame_linking (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< PerAnimOverridesper_anim_overrides (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< bool > cross_tileset_anim_linking (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< bool > verify_checksums (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< PrimaryPairingModeprimary_pairing_mode (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::vector< std::string > > primary_pairing_partners (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::vector< std::string > > diagnostic_warnings_exclude (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::vector< std::string > > diagnostic_warnings_include (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::vector< std::string > > diagnostic_remarks_exclude (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::vector< std::string > > diagnostic_remarks_include (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::string > tileset_paths_primary_src (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::string > tileset_paths_primary_bin (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::string > tileset_paths_secondary_src (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::string > tileset_paths_secondary_bin (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< std::size_t > metatile_attr_size (ConfigScopeType type, const std::string &scope) const override
 
LayerValue< bool > tileset_animations_wire_anim_code (ConfigScopeType type, const std::string &scope) const override
 
- Public Member Functions inherited from porytiles::ConfigProvider
virtual ~ConfigProvider ()=default
 

Detailed Description

A ConfigProvider implementation that reads configuration values from #define directives in a header file.

HeaderDefineProvider parses a C/C++ header file looking for #define directives that correspond to configuration values. This is useful for reading configuration from decompilation project headers like include/fieldmap.h.

The provider uses a full C parser that supports:

  • Simple integer literals: #define NUM_TILES 512
  • Hexadecimal, octal, and binary literals: #define FLAGS 0xFF
  • Arithmetic expressions: #define SIZE (1 << 10)
  • Macro references: #define TOTAL (PRIMARY + SECONDARY)

The header file is loaded lazily and cached for performance. If the file doesn't exist or a define is not found, methods return LayerValue::not_provided(), allowing graceful fallback to other providers.

Definition at line 40 of file header_define_provider.hpp.

Constructor & Destructor Documentation

◆ HeaderDefineProvider() [1/2]

porytiles::HeaderDefineProvider::HeaderDefineProvider ( std::filesystem::path  project_root,
std::filesystem::path  header_relative_path,
gsl::not_null< const TextFormatter * >  format 
)
inlineexplicit

Constructs a HeaderDefineProvider that reads #define values from a header file.

This constructor sets up the provider to read configuration values from #define directives in the specified header file. The header file is loaded lazily when first accessed and cached for subsequent lookups.

Parameters
header_relative_pathThe path to the header file relative to project_root
formatA pointer to the TextFormatter to use
project_rootThe root directory of the project

Definition at line 53 of file header_define_provider.hpp.

◆ HeaderDefineProvider() [2/2]

porytiles::HeaderDefineProvider::HeaderDefineProvider ( std::filesystem::path  project_root,
std::filesystem::path  header_relative_path 
)
inlineexplicit

Constructs a HeaderDefineProvider with a default PlainTextFormatter.

This constructor creates an internally owned PlainTextFormatter instance and uses it for formatting. The HeaderDefineProvider will read configuration values from #define directives in the specified header file. The header file is loaded lazily when first accessed and cached for subsequent lookups.

Parameters
project_rootThe root directory of the project
header_relative_pathThe path to the header file relative to project_root

Definition at line 74 of file header_define_provider.hpp.

Member Function Documentation

◆ cross_tileset_anim_linking()

LayerValue< bool > porytiles::HeaderDefineProvider::cross_tileset_anim_linking ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 217 of file header_define_provider.cpp.

◆ diagnostic_remarks_exclude()

LayerValue< std::vector< std::string > > porytiles::HeaderDefineProvider::diagnostic_remarks_exclude ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 253 of file header_define_provider.cpp.

◆ diagnostic_remarks_include()

LayerValue< std::vector< std::string > > porytiles::HeaderDefineProvider::diagnostic_remarks_include ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 259 of file header_define_provider.cpp.

◆ diagnostic_warnings_exclude()

LayerValue< std::vector< std::string > > porytiles::HeaderDefineProvider::diagnostic_warnings_exclude ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 241 of file header_define_provider.cpp.

◆ diagnostic_warnings_include()

LayerValue< std::vector< std::string > > porytiles::HeaderDefineProvider::diagnostic_warnings_include ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 247 of file header_define_provider.cpp.

◆ extrinsic_transparency()

LayerValue< Rgba32 > porytiles::HeaderDefineProvider::extrinsic_transparency ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 127 of file header_define_provider.cpp.

◆ global_anim_key_frame_resolution_strategy()

LayerValue< AnimKeyFrameResolutionStrategy > porytiles::HeaderDefineProvider::global_anim_key_frame_resolution_strategy ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 193 of file header_define_provider.cpp.

◆ global_anim_multi_pal_subtile_resolution_strategy()

LayerValue< AnimMultiPalSubtileResolutionStrategy > porytiles::HeaderDefineProvider::global_anim_multi_pal_subtile_resolution_strategy ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 199 of file header_define_provider.cpp.

◆ global_anim_pal_resolution_strategy()

LayerValue< AnimPalResolutionStrategy > porytiles::HeaderDefineProvider::global_anim_pal_resolution_strategy ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 187 of file header_define_provider.cpp.

◆ global_frame_linking()

LayerValue< FrameLinking > porytiles::HeaderDefineProvider::global_frame_linking ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 205 of file header_define_provider.cpp.

◆ max_map_data_size()

LayerValue< std::size_t > porytiles::HeaderDefineProvider::max_map_data_size ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 101 of file header_define_provider.cpp.

◆ metatile_attr_size()

LayerValue< std::size_t > porytiles::HeaderDefineProvider::metatile_attr_size ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 289 of file header_define_provider.cpp.

◆ name()

std::string porytiles::HeaderDefineProvider::name ( ) const
overridevirtual

Gets the name of this config layer.

Returns
The name "HeaderDefineProvider"

Implements porytiles::ConfigProvider.

Definition at line 18 of file header_define_provider.cpp.

◆ num_metatiles_in_primary()

LayerValue< std::size_t > porytiles::HeaderDefineProvider::num_metatiles_in_primary ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 49 of file header_define_provider.cpp.

◆ num_metatiles_total()

LayerValue< std::size_t > porytiles::HeaderDefineProvider::num_metatiles_total ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 62 of file header_define_provider.cpp.

◆ num_pals_in_primary()

LayerValue< std::size_t > porytiles::HeaderDefineProvider::num_pals_in_primary ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 75 of file header_define_provider.cpp.

◆ num_pals_total()

LayerValue< std::size_t > porytiles::HeaderDefineProvider::num_pals_total ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 88 of file header_define_provider.cpp.

◆ num_tiles_in_primary()

LayerValue< std::size_t > porytiles::HeaderDefineProvider::num_tiles_in_primary ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 23 of file header_define_provider.cpp.

◆ num_tiles_per_metatile()

LayerValue< std::size_t > porytiles::HeaderDefineProvider::num_tiles_per_metatile ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 114 of file header_define_provider.cpp.

◆ num_tiles_total()

LayerValue< std::size_t > porytiles::HeaderDefineProvider::num_tiles_total ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 36 of file header_define_provider.cpp.

◆ packing_strategy()

LayerValue< PackingStrategyType > porytiles::HeaderDefineProvider::packing_strategy ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 157 of file header_define_provider.cpp.

◆ packing_strategy_params()

LayerValue< PackingStrategyParams > porytiles::HeaderDefineProvider::packing_strategy_params ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 163 of file header_define_provider.cpp.

◆ pal_hints()

LayerValue< std::vector< PaletteHint > > porytiles::HeaderDefineProvider::pal_hints ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 151 of file header_define_provider.cpp.

◆ pal_hints_enabled()

LayerValue< bool > porytiles::HeaderDefineProvider::pal_hints_enabled ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 145 of file header_define_provider.cpp.

◆ pals_edit_mode()

LayerValue< ArtifactEditMode > porytiles::HeaderDefineProvider::pals_edit_mode ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 139 of file header_define_provider.cpp.

◆ per_anim_overrides()

LayerValue< PerAnimOverrides > porytiles::HeaderDefineProvider::per_anim_overrides ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 211 of file header_define_provider.cpp.

◆ primary_pairing_mode()

LayerValue< PrimaryPairingMode > porytiles::HeaderDefineProvider::primary_pairing_mode ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 229 of file header_define_provider.cpp.

◆ primary_pairing_partners()

LayerValue< std::vector< std::string > > porytiles::HeaderDefineProvider::primary_pairing_partners ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 235 of file header_define_provider.cpp.

◆ tile_sharing_alignment()

LayerValue< TileSharingAlignment > porytiles::HeaderDefineProvider::tile_sharing_alignment ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 175 of file header_define_provider.cpp.

◆ tile_sharing_packing()

LayerValue< TileSharingPacking > porytiles::HeaderDefineProvider::tile_sharing_packing ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 169 of file header_define_provider.cpp.

◆ tiles_edit_mode()

LayerValue< ArtifactEditMode > porytiles::HeaderDefineProvider::tiles_edit_mode ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 133 of file header_define_provider.cpp.

◆ tiles_pal_mode()

LayerValue< TilesPalMode > porytiles::HeaderDefineProvider::tiles_pal_mode ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 181 of file header_define_provider.cpp.

◆ tileset_animations_wire_anim_code()

LayerValue< bool > porytiles::HeaderDefineProvider::tileset_animations_wire_anim_code ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 295 of file header_define_provider.cpp.

◆ tileset_paths_primary_bin()

LayerValue< std::string > porytiles::HeaderDefineProvider::tileset_paths_primary_bin ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 271 of file header_define_provider.cpp.

◆ tileset_paths_primary_src()

LayerValue< std::string > porytiles::HeaderDefineProvider::tileset_paths_primary_src ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 265 of file header_define_provider.cpp.

◆ tileset_paths_secondary_bin()

LayerValue< std::string > porytiles::HeaderDefineProvider::tileset_paths_secondary_bin ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 283 of file header_define_provider.cpp.

◆ tileset_paths_secondary_src()

LayerValue< std::string > porytiles::HeaderDefineProvider::tileset_paths_secondary_src ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 277 of file header_define_provider.cpp.

◆ verify_checksums()

LayerValue< bool > porytiles::HeaderDefineProvider::verify_checksums ( ConfigScopeType  type,
const std::string &  scope 
) const
overridevirtual

Reimplemented from porytiles::ConfigProvider.

Definition at line 223 of file header_define_provider.cpp.


The documentation for this class was generated from the following files: