blob: 7898da790df92ba2ba4d95ec173d40dbb6423f24 (
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
30
31
32
33
34
35
36
37
38
39
40
|
#pragma once
#include <string>
#include <vector>
#include <mbgl/util/optional.hpp>
namespace mbgl {
namespace style {
namespace expression {
class ParsingContext {
public:
ParsingContext() {}
ParsingContext(ParsingContext previous,
optional<size_t> index,
optional<std::string> name) :
path(previous.path),
ancestors(previous.ancestors)
{
if (index) path.emplace_back(*index);
if (name) ancestors.emplace_back(*name);
}
std::string key() const {
std::string result;
for(auto const& index : path) { result += "[" + std::to_string(index) + "]"; }
return result;
}
std::string key(size_t lastIndex) const {
return key() + "[" + std::to_string(lastIndex) + "]";
}
std::vector<size_t> path;
std::vector<std::string> ancestors;
};
} // namespace expression
} // namespace style
} // namespace mbgl
|