|
Porytiles
|
Abstract interface for providing two-way name/value mappings for an enumerated attribute field. More...
#include <enum_map_provider.hpp>
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. | |
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.
|
virtualdefault |
|
pure virtual |
Looks up the numeric value for a constant name.
| name | The value constant name (e.g. "MB_NORMAL") |
Implemented in porytiles::HeaderEnumMapProvider.
|
pure virtual |
Looks up the constant name for a numeric value.
| value | The numeric value |
Implemented in porytiles::HeaderEnumMapProvider.