Porytiles
Loading...
Searching...
No Matches
porytiles::EnumMapProvider Class Referenceabstract

Abstract interface for providing two-way name/value mappings for an enumerated attribute field. More...

#include <enum_map_provider.hpp>

Inheritance diagram for porytiles::EnumMapProvider:
[legend]

Public Member Functions

virtual ~EnumMapProvider ()=default
 
virtual ChainableResult< std::uint32_t > lookup (const std::string &name) const =0
 Looks up the numeric value for a constant name.
 
virtual ChainableResult< std::string > lookup (std::uint32_t value) const =0
 Looks up the constant name for a numeric value.
 

Detailed Description

Abstract interface for providing two-way name/value mappings for an enumerated attribute field.

The base game names the values of a metatile attribute field (behavior constants, terrain types, encounter types, and so on) through C header constants. An EnumMapProvider maps those constant names (e.g. "MB_NORMAL", "TILE_TERRAIN_GRASS") to their numeric values and vice versa. A single field is one provider; the field a provider serves is a construction-time detail, not a compile-time type. Implementations may load these mappings from various sources such as header files or configuration, and loading and caching strategies are implementation details left to concrete implementations.

Values are widened to uint32_t so one interface serves every field regardless of its bit width. The two overloads stay unambiguous because there is no implicit conversion between a name string and an integer.

Definition at line 25 of file enum_map_provider.hpp.

Constructor & Destructor Documentation

◆ ~EnumMapProvider()

virtual porytiles::EnumMapProvider::~EnumMapProvider ( )
virtualdefault

Member Function Documentation

◆ lookup() [1/2]

virtual ChainableResult< std::uint32_t > porytiles::EnumMapProvider::lookup ( const std::string &  name) const
pure virtual

Looks up the numeric value for a constant name.

Parameters
nameThe value constant name (e.g. "MB_NORMAL")
Returns
The numeric value if found, or an error describing why the lookup failed

Implemented in porytiles::HeaderEnumMapProvider.

◆ lookup() [2/2]

virtual ChainableResult< std::string > porytiles::EnumMapProvider::lookup ( std::uint32_t  value) const
pure virtual

Looks up the constant name for a numeric value.

Parameters
valueThe numeric value
Returns
The constant name if found, or an error describing why the lookup failed

Implemented in porytiles::HeaderEnumMapProvider.


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