Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
generic_mapper.h File Reference

Generic enum↔string (and optional external key) mappers built on DynamicRegistry. More...

#include <map>
#include <optional>
#include <string_view>
#include <vector>
#include "dynamic_registry.h"
#include "Map.h"
#include "generic_mapper.tpp"
Include dependency graph for generic_mapper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  GenericMapperNoExt< Tag, EnumT, MapFn >
 Generic enum↔string mapper without external keys. More...
 
class  GenericMapperWithExt< Tag, EnumT, ExternalKey, Hash, MapFn, ExtFn >
 Generic enum↔string mapper with external keys and dynamic aliases. More...
 

Typedefs

template<class Tag >
using IdOf = SymbolId< Tag >
 Convenience alias for the identifier type associated with a given tag.
 

Functions

std::string nk (std::string_view s)
 Shortcut helper to normalize a string_view into a canonical key.
 

Detailed Description

Generic enum↔string (and optional external key) mappers built on DynamicRegistry.

This header provides two templated mapper classes:

  • GenericMapperNoExt: bridges an enum type and its string names, with support for dynamic aliases and user-defined symbols.
  • GenericMapperWithExt: extends the above with an additional "external key" (e.g. FLHA indices, integer codes, etc).

Both mappers are parameterized by:

  • Tag : a tag type used to instantiate SymbolId<Tag> (strong-typed string id),
  • EnumT : the enum type being mapped,
  • MapFn : a function pointer returning a const std::map<EnumT,std::string>& with the builtin mapping (legacy/static map),
  • ExtFn : (for GenericMapperWithExt) a function pointer returning const std::map<EnumT,ExternalKey>& for the external mapping.

The internal DynamicRegistry uses case-insensitive normalization via normalize_key(), so lookups are case-insensitive and aliases can be added at runtime without interfering with builtin names.

Definition in file generic_mapper.h.

Typedef Documentation

◆ IdOf

template<class Tag >
using IdOf = SymbolId<Tag>

Convenience alias for the identifier type associated with a given tag.

Template Parameters
TagTag used for SymbolId instantiation.

Definition at line 41 of file generic_mapper.h.

Function Documentation

◆ nk()

std::string nk ( std::string_view  s)
inline

Shortcut helper to normalize a string_view into a canonical key.

This simply forwards to normalize_key().

Parameters
sInput string_view.
Returns
Normalized string.

Definition at line 51 of file generic_mapper.h.