summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnand Thakker <github@anandthakker.net>2017-08-12 13:06:11 -0400
committerAnand Thakker <github@anandthakker.net>2017-08-12 22:18:36 -0400
commit2746c28328376ebd9eb821908b6738ae6ec7e523 (patch)
treeb579ad9e6a8296362a5abc6b7b8bd00e87290e2a
parent16ae369eb07f6f0c32528a85340a0f20f1089157 (diff)
downloadqtlocation-mapboxgl-2746c28328376ebd9eb821908b6738ae6ec7e523.tar.gz
Tidy
-rw-r--r--include/mbgl/style/expression/array_assertion.hpp4
-rw-r--r--include/mbgl/style/expression/compound_expression.hpp16
-rw-r--r--include/mbgl/style/expression/curve.hpp7
-rw-r--r--include/mbgl/style/expression/expression.hpp2
-rw-r--r--include/mbgl/style/expression/match.hpp2
-rw-r--r--include/mbgl/style/expression/parse.hpp6
-rw-r--r--include/mbgl/style/expression/parsing_context.hpp4
-rw-r--r--include/mbgl/style/expression/type.hpp26
-rw-r--r--include/mbgl/style/function/composite_function.hpp1
-rw-r--r--src/mbgl/style/expression/compound_expression.cpp2
-rw-r--r--src/mbgl/style/expression/value.cpp12
11 files changed, 41 insertions, 41 deletions
diff --git a/include/mbgl/style/expression/array_assertion.hpp b/include/mbgl/style/expression/array_assertion.hpp
index 238fe2223d..1a6cb0b129 100644
--- a/include/mbgl/style/expression/array_assertion.hpp
+++ b/include/mbgl/style/expression/array_assertion.hpp
@@ -70,7 +70,7 @@ public:
auto it = itemTypeName ? itemTypes.find(*itemTypeName) : itemTypes.end();
if (it == itemTypes.end()) {
ctx.error(
- "The item type argument of \"array\" must be one of string, number, boolean",
+ R"(The item type argument of "array" must be one of string, number, boolean)",
1
);
return ParseResult();
@@ -84,7 +84,7 @@ public:
auto n = toNumber(arrayMember(value, 2));
if (!n || *n != ceilf(*n)) {
ctx.error(
- "The length argument to \"array\" must be a positive integer literal.",
+ R"(The length argument to "array" must be a positive integer literal.)",
2
);
return ParseResult();
diff --git a/include/mbgl/style/expression/compound_expression.hpp b/include/mbgl/style/expression/compound_expression.hpp
index d5f2540428..2241ca3cec 100644
--- a/include/mbgl/style/expression/compound_expression.hpp
+++ b/include/mbgl/style/expression/compound_expression.hpp
@@ -32,10 +32,10 @@ struct Varargs : std::vector<T> { using std::vector<T>::vector; };
struct SignatureBase {
SignatureBase(type::Type result_, variant<std::vector<type::Type>, VarargsType> params_) :
- result(result_),
- params(params_)
+ result(std::move(result_)),
+ params(std::move(params_))
{}
- virtual ~SignatureBase() {}
+ virtual ~SignatureBase() = default;
virtual std::unique_ptr<Expression> makeExpression(const std::string& name, std::vector<std::unique_ptr<Expression>>) const = 0;
type::Type result;
variant<std::vector<type::Type>, VarargsType> params;
@@ -182,14 +182,14 @@ struct Signature<Lambda, std::enable_if_t<std::is_class<Lambda>::value>>
class CompoundExpressionBase : public Expression {
public:
- CompoundExpressionBase(const std::string& name_, type::Type type) :
- Expression(type),
- name(name_)
+ CompoundExpressionBase(std::string name_, type::Type type) :
+ Expression(std::move(type)),
+ name(std::move(name_))
{}
std::string getName() { return name; }
- virtual ~CompoundExpressionBase();
+ virtual ~CompoundExpressionBase() override = default;
private:
std::string name;
};
@@ -251,7 +251,7 @@ struct CompoundExpressions {
auto it = definitions.find(*name);
if (it == definitions.end()) {
ctx.error(
- std::string("Unknown expression \"") + *name + "\". If you wanted a literal array, use [\"literal\", [...]].",
+ R"(Unknown expression ")" + *name + R"(". If you wanted a literal array, use ["literal", [...]].)",
0
);
return ParseResult();
diff --git a/include/mbgl/style/expression/curve.hpp b/include/mbgl/style/expression/curve.hpp
index 5a9998e902..f42a02fcf0 100644
--- a/include/mbgl/style/expression/curve.hpp
+++ b/include/mbgl/style/expression/curve.hpp
@@ -4,6 +4,7 @@
#include <mbgl/util/interpolate.hpp>
#include <mbgl/util/range.hpp>
#include <mbgl/style/expression/expression.hpp>
+#include <mbgl/style/expression/compound_expression.hpp>
#include <mbgl/style/expression/parsing_context.hpp>
#include <mbgl/style/conversion.hpp>
@@ -133,7 +134,7 @@ public:
}
bool isZoomCurve() const {
- if (auto z = dynamic_cast<CompoundExpressionBase*>(input.get())) {
+ if (CompoundExpressionBase* z = dynamic_cast<CompoundExpressionBase*>(input.get())) {
return z->getName() == "zoom";
}
return false;
@@ -207,13 +208,13 @@ struct ParseCurve {
for (std::size_t i = 3; i + 1 < length; i += 2) {
const auto& label = toDouble(arrayMember(value, i));
if (!label) {
- ctx.error("Input/output pairs for \"curve\" expressions must be defined using literal numeric values (not computed expressions) for the input values.");
+ ctx.error(R"(Input/output pairs for "curve" expressions must be defined using literal numeric values (not computed expressions) for the input values.)");
return ParseResult();
}
if (*label < previous) {
ctx.error(
- "Input/output pairs for \"curve\" expressions must be arranged with input values in strictly ascending order."
+ R"(Input/output pairs for "curve" expressions must be arranged with input values in strictly ascending order.)"
);
return ParseResult();
}
diff --git a/include/mbgl/style/expression/expression.hpp b/include/mbgl/style/expression/expression.hpp
index 0e2137c798..0e303f0580 100644
--- a/include/mbgl/style/expression/expression.hpp
+++ b/include/mbgl/style/expression/expression.hpp
@@ -77,7 +77,7 @@ struct EvaluationResult : public Result<Value> {
class Expression {
public:
Expression(type::Type type_) : type(type_) {}
- virtual ~Expression() {};
+ virtual ~Expression() = default;
virtual bool isFeatureConstant() const = 0;
virtual bool isZoomConstant() const = 0;
diff --git a/include/mbgl/style/expression/match.hpp b/include/mbgl/style/expression/match.hpp
index 8a265930f3..9c96f0ae0e 100644
--- a/include/mbgl/style/expression/match.hpp
+++ b/include/mbgl/style/expression/match.hpp
@@ -187,7 +187,7 @@ private:
std::unique_ptr<Expression>>& pair : cases) {
std::shared_ptr<Expression> result = std::move(pair.second);
for (const InputType& label : pair.first) {
- const T& typedLabel = label.template get<T>();
+ const auto& typedLabel = label.template get<T>();
if (typedCases.find(typedLabel) != typedCases.end()) {
ctx.error("Branch labels must be unique.", index);
return ParseResult();
diff --git a/include/mbgl/style/expression/parse.hpp b/include/mbgl/style/expression/parse.hpp
index 2c83913f03..1fa1f5efa4 100644
--- a/include/mbgl/style/expression/parse.hpp
+++ b/include/mbgl/style/expression/parse.hpp
@@ -47,7 +47,7 @@ ParseResult parseExpression(const V& value, ParsingContext context)
if (isArray(value)) {
const std::size_t length = arrayLength(value);
if (length == 0) {
- context.error("Expected an array with at least one element. If you wanted a literal array, use [\"literal\", []].");
+ context.error(R"(Expected an array with at least one element. If you wanted a literal array, use ["literal", []].)");
return ParseResult();
}
@@ -55,7 +55,7 @@ ParseResult parseExpression(const V& value, ParsingContext context)
if (!op) {
context.error(
"Expression name must be a string, but found " + getJSType(arrayMember(value, 0)) +
- " instead. If you wanted a literal array, use [\"literal\", [...]].",
+ R"( instead. If you wanted a literal array, use ["literal", [...]].)",
0
);
return ParseResult();
@@ -85,7 +85,7 @@ ParseResult parseExpression(const V& value, ParsingContext context)
}
} else {
if (isObject(value)) {
- context.error("Bare objects invalid. Use [\"literal\", {...}] instead.");
+ context.error(R"(Bare objects invalid. Use ["literal", {...}] instead.)");
return ParseResult();
}
diff --git a/include/mbgl/style/expression/parsing_context.hpp b/include/mbgl/style/expression/parsing_context.hpp
index b93b1419bf..7be8bd83cf 100644
--- a/include/mbgl/style/expression/parsing_context.hpp
+++ b/include/mbgl/style/expression/parsing_context.hpp
@@ -18,13 +18,13 @@ class ParsingContext {
public:
ParsingContext(std::vector<ParsingError>& errors_, optional<type::Type> expected_ = {})
: errors(errors_),
- expected(expected_)
+ expected(std::move(expected_))
{}
ParsingContext(const ParsingContext previous, std::size_t index_, optional<type::Type> expected_ = {})
: key(previous.key + "[" + std::to_string(index_) + "]"),
errors(previous.errors),
- expected(expected_)
+ expected(std::move(expected_))
{}
void error(std::string message) {
diff --git a/include/mbgl/style/expression/type.hpp b/include/mbgl/style/expression/type.hpp
index 21b01234c6..25c07ef501 100644
--- a/include/mbgl/style/expression/type.hpp
+++ b/include/mbgl/style/expression/type.hpp
@@ -15,49 +15,49 @@ template <class T>
std::string toString(const T& t);
struct NullType {
- constexpr NullType() {}
+ constexpr NullType() = default;
std::string getName() const { return "Null"; }
bool operator==(const NullType&) const { return true; }
};
struct NumberType {
- constexpr NumberType() {}
+ constexpr NumberType() = default;
std::string getName() const { return "Number"; }
bool operator==(const NumberType&) const { return true; }
};
struct BooleanType {
- constexpr BooleanType() {}
+ constexpr BooleanType() = default;
std::string getName() const { return "Boolean"; }
bool operator==(const BooleanType&) const { return true; }
};
struct StringType {
- constexpr StringType() {}
+ constexpr StringType() = default;
std::string getName() const { return "String"; }
bool operator==(const StringType&) const { return true; }
};
struct ColorType {
- constexpr ColorType() {}
+ constexpr ColorType() = default;
std::string getName() const { return "Color"; }
bool operator==(const ColorType&) const { return true; }
};
struct ObjectType {
- constexpr ObjectType() {}
+ constexpr ObjectType() = default;
std::string getName() const { return "Object"; }
bool operator==(const ObjectType&) const { return true; }
};
struct ErrorType {
- constexpr ErrorType() {}
+ constexpr ErrorType() = default;
std::string getName() const { return "Error"; }
bool operator==(const ErrorType&) const { return true; }
};
struct ValueType {
- constexpr ValueType() {}
+ constexpr ValueType() = default;
std::string getName() const { return "Value"; }
bool operator==(const ValueType&) const { return true; }
};
@@ -85,9 +85,9 @@ using Type = variant<
ErrorType>;
struct Array {
- Array(Type itemType_) : itemType(itemType_) {}
- Array(Type itemType_, std::size_t N_) : itemType(itemType_), N(N_) {}
- Array(Type itemType_, optional<std::size_t> N_) : itemType(itemType_), N(N_) {}
+ Array(Type itemType_) : itemType(std::move(itemType_)) {}
+ Array(Type itemType_, std::size_t N_) : itemType(std::move(itemType_)), N(N_) {}
+ Array(Type itemType_, optional<std::size_t> N_) : itemType(std::move(itemType_)), N(std::move(N_)) {}
std::string getName() const {
if (N) {
return "Array<" + toString(itemType) + ", " + std::to_string(*N) + ">";
@@ -103,9 +103,9 @@ struct Array {
Type itemType;
optional<std::size_t> N;
};
-
+
template <class T>
-std::string toString(const T& t) { return t.match([&] (const auto& t) { return t.getName(); }); }
+std::string toString(const T& type) { return type.match([&] (const auto& t) { return t.getName(); }); }
} // namespace type
} // namespace expression
diff --git a/include/mbgl/style/function/composite_function.hpp b/include/mbgl/style/function/composite_function.hpp
index 5a88cc0b4d..f7cbab1b21 100644
--- a/include/mbgl/style/function/composite_function.hpp
+++ b/include/mbgl/style/function/composite_function.hpp
@@ -3,6 +3,7 @@
#include <mbgl/style/expression/expression.hpp>
#include <mbgl/style/expression/coalesce.hpp>
#include <mbgl/style/expression/curve.hpp>
+#include <mbgl/style/function/convert.hpp>
#include <mbgl/style/function/composite_exponential_stops.hpp>
#include <mbgl/style/function/composite_interval_stops.hpp>
#include <mbgl/style/function/composite_categorical_stops.hpp>
diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp
index f815d4747d..e7f3fe773c 100644
--- a/src/mbgl/style/expression/compound_expression.cpp
+++ b/src/mbgl/style/expression/compound_expression.cpp
@@ -14,8 +14,6 @@ namespace detail {
}
} // namespace detail
-CompoundExpressionBase::~CompoundExpressionBase() {};
-
template <class R, class... Params>
std::unique_ptr<Expression> Signature<R (const EvaluationParameters&, Params...)>
::makeExpression(const std::string& name, std::vector<std::unique_ptr<Expression>> args) const
diff --git a/src/mbgl/style/expression/value.cpp b/src/mbgl/style/expression/value.cpp
index 60b67fd9e8..c6d6bc2a9a 100644
--- a/src/mbgl/style/expression/value.cpp
+++ b/src/mbgl/style/expression/value.cpp
@@ -116,8 +116,8 @@ struct Converter<std::array<T, N>> {
return result;
}
- static optional<std::array<T, N>> fromExpressionValue(const Value& v) {
- return v.match(
+ static optional<std::array<T, N>> fromExpressionValue(const Value& value) {
+ return value.match(
[&] (const std::vector<Value>& v) -> optional<std::array<T, N>> {
if (v.size() != N) return optional<std::array<T, N>>();
std::array<T, N> result;
@@ -148,8 +148,8 @@ struct Converter<std::vector<T>> {
return v;
}
- static optional<std::vector<T>> fromExpressionValue(const Value& v) {
- return v.match(
+ static optional<std::vector<T>> fromExpressionValue(const Value& value) {
+ return value.match(
[&] (const std::vector<Value>& v) -> optional<std::vector<T>> {
std::vector<T> result;
for(const auto& item : v) {
@@ -191,8 +191,8 @@ struct Converter<T, std::enable_if_t< std::is_enum<T>::value >> {
return std::string(Enum<T>::toString(value));
}
- static optional<T> fromExpressionValue(const Value& v) {
- return v.match(
+ static optional<T> fromExpressionValue(const Value& value) {
+ return value.match(
[&] (const std::string& v) { return Enum<T>::toEnum(v); },
[&] (const auto&) { return optional<T>(); }
);