#pragma once #include #include #include #include #include #include #include namespace mbgl { namespace style { namespace conversion { template <> struct Converter { optional operator()(const Convertible& value, Error& error) const; }; template <> struct Converter { optional operator()(const Convertible& value, Error& error) const; }; template <> struct Converter { optional operator()(const Convertible& value, Error& error) const; }; template struct Converter::value>> { optional operator()(const Convertible& value, Error& error) const { optional string = toString(value); if (!string) { error.message = "value must be a string"; return nullopt; } const auto result = Enum::toEnum(*string); if (!result) { error.message = "value must be a valid enumeration value"; return nullopt; } return *result; } }; template <> struct Converter { optional operator()(const Convertible& value, Error& error) const; }; template struct Converter> { optional> operator()(const Convertible& value, Error& error) const { if (!isArray(value) || arrayLength(value) != N) { error.message = "value must be an array of " + util::toString(N) + " numbers"; return nullopt; } std::array result; for (size_t i = 0; i < N; i++) { optional n = toNumber(arrayMember(value, i)); if (!n) { error.message = "value must be an array of " + util::toString(N) + " numbers"; return nullopt; } result[i] = *n; } return result; } }; template <> struct Converter> { optional> operator()(const Convertible& value, Error& error) const; }; template <> struct Converter> { optional> operator()(const Convertible& value, Error& error) const; }; } // namespace conversion } // namespace style } // namespace mbgl