|
| static void | init_builtins () |
| | Explicitly initializes builtin entries.
|
| |
| static std::vector< std::string > | get_str () |
| | Returns the list of builtin string names from MapFn().
|
| |
| static std::vector< EnumT > | get_enum () |
| | Returns the list of builtin enum values.
|
| |
| static std::vector< std::string > | get_str_all () |
| | Returns all known names (builtin + custom).
|
| |
| static EnumT | enum_elt_legacy (std::string_view s) |
| | Legacy enum lookup using only the static MapFn() table.
|
| |
| static IdOf< Tag > | id_of (std::string_view s) |
| | Resolves a string into an IdOf<Tag> via the registry.
|
| |
| static IdOf< Tag > | enum_elt (std::string_view s) |
| | Alias for id_of(), kept for compatibility.
|
| |
| static std::optional< IdOf< Tag > > | from_external (const ExternalKey &k) |
| | Resolves an external key into an identifier.
|
| |
| static std::optional< ExternalKey > | external_of (const IdOf< Tag > &id) |
| | Returns the external key associated with a given identifier.
|
| |
| static bool | register_custom (std::string canonical, std::vector< std::string > aliases={}, std::optional< ExternalKey > ext=std::nullopt) |
| | Registers a custom entry with optional external key.
|
| |
| static bool | set_external (const IdOf< Tag > &id, const ExternalKey &k) |
| | Sets or updates the external key of an existing identifier.
|
| |
| static std::vector< IdOf< Tag > > | list_all () |
| | Lists all distinct identifiers currently registered.
|
| |
| static std::string | str (const IdOf< Tag > &id) |
| | Returns the string representation of an identifier.
|
| |
| static std::string | str (EnumT e) |
| | Returns the builtin string name of an enum value.
|
| |
| static IdOf< Tag > | to_id (EnumT e) |
| | Converts an enum value to an IdOf<Tag>.
|
| |
| static std::optional< EnumT > | enum_of (const IdOf< Tag > &id) |
| | Attempts to recover the enum value associated with an identifier.
|
| |
template<class Tag, class EnumT, class ExternalKey, class Hash, const std::map< EnumT, std::string > &(*)() MapFn, const std::map< EnumT, ExternalKey > &(*)() ExtFn>
class GenericMapperWithExt< Tag, EnumT, ExternalKey, Hash, MapFn, ExtFn >
Generic enum↔string mapper with external keys and dynamic aliases.
This template extends GenericMapperNoExt by adding support for an "external key" (ExternalKey), which can be used to represent e.g. FLHA indices, integer codes, or other external identifiers.
Initialization:
- Builtin entries are created from the map returned by MapFn() and the external-key map returned by ExtFn().
- Each EnumT value is mapped to a canonical name and optionally to an external key, stored in a DynamicRegistry<Tag,ExternalKey,Hash>.
Features:
- Bidirectional mapping between EnumT and IdOf<Tag>.
- Bidirectional mapping between external keys and IdOf<Tag>.
- Case-insensitive lookup and dynamic alias registration.
- Template Parameters
-
| Tag | Tag used for SymbolId<Tag>. |
| EnumT | Enum type to map. |
| ExternalKey | Type for the external key. |
| Hash | Hash functor for ExternalKey in unordered_map. |
| MapFn | Function returning builtin EnumT→std::string map. |
| ExtFn | Function returning EnumT→ExternalKey map. |
Definition at line 272 of file generic_mapper.h.
template<class Tag , class EnumT , class ExternalKey , class Hash , const std::map< EnumT, std::string > &(*)() MapFn, const std::map< EnumT, ExternalKey > &(*)() ExtFn>
| static EnumT GenericMapperWithExt< Tag, EnumT, ExternalKey, Hash, MapFn, ExtFn >::enum_elt_legacy |
( |
std::string_view |
s | ) |
|
|
static |
Legacy enum lookup using only the static MapFn() table.
As in GenericMapperNoExt::enum_elt_legacy, this scans the static map and ignores custom registrations and external keys.
- Parameters
-
| s | Name to look up (case-insensitive). |
- Returns
- Matching EnumT value.
- Exceptions
-
| std::out_of_range | if no match is found. |
template<class Tag , class EnumT , class ExternalKey , class Hash , const std::map< EnumT, std::string > &(*)() MapFn, const std::map< EnumT, ExternalKey > &(*)() ExtFn>
| static std::optional< EnumT > GenericMapperWithExt< Tag, EnumT, ExternalKey, Hash, MapFn, ExtFn >::enum_of |
( |
const IdOf< Tag > & |
id | ) |
|
|
static |
Attempts to recover the enum value associated with an identifier.
The identifier’s string is normalized and compared against the builtin names in MapFn(). This does not consult the dynamic registry, so only builtin names are considered.
- Parameters
-
- Returns
- Matching EnumT if found, std::nullopt otherwise.
template<class Tag , class EnumT , class ExternalKey , class Hash , const std::map< EnumT, std::string > &(*)() MapFn, const std::map< EnumT, ExternalKey > &(*)() ExtFn>
| static std::optional< IdOf< Tag > > GenericMapperWithExt< Tag, EnumT, ExternalKey, Hash, MapFn, ExtFn >::from_external |
( |
const ExternalKey & |
k | ) |
|
|
static |
Resolves an external key into an identifier.
Uses the registry's external-key index to find the canonical identifier associated with k.
- Parameters
-
| k | External key to look up. |
- Returns
- Matching IdOf<Tag>, or std::nullopt if none.
template<class Tag , class EnumT , class ExternalKey , class Hash , const std::map< EnumT, std::string > &(*)() MapFn, const std::map< EnumT, ExternalKey > &(*)() ExtFn>
| static std::vector< std::string > GenericMapperWithExt< Tag, EnumT, ExternalKey, Hash, MapFn, ExtFn >::get_str |
( |
| ) |
|
|
static |
Returns the list of builtin string names from MapFn().
Only the static mapping is consulted; dynamic/custom entries are not included.
- Returns
- Vector of builtin names.
template<class Tag , class EnumT , class ExternalKey , class Hash , const std::map< EnumT, std::string > &(*)() MapFn, const std::map< EnumT, ExternalKey > &(*)() ExtFn>
| static std::vector< std::string > GenericMapperWithExt< Tag, EnumT, ExternalKey, Hash, MapFn, ExtFn >::get_str_all |
( |
| ) |
|
|
static |
Returns all known names (builtin + custom).
This triggers initialization and then enumerates the registry to collect all identifier strings.
- Returns
- Vector of all identifier names.
template<class Tag , class EnumT , class ExternalKey , class Hash , const std::map< EnumT, std::string > &(*)() MapFn, const std::map< EnumT, ExternalKey > &(*)() ExtFn>
Resolves a string into an IdOf<Tag> via the registry.
The lookup is case-insensitive and takes into account builtin and custom aliases.
- Parameters
-
- Returns
- Corresponding IdOf<Tag>.
- Exceptions
-
| std::runtime_error | if the name is unknown. |
template<class Tag , class EnumT , class ExternalKey , class Hash , const std::map< EnumT, std::string > &(*)() MapFn, const std::map< EnumT, ExternalKey > &(*)() ExtFn>
Explicitly initializes builtin entries.
Populates the registry from the static maps provided by MapFn() and ExtFn() if not already initialized.
template<class Tag , class EnumT , class ExternalKey , class Hash , const std::map< EnumT, std::string > &(*)() MapFn, const std::map< EnumT, ExternalKey > &(*)() ExtFn>
Lists all distinct identifiers currently registered.
Includes both builtin and custom entries; each canonical id is returned once, regardless of the number of aliases.
- Returns
- Vector of IdOf<Tag>.
template<class Tag , class EnumT , class ExternalKey , class Hash , const std::map< EnumT, std::string > &(*)() MapFn, const std::map< EnumT, ExternalKey > &(*)() ExtFn>
| static bool GenericMapperWithExt< Tag, EnumT, ExternalKey, Hash, MapFn, ExtFn >::register_custom |
( |
std::string |
canonical, |
|
|
std::vector< std::string > |
aliases = {}, |
|
|
std::optional< ExternalKey > |
ext = std::nullopt |
|
) |
| |
|
static |
Registers a custom entry with optional external key.
Similar to register_custom() in GenericMapperNoExt, but also allows attaching an external key that participates in from_external()/external_of() mappings.
- Parameters
-
| canonical | Canonical name for the identifier. |
| aliases | Optional aliases for lookup. |
| ext | Optional external key to associate. |
- Returns
- true if registration succeeded, false if blocked by an existing builtin entry.
template<class Tag , class EnumT , class ExternalKey , class Hash , const std::map< EnumT, std::string > &(*)() MapFn, const std::map< EnumT, ExternalKey > &(*)() ExtFn>
| static bool GenericMapperWithExt< Tag, EnumT, ExternalKey, Hash, MapFn, ExtFn >::set_external |
( |
const IdOf< Tag > & |
id, |
|
|
const ExternalKey & |
k |
|
) |
| |
|
static |
Sets or updates the external key of an existing identifier.
If the identifier exists in the registry, its external key is set to k and the external-key index updated accordingly.
- Parameters
-
| id | Identifier whose external key should be set. |
| k | New external key value. |
- Returns
- true if the identifier was found and updated, false otherwise.
template<class Tag , class EnumT , class ExternalKey , class Hash , const std::map< EnumT, std::string > &(*)() MapFn, const std::map< EnumT, ExternalKey > &(*)() ExtFn>
Returns the string representation of an identifier.
This simply returns id.str().
- Parameters
-
- Returns
- String representation of
id.
template<class Tag , class EnumT , class ExternalKey , class Hash , const std::map< EnumT, std::string > &(*)() MapFn, const std::map< EnumT, ExternalKey > &(*)() ExtFn>
Converts an enum value to an IdOf<Tag>.
The identifier wraps the builtin string returned by MapFn().at(e).
- Parameters
-
- Returns
- Corresponding IdOf<Tag>.