summaryrefslogtreecommitdiff
path: root/src/style/class_dictionary.cpp
blob: 6e1eb5a8797b401dbdd90e5134d9f6b1c717a158 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <mbgl/style/class_dictionary.hpp>

namespace mbgl {

ClassID ClassDictionary::Lookup(const std::string &class_name) {
    auto it = store.find(class_name);
    if (it == store.end()) {
        // Insert the class name into the store.
        ClassID id = ClassID(uint32_t(ClassID::Named) + offset++);
        store.emplace(class_name, id);
        return id;
    } else {
        return it->second;
    }
}

ClassID ClassDictionary::Normalize(ClassID id) {
    if (id >= ClassID::Named) {
        return ClassID::Named;
    } else {
        return id;
    }
}


std::unordered_map<std::string, ClassID> ClassDictionary::store = { { "", ClassID::Default } };
uint32_t ClassDictionary::offset = 0;

}