|
ITCHCPP 1.6.1
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
|
An immutable, compile-time lookup table from a key to a description. More...
#include <indicators.hpp>
Public Types | |
| using | value_type = std::pair< KeyType, std::string_view > |
Public Member Functions | |
| constexpr | FrozenMap (std::array< value_type, Size > entries) noexcept |
Constructs the map from an unsorted list of key/description entries, sorting them by key once so that find can binary search. | |
| constexpr auto | find (const KeyType &key) const noexcept -> std::optional< std::string_view > |
Returns the description for a key, or std::nullopt if absent. | |
| constexpr auto | at_or (const KeyType &key, std::string_view fallback) const noexcept -> std::string_view |
| Returns the description for a key, or a fallback if absent. | |
An immutable, compile-time lookup table from a key to a description.
Replaces the namespace-scope std::map globals that this header used to define: those incurred dynamic initialization in every translation unit and risked one-definition-rule trouble. A FrozenMap is a literal type held in read-only storage. Its entries are sorted once at compile time, so lookups are a branch-light binary search with no allocation and no runtime setup.
| KeyType | The key type (char for single-letter codes, or std::string_view for multi-character codes). |
| Size | The number of entries. |
Definition at line 35 of file indicators.hpp.
| using itch::indicators::FrozenMap< KeyType, Size >::value_type = std::pair<KeyType, std::string_view> |
Definition at line 37 of file indicators.hpp.
|
inlineexplicitconstexprnoexcept |
Constructs the map from an unsorted list of key/description entries, sorting them by key once so that find can binary search.
| entries | The key/description pairs backing this map, in any order. |
Definition at line 44 of file indicators.hpp.
|
inlineconstexprnoexcept |
Returns the description for a key, or std::nullopt if absent.
| key | The key to look up. |
std::nullopt if no entry has this key. Definition at line 53 of file indicators.hpp.
Referenced by itch::indicators::FrozenMap< KeyType, Size >::at_or().
|
inlineconstexprnoexcept |
Returns the description for a key, or a fallback if absent.
| key | The key to look up. |
| fallback | The description to return when key is not found. |
fallback if no entry has this key. Definition at line 67 of file indicators.hpp.
References itch::indicators::FrozenMap< KeyType, Size >::find().
Referenced by itch::analytics::cross_type_name(), and itch::analytics::imbalance_direction_name().