|
Porytiles
|
Loads a field's name/value mappings from a C/C++ header used by a decomp project. More...
#include <header_enum_map_provider.hpp>
Public Member Functions | |
| HeaderEnumMapProvider (std::filesystem::path header_path, EnumDefinition definition, gsl::not_null< const TextFormatter * > format, gsl::not_null< const UserDiagnostics * > diag) | |
| Constructs a provider that will load from the specified header file. | |
| ChainableResult< std::uint32_t > | lookup (const std::string &name) const override |
| Looks up the numeric value for a constant name. | |
| ChainableResult< std::string > | lookup (std::uint32_t value) const override |
| Looks up the constant name for a numeric value. | |
Public Member Functions inherited from porytiles::EnumMapProvider | |
| virtual | ~EnumMapProvider ()=default |
Loads a field's name/value mappings from a C/C++ header used by a decomp project.
One provider serves one field. What field it serves, which header it reads, the shared name prefix, the names to skip, and the acceptable declaration styles all come from the EnumDefinition passed at construction, so a single class covers behavior, terrain, encounter, and any future field. Two declaration styles are understood:
Define format:
Enum format:
In the enum format, values are assigned sequentially starting from 0. Both formats support decimal and hexadecimal values (for define format). The EnumDefinition's HeaderFormat selects which styles are read: defines only, enums only, or either (defines first, then enums). During the scan, names that lack the definition's prefix, names in the definition's skip set, and values that exceed the field's maximum are silently ignored, so an unrelated or over-wide constant in a shared header is simply not a mapping. The provider loads lazily on first lookup and caches the result.
Definition at line 46 of file header_enum_map_provider.hpp.
|
inline |
Constructs a provider that will load from the specified header file.
The provider reads mappings from the given header lazily when first accessed via lookup(), then caches them for subsequent lookups. The EnumDefinition fully determines what is scanned and how.
| header_path | The path to the header declaring this field's value names |
| definition | The resolved description of the field's prefix, cap, skip set, format, and display name |
| format | The text formatter for styled output |
| diag | The user diagnostics for error reporting |
Definition at line 58 of file header_enum_map_provider.hpp.
|
overridevirtual |
Looks up the numeric value for a constant name.
| name | The value constant name (e.g. "MB_NORMAL") |
Implements porytiles::EnumMapProvider.
Definition at line 167 of file header_enum_map_provider.cpp.
|
overridevirtual |
Looks up the constant name for a numeric value.
| value | The numeric value |
Implements porytiles::EnumMapProvider.
Definition at line 196 of file header_enum_map_provider.cpp.