blob: 6eb106dfecbf2371109dbce815877fc733d45baa (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/style/expression/is_constant.hpp>
#include <mbgl/style/expression/is_expression.hpp>
#include <mbgl/style/expression/literal.hpp>
#include <mbgl/style/expression/expression.hpp>
#include <mbgl/style/expression/type.hpp>
#include <mbgl/style/expression/compound_expression.hpp>
#include <mbgl/style/expression/boolean_operator.hpp>
namespace mbgl {
namespace style {
namespace expression {
bool Formatted::operator==(const Formatted& other) const {
if (other.sections.size() != sections.size()) {
return false;
}
for (std::size_t i = 0; i < sections.size(); i++) {
const auto& thisSection = sections.at(i);
const auto& otherSection = other.sections.at(i);
if (thisSection.text != otherSection.text ||
thisSection.fontScale != otherSection.fontScale ||
thisSection.fontStack != otherSection.fontStack) {
return false;
}
}
return true;
}
std::string Formatted::toString() const {
std::string result;
for (const auto& section : sections) {
result += section.text;
}
return result;
}
} // namespace expression
namespace conversion {
using namespace mbgl::style::expression;
optional<Formatted> Converter<Formatted>::operator()(const Convertible& value, Error&) const {
using namespace mbgl::style::expression;
auto result = toString(value);
if (result) {
return Formatted(result->c_str());
} else {
return nullopt;
}
}
} // namespace conversion
} // namespace style
} // namespace mbgl
|