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_palettes_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
 
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
 
- Public Member Functions inherited from porytiles::ConfigProvider
virtual ~ConfigProvider ()=default
 
virtual LayerValue< Rgba32extrinsic_transparency (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< bool > ignore_triple_layer_content (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< ArtifactEditModetiles_edit_mode (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< ArtifactEditModepalettes_edit_mode (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< bool > palette_hints_enabled (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< std::vector< PaletteHint > > palette_hints (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< PackingStrategyTypepacking_strategy (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< PackingStrategyParamspacking_strategy_params (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< TileSharingPackingtile_sharing_packing (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< TileSharingAlignmenttile_sharing_alignment (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< TilesPaletteModetiles_palette_mode (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< AnimPaletteResolutionStrategyglobal_anim_palette_resolution_strategy (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< AnimKeyFrameResolutionStrategyglobal_anim_key_frame_resolution_strategy (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< AnimMultiPaletteSubtileResolutionStrategyglobal_anim_multi_palette_subtile_resolution_strategy (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< FrameLinkingglobal_frame_linking (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< PerAnimOverridesper_anim_overrides (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< bool > cross_tileset_anim_linking (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< bool > verify_checksums (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< PrimaryPairingModeprimary_pairing_mode (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< std::vector< std::string > > primary_pairing_partners (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< std::vector< std::string > > diagnostic_warnings_exclude (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< std::vector< std::string > > diagnostic_warnings_include (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< std::vector< std::string > > diagnostic_remarks_exclude (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< std::vector< std::string > > diagnostic_remarks_include (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< std::string > tileset_paths_primary_src (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< std::string > tileset_paths_primary_bin (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< std::string > tileset_paths_secondary_src (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< std::string > tileset_paths_secondary_bin (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< std::optional< std::size_t > > metatile_attribute_size (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< std::optional< std::size_t > > metatile_attribute_declaration_size (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< MetatileAttributeFieldDefinitionsmetatile_attribute_fields (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< MetatileAttributeFieldOverridesmetatile_attribute_field_overrides (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< RolePinDefinitionsrole_pins (ConfigScopeType type, const std::string &scope) const
 
virtual LayerValue< bool > tileset_animations_wire_anim_code (ConfigScopeType type, const std::string &scope) const
 

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. Config values with no associated header define are not overridden here at all; they defer via the ConfigProvider base class default.

Definition at line 37 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 48 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 67 of file header_define_provider.hpp.

Member Function Documentation

◆ 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 94 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 16 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 44 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 58 of file header_define_provider.cpp.

◆ num_palettes_in_primary()

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

Reimplemented from porytiles::ConfigProvider.

Definition at line 72 of file header_define_provider.cpp.

◆ num_palettes_total()

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

Reimplemented from porytiles::ConfigProvider.

Definition at line 86 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 22 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 108 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.


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