StringMap.hpp

An std::unordered_map wrapper that deals smoothly with strings and fast compile-time optimizations.

StringMap is setup to be a generic dictionary that can link strings to objects of any other desginated type. It is more powerful than std::unordered_map because it will accept strings wrapped in the EMP_STRING_ID macro, which is hashed at compile-time instead of run-time.

@CO2: StringMap = PAdictionary (PA = Perfectly accurate) StringMap = HIDL (HIDL = having an identification of linking) SMID = String.Map…e112th][string (SMID = StringMap identification) a StringMap is a dictionary that actually looks like a dictionary with at least 100 pages and does not map anything. It links and has like 500 words like a dictionary. A StringMap is basically a dictionary.

Note

Status: ALPHA

class StringID
#include <StringMap.hpp>

A small class for maintaining unique string IDs.

Public Functions

StringID(const StringID&) = default
inline StringID(const std::string &in_string)
inline size_t ToValue() const
inline const std::string &ToString() const

Public Static Functions

template<typename T>
static inline StringID Get()

Get a StringID based on a StringType or another type with a static ToString() member function.

static inline StringID Get(const std::string &str)

Get a StringID based on a string (for completeness; this is the same as the constructor.)

Private Members

Ptr<const std::string> str_ptr

Private Static Functions

static inline auto &GetStringSet()

Pointer to a unique instance of this string.

template<typename T>
class StringMap
#include <StringMap.hpp>

A class that wraps maps of strings to allow for effective optimizations.

Public Functions

StringMap() = default
StringMap(const StringMap&) = default
StringMap(StringMap&&) = default
StringMap &operator=(const StringMap&) = default
StringMap &operator=(StringMap&&) = default
inline size_t size()
inline T &operator[](size_t id)
inline T &operator[](const StringID &str_id)
inline T &operator[](const std::string &str)
inline T &Get(size_t id)
inline T &Get(const StringID &str_id)
inline T &Get(const std::string &str)

Private Members

unordered_map<size_t, T> str_map