diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-06-27 15:53:12 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-06-27 15:53:12 +0200 |
commit | e989478b27598cfac60a0ee20d1d5cef71d8accb (patch) | |
tree | d76cd0fe3b1608cdf41dc07b553779c780531bb5 /include/llmr/style | |
parent | 6d9de7573202d4b2332667f2d685a0e73e7c0f52 (diff) | |
download | qtlocation-mapboxgl-e989478b27598cfac60a0ee20d1d5cef71d8accb.tar.gz |
add class dictionary to avoid storing strings all the time
Diffstat (limited to 'include/llmr/style')
-rw-r--r-- | include/llmr/style/class_dictionary.hpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/llmr/style/class_dictionary.hpp b/include/llmr/style/class_dictionary.hpp new file mode 100644 index 0000000000..772eb9c70e --- /dev/null +++ b/include/llmr/style/class_dictionary.hpp @@ -0,0 +1,32 @@ +#ifndef LLMR_STYLE_CLASS_DICTIONARY +#define LLMR_STYLE_CLASS_DICTIONARY + +#include <cstdint> +#include <string> +#include <unordered_map> + +namespace llmr { + +enum class ClassID : uint32_t { + Fallback = 0, // These values are from the fallback properties + Default = 1, // These values are from the default style for a layer + Named = 2 // These values (and all subsequent IDs) are from a named style from the layer +}; + +class ClassDictionary { +public: + // Returns an ID for a class name. If the class name does not yet have an ID, one is + // auto-generated and stored for future reference. + static ClassID Lookup(const std::string &class_name); + + // Returns either Fallback, Default or Named, depending on the type of the class id. + static ClassID Normalize(ClassID id); + +private: + static std::unordered_map<std::string, ClassID> store; + static uint32_t offset; +}; + +} + +#endif |