From 83d650959577acf59d82ff039cbf3572e5da89ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 20 Oct 2020 21:48:55 +0200 Subject: [PATCH] Math: adapt to changes to Tweakable internals. --- src/Magnum/Math/Angle.cpp | 62 +++++++++++++----------- src/Magnum/Math/Angle.h | 8 ++-- src/Magnum/Math/Color.cpp | 75 ++++++++++++++++-------------- src/Magnum/Math/Color.h | 8 ++-- src/Magnum/Math/Half.cpp | 18 +++---- src/Magnum/Math/Half.h | 2 +- src/Magnum/Math/Test/AngleTest.cpp | 5 +- src/Magnum/Math/Test/ColorTest.cpp | 33 ++++++------- src/Magnum/Math/Test/HalfTest.cpp | 4 +- 9 files changed, 116 insertions(+), 99 deletions(-) diff --git a/src/Magnum/Math/Angle.cpp b/src/Magnum/Math/Angle.cpp index 61e66eb84..6a4f66a27 100644 --- a/src/Magnum/Math/Angle.cpp +++ b/src/Magnum/Math/Angle.cpp @@ -26,96 +26,102 @@ #include "Angle.h" #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) -#include -#include -#include -#include +#include /** @todo get rid of this once StringView::find() exists */ +#include #include namespace Corrade { namespace Utility { -std::pair> TweakableParser>::parse(const Containers::ArrayView value) { +std::pair> TweakableParser>::parse(const Containers::StringView value) { + using namespace Containers::Literals; + char* end; - const Magnum::Float result = std::strtof(value, &end); + const Magnum::Float result = std::strtof(value.data(), &end); if(end == value.begin() || std::find(value.begin(), value.end(), '.') == value.end()) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "is not an angle literal"; + Warning{} << "Utility::TweakableParser:" << value << "is not an angle literal"; return {TweakableState::Recompile, {}}; } - if(!String::viewEndsWith(value, "_degf")) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "has an unexpected suffix, expected _degf"; + if(!value.hasSuffix("_degf"_s)) { + Warning{} << "Utility::TweakableParser:" << value << "has an unexpected suffix, expected _degf"; return {TweakableState::Recompile, {}}; } if(end != value.end() - 5) { - Warning{} << "Utility::TweakableParser: unexpected characters" << std::string{const_cast(end), value.end()} << "after an angle literal"; + Warning{} << "Utility::TweakableParser: unexpected characters" << value.suffix(end) << "after an angle literal"; return {TweakableState::Recompile, {}}; } return {TweakableState::Success, Magnum::Math::Deg{result}}; } -std::pair> TweakableParser>::parse(const Containers::ArrayView value) { +std::pair> TweakableParser>::parse(const Containers::StringView value) { + using namespace Containers::Literals; + char* end; - const Magnum::Double result = std::strtod(value, &end); + const Magnum::Double result = std::strtod(value.data(), &end); if(end == value.begin() || std::find(value.begin(), value.end(), '.') == value.end()) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "is not an angle literal"; + Warning{} << "Utility::TweakableParser:" << value << "is not an angle literal"; return {TweakableState::Recompile, {}}; } - if(!String::viewEndsWith(value, "_deg")) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "has an unexpected suffix, expected _deg"; + if(!value.hasSuffix("_deg"_s)) { + Warning{} << "Utility::TweakableParser:" << value << "has an unexpected suffix, expected _deg"; return {TweakableState::Recompile, {}}; } if(end != value.end() - 4) { - Warning{} << "Utility::TweakableParser: unexpected characters" << std::string{const_cast(end), value.end()} << "after an angle literal"; + Warning{} << "Utility::TweakableParser: unexpected characters" << value.suffix(end) << "after an angle literal"; return {TweakableState::Recompile, {}}; } return {TweakableState::Success, Magnum::Math::Deg{result}}; } -std::pair> TweakableParser>::parse(const Containers::ArrayView value) { +std::pair> TweakableParser>::parse(const Containers::StringView value) { + using namespace Containers::Literals; + char* end; - const Magnum::Float result = std::strtof(value, &end); + const Magnum::Float result = std::strtof(value.data(), &end); if(end == value.begin() || std::find(value.begin(), value.end(), '.') == value.end()) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "is not an angle literal"; + Warning{} << "Utility::TweakableParser:" << value << "is not an angle literal"; return {TweakableState::Recompile, {}}; } - if(!String::viewEndsWith(value, "_radf")) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "has an unexpected suffix, expected _radf"; + if(!value.hasSuffix("_radf"_s)) { + Warning{} << "Utility::TweakableParser:" << value.data() << "has an unexpected suffix, expected _radf"; return {TweakableState::Recompile, {}}; } if(end != value.end() - 5) { - Warning{} << "Utility::TweakableParser: unexpected characters" << std::string{const_cast(end), value.end()} << "after an angle literal"; + Warning{} << "Utility::TweakableParser: unexpected characters" << value.suffix(end) << "after an angle literal"; return {TweakableState::Recompile, {}}; } return {TweakableState::Success, Magnum::Math::Rad{result}}; } -std::pair> TweakableParser>::parse(const Containers::ArrayView value) { +std::pair> TweakableParser>::parse(const Containers::StringView value) { + using namespace Containers::Literals; + char* end; - const Magnum::Double result = std::strtod(value, &end); + const Magnum::Double result = std::strtod(value.data(), &end); if(end == value.begin() || std::find(value.begin(), value.end(), '.') == value.end()) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "is not an angle literal"; + Warning{} << "Utility::TweakableParser:" << value << "is not an angle literal"; return {TweakableState::Recompile, {}}; } - if(!String::viewEndsWith(value, "_rad")) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "has an unexpected suffix, expected _rad"; + if(!value.hasSuffix("_rad"_s)) { + Warning{} << "Utility::TweakableParser:" << value << "has an unexpected suffix, expected _rad"; return {TweakableState::Recompile, {}}; } if(end != value.end() - 4) { - Warning{} << "Utility::TweakableParser: unexpected characters" << std::string{const_cast(end), value.end()} << "after an angle literal"; + Warning{} << "Utility::TweakableParser: unexpected characters" << value.suffix(end) << "after an angle literal"; return {TweakableState::Recompile, {}}; } diff --git a/src/Magnum/Math/Angle.h b/src/Magnum/Math/Angle.h index 10a431f31..a81970cb9 100644 --- a/src/Magnum/Math/Angle.h +++ b/src/Magnum/Math/Angle.h @@ -263,7 +263,7 @@ template<> struct MAGNUM_EXPORT TweakableParser TweakableParser() = delete; /** @brief Parse the value */ - static std::pair> parse(Containers::ArrayView value); + static std::pair> parse(Containers::StringView value); }; /** @@ -276,7 +276,7 @@ template<> struct MAGNUM_EXPORT TweakableParser> parse(Containers::ArrayView value); + static std::pair> parse(Containers::StringView value); }; /** @@ -289,7 +289,7 @@ template<> struct MAGNUM_EXPORT TweakableParser TweakableParser() = delete; /** @brief Parse the value */ - static std::pair> parse(Containers::ArrayView value); + static std::pair> parse(Containers::StringView value); }; /** @@ -302,7 +302,7 @@ template<> struct MAGNUM_EXPORT TweakableParser> parse(Containers::ArrayView value); + static std::pair> parse(Containers::StringView value); }; #endif diff --git a/src/Magnum/Math/Color.cpp b/src/Magnum/Math/Color.cpp index d5c9a0314..aa49bbebb 100644 --- a/src/Magnum/Math/Color.cpp +++ b/src/Magnum/Math/Color.cpp @@ -27,8 +27,7 @@ #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) #include -#include -#include +#include #include #endif @@ -146,28 +145,30 @@ Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug& debug, const Color4 #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) namespace Corrade { namespace Utility { -std::pair> TweakableParser>::parse(const Containers::ArrayView value) { +std::pair> TweakableParser>::parse(const Containers::StringView value) { + using namespace Containers::Literals; + if(value.size() < 2 || value[0] != '0' || (value[1] != 'x' && value[1] != 'X')) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "is not a hexadecimal color literal"; + Warning{} << "Utility::TweakableParser:" << value << "is not a hexadecimal color literal"; return {TweakableState::Recompile, {}}; } - const bool isSrgb = String::viewEndsWith(value, "_srgb"); - if(!isSrgb && !String::viewEndsWith(value, "_rgb")) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "has an unexpected suffix, expected _rgb or _srgb"; + const bool isSrgb = value.hasSuffix("_srgb"_s); + if(!isSrgb && !value.hasSuffix("_rgb"_s)) { + Warning{} << "Utility::TweakableParser:" << value << "has an unexpected suffix, expected _rgb or _srgb"; return {TweakableState::Recompile, {}}; } char* end; - const Magnum::UnsignedInt result = std::strtoul(value, &end, 16); + const Magnum::UnsignedInt result = std::strtoul(value.data(), &end, 16); if(end != value.end() - (isSrgb ? 5 : 4)) { - Warning{} << "Utility::TweakableParser: unexpected characters" << std::string{const_cast(end), value.end()} << "after a color literal"; + Warning{} << "Utility::TweakableParser: unexpected characters" << value.suffix(end) << "after a color literal"; return {TweakableState::Recompile, {}}; } if(value.size() != std::size_t(isSrgb ? 13 : 12)) { - Error{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "doesn't have expected number of digits"; + Error{} << "Utility::TweakableParser:" << value << "doesn't have expected number of digits"; return {TweakableState::Error, {}}; } @@ -176,28 +177,30 @@ std::pair> TweakableP Magnum::Math::Literals::operator "" _rgb(result)}; } -std::pair> TweakableParser>::parse(const Containers::ArrayView value) { +std::pair> TweakableParser>::parse(const Containers::StringView value) { + using namespace Containers::Literals; + if(value.size() < 2 || value[0] != '0' || (value[1] != 'x' && value[1] != 'X')) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "is not a hexadecimal color literal"; + Warning{} << "Utility::TweakableParser:" << value << "is not a hexadecimal color literal"; return {TweakableState::Recompile, {}}; } - const bool isSrgb = String::viewEndsWith(value, "_srgba"); - if(!isSrgb && !String::viewEndsWith(value, "_rgba")) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "has an unexpected suffix, expected _rgba or _srgba"; + const bool isSrgb = value.hasSuffix("_srgba"_s); + if(!isSrgb && !value.hasSuffix("_rgba"_s)) { + Warning{} << "Utility::TweakableParser:" << value << "has an unexpected suffix, expected _rgba or _srgba"; return {TweakableState::Recompile, {}}; } char* end; - const Magnum::UnsignedInt result = std::strtoul(value, &end, 16); + const Magnum::UnsignedInt result = std::strtoul(value.data(), &end, 16); if(end != value.end() - (isSrgb ? 6 : 5)) { - Warning{} << "Utility::TweakableParser: unexpected characters" << std::string{const_cast(end), value.end()} << "after a color literal"; + Warning{} << "Utility::TweakableParser: unexpected characters" << value.suffix(end) << "after a color literal"; return {TweakableState::Recompile, {}}; } if(value.size() != std::size_t(isSrgb ? 16 : 15)) { - Error{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "doesn't have expected number of digits"; + Error{} << "Utility::TweakableParser:" << value << "doesn't have expected number of digits"; return {TweakableState::Error, {}}; } @@ -206,28 +209,30 @@ std::pair> TweakableP Magnum::Math::Literals::operator "" _rgba(result)}; } -std::pair> TweakableParser>::parse(const Containers::ArrayView value) { +std::pair> TweakableParser>::parse(const Containers::StringView value) { + using namespace Containers::Literals; + if(value.size() < 2 || value[0] != '0' || (value[1] != 'x' && value[1] != 'X')) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "is not a hexadecimal color literal"; + Warning{} << "Utility::TweakableParser:" << value << "is not a hexadecimal color literal"; return {TweakableState::Recompile, {}}; } - const bool isSrgb = String::viewEndsWith(value, "_srgbf"); - if(!isSrgb && !String::viewEndsWith(value, "_rgbf")) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "has an unexpected suffix, expected _rgbf or _srgbf"; + const bool isSrgb = value.hasSuffix("_srgbf"_s); + if(!isSrgb && !value.hasSuffix("_rgbf"_s)) { + Warning{} << "Utility::TweakableParser:" << value << "has an unexpected suffix, expected _rgbf or _srgbf"; return {TweakableState::Recompile, {}}; } char* end; - const Magnum::UnsignedInt result = std::strtoul(value, &end, 16); + const Magnum::UnsignedInt result = std::strtoul(value.data(), &end, 16); if(end != value.end() - (isSrgb ? 6 : 5)) { - Warning{} << "Utility::TweakableParser: unexpected characters" << std::string{const_cast(end), value.end()} << "after a color literal"; + Warning{} << "Utility::TweakableParser: unexpected characters" << value.suffix(end) << "after a color literal"; return {TweakableState::Recompile, {}}; } if(value.size() != std::size_t(isSrgb ? 14 : 13)) { - Error{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "doesn't have expected number of digits"; + Error{} << "Utility::TweakableParser:" << value << "doesn't have expected number of digits"; return {TweakableState::Error, {}}; } @@ -236,28 +241,30 @@ std::pair> TweakableParser> TweakableParser>::parse(const Containers::ArrayView value) { +std::pair> TweakableParser>::parse(const Containers::StringView value) { + using namespace Containers::Literals; + if(value.size() < 2 || value[0] != '0' || (value[1] != 'x' && value[1] != 'X')) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "is not a hexadecimal color literal"; + Warning{} << "Utility::TweakableParser:" << value << "is not a hexadecimal color literal"; return {TweakableState::Recompile, {}}; } - const bool isSrgb = String::viewEndsWith(value, "_srgbaf"); - if(!isSrgb && !String::viewEndsWith(value, "_rgbaf")) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "has an unexpected suffix, expected _rgbaf or _srgbaf"; + const bool isSrgb = value.hasSuffix("_srgbaf"_s); + if(!isSrgb && !value.hasSuffix("_rgbaf"_s)) { + Warning{} << "Utility::TweakableParser:" << value << "has an unexpected suffix, expected _rgbaf or _srgbaf"; return {TweakableState::Recompile, {}}; } char* end; - const Magnum::UnsignedInt result = std::strtoul(value, &end, 16); + const Magnum::UnsignedInt result = std::strtoul(value.data(), &end, 16); if(end != value.end() - (isSrgb ? 7 : 6)) { - Warning{} << "Utility::TweakableParser: unexpected characters" << std::string{const_cast(end), value.end()} << "after a color literal"; + Warning{} << "Utility::TweakableParser: unexpected characters" << value.suffix(end) << "after a color literal"; return {TweakableState::Recompile, {}}; } if(value.size() != (isSrgb ? 17 : 16)) { - Error{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "doesn't have expected number of digits"; + Error{} << "Utility::TweakableParser:" << value << "doesn't have expected number of digits"; return {TweakableState::Error, {}}; } diff --git a/src/Magnum/Math/Color.h b/src/Magnum/Math/Color.h index 6d2fa9f05..c0e8efa5f 100644 --- a/src/Magnum/Math/Color.h +++ b/src/Magnum/Math/Color.h @@ -1429,7 +1429,7 @@ template<> struct MAGNUM_EXPORT TweakableParser> parse(Containers::ArrayView value); + static std::pair> parse(Containers::StringView value); }; #ifndef DOXYGEN_GENERATING_OUTPUT @@ -1447,7 +1447,7 @@ template<> struct MAGNUM_EXPORT TweakableParser> parse(Containers::ArrayView value); + static std::pair> parse(Containers::StringView value); }; #ifndef DOXYGEN_GENERATING_OUTPUT @@ -1465,7 +1465,7 @@ template<> struct MAGNUM_EXPORT TweakableParser> parse(Containers::ArrayView value); + static std::pair> parse(Containers::StringView value); }; /** @@ -1479,7 +1479,7 @@ template<> struct MAGNUM_EXPORT TweakableParser> parse(Containers::ArrayView value); + static std::pair> parse(Containers::StringView value); }; #endif diff --git a/src/Magnum/Math/Half.cpp b/src/Magnum/Math/Half.cpp index e0d7d0318..b61811938 100644 --- a/src/Magnum/Math/Half.cpp +++ b/src/Magnum/Math/Half.cpp @@ -30,8 +30,8 @@ #include #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) -#include -#include +#include /** @todo get rid of this once StringView::find() exists */ +#include #include #endif @@ -50,22 +50,24 @@ Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug& debug, Half value) #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) namespace Corrade { namespace Utility { -std::pair TweakableParser::parse(const Containers::ArrayView value) { +std::pair TweakableParser::parse(const Containers::StringView value) { + using namespace Containers::Literals; + char* end; - const Magnum::Float result = std::strtof(value, &end); + const Magnum::Float result = std::strtof(value.data(), &end); if(end == value.begin() || std::find(value.begin(), value.end(), '.') == value.end()) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "is not a half literal"; + Warning{} << "Utility::TweakableParser:" << value << "is not a half literal"; return {TweakableState::Recompile, {}}; } - if(!String::viewEndsWith(value, "_h")) { - Warning{} << "Utility::TweakableParser:" << std::string{value, value.size()} << "has an unexpected suffix, expected _h"; + if(!value.hasSuffix("_h"_s)) { + Warning{} << "Utility::TweakableParser:" << value << "has an unexpected suffix, expected _h"; return {TweakableState::Recompile, {}}; } if(end != value.end() - 2) { - Warning{} << "Utility::TweakableParser: unexpected characters" << std::string{const_cast(end), value.end()} << "after a half literal"; + Warning{} << "Utility::TweakableParser: unexpected characters" << value.suffix(end) << "after a half literal"; return {TweakableState::Recompile, {}}; } diff --git a/src/Magnum/Math/Half.h b/src/Magnum/Math/Half.h index 08aa02804..2b4cf32c3 100644 --- a/src/Magnum/Math/Half.h +++ b/src/Magnum/Math/Half.h @@ -213,7 +213,7 @@ template<> struct MAGNUM_EXPORT TweakableParser { TweakableParser() = delete; /** @brief Parse the value */ - static std::pair parse(Containers::ArrayView value); + static std::pair parse(Containers::StringView value); }; }} diff --git a/src/Magnum/Math/Test/AngleTest.cpp b/src/Magnum/Math/Test/AngleTest.cpp index 7c0562524..9ed665347 100644 --- a/src/Magnum/Math/Test/AngleTest.cpp +++ b/src/Magnum/Math/Test/AngleTest.cpp @@ -29,6 +29,7 @@ #include #include #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) +#include #include #include #endif @@ -294,7 +295,7 @@ template void AngleTest::tweakable() { std::string input = Corrade::Utility::formatString(data.data, TweakableTraits::literal()); Corrade::Utility::TweakableState state; T result; - std::tie(state, result) = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}); + std::tie(state, result) = Corrade::Utility::TweakableParser::parse(input); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(result, T(typename T::Type(data.result))); } @@ -308,7 +309,7 @@ template void AngleTest::tweakableError() { std::ostringstream out; Warning redirectWarning{&out}; Error redirectError{&out}; - Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}).first; + Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse(input).first; CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, TweakableTraits::literal())); CORRADE_COMPARE(state, data.state); } diff --git a/src/Magnum/Math/Test/ColorTest.cpp b/src/Magnum/Math/Test/ColorTest.cpp index aa1e0af90..435de364d 100644 --- a/src/Magnum/Math/Test/ColorTest.cpp +++ b/src/Magnum/Math/Test/ColorTest.cpp @@ -28,6 +28,7 @@ #include #include #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) +#include #include #include #endif @@ -1099,7 +1100,7 @@ void ColorTest::tweakableRgb() { std::string input = Corrade::Utility::formatString(data.dataRgb, "rgb"); Corrade::Utility::TweakableState state; Color3ub result; - std::tie(state, result) = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}); + std::tie(state, result) = Corrade::Utility::TweakableParser::parse(input); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(result, data.resultUb.rgb()); } @@ -1110,7 +1111,7 @@ void ColorTest::tweakableSrgb() { std::string input = Corrade::Utility::formatString(data.dataRgb, "srgb"); Corrade::Utility::TweakableState state; Math::Vector3 result; - std::tie(state, result) = Corrade::Utility::TweakableParser>::parse({input.data(), input.size()}); + std::tie(state, result) = Corrade::Utility::TweakableParser>::parse(input); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(result, data.resultUb.rgb()); } @@ -1121,7 +1122,7 @@ void ColorTest::tweakableRgba() { std::string input = Corrade::Utility::formatString(data.dataRgba, "rgba"); Corrade::Utility::TweakableState state; Color4ub result; - std::tie(state, result) = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}); + std::tie(state, result) = Corrade::Utility::TweakableParser::parse(input); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(result, data.resultUb); } @@ -1132,7 +1133,7 @@ void ColorTest::tweakableSrgba() { std::string input = Corrade::Utility::formatString(data.dataRgba, "srgba"); Corrade::Utility::TweakableState state; Math::Vector4 result; - std::tie(state, result) = Corrade::Utility::TweakableParser>::parse({input.data(), input.size()}); + std::tie(state, result) = Corrade::Utility::TweakableParser>::parse(input); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(result, data.resultUb); } @@ -1143,7 +1144,7 @@ void ColorTest::tweakableRgbf() { std::string input = Corrade::Utility::formatString(data.dataRgb, "rgbf"); Corrade::Utility::TweakableState state; Color3 result; - std::tie(state, result) = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}); + std::tie(state, result) = Corrade::Utility::TweakableParser::parse(input); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(result, data.result.rgb()); } @@ -1154,7 +1155,7 @@ void ColorTest::tweakableSrgbf() { std::string input = Corrade::Utility::formatString(data.dataRgb, "srgbf"); Corrade::Utility::TweakableState state; Color3 result; - std::tie(state, result) = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}); + std::tie(state, result) = Corrade::Utility::TweakableParser::parse(input); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(result, data.resultSrgba.rgb()); } @@ -1165,7 +1166,7 @@ void ColorTest::tweakableRgbaf() { std::string input = Corrade::Utility::formatString(data.dataRgba, "rgbaf"); Corrade::Utility::TweakableState state; Color4 result; - std::tie(state, result) = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}); + std::tie(state, result) = Corrade::Utility::TweakableParser::parse(input); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(result, data.result); } @@ -1176,7 +1177,7 @@ void ColorTest::tweakableSrgbaf() { std::string input = Corrade::Utility::formatString(data.dataRgba, "srgbaf"); Corrade::Utility::TweakableState state; Color4 result; - std::tie(state, result) = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}); + std::tie(state, result) = Corrade::Utility::TweakableParser::parse(input); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(result, data.resultSrgba); } @@ -1189,7 +1190,7 @@ void ColorTest::tweakableErrorRgb() { std::ostringstream out; Warning redirectWarning{&out}; Error redirectError{&out}; - Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}).first; + Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse(input).first; CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366", "rgb", "")); CORRADE_COMPARE(state, data.state); } @@ -1202,7 +1203,7 @@ void ColorTest::tweakableErrorSrgb() { std::ostringstream out; Warning redirectWarning{&out}; Error redirectError{&out}; - Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser>::parse({input.data(), input.size()}).first; + Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser>::parse(input).first; CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366", "rgb", "s")); CORRADE_COMPARE(state, data.state); } @@ -1215,7 +1216,7 @@ void ColorTest::tweakableErrorRgba() { std::ostringstream out; Warning redirectWarning{&out}; Error redirectError{&out}; - Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}).first; + Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse(input).first; CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366aa", "rgba", "")); CORRADE_COMPARE(state, data.state); } @@ -1228,7 +1229,7 @@ void ColorTest::tweakableErrorSrgba() { std::ostringstream out; Warning redirectWarning{&out}; Error redirectError{&out}; - Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser>::parse({input.data(), input.size()}).first; + Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser>::parse(input).first; CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366aa", "rgba", "s")); CORRADE_COMPARE(state, data.state); } @@ -1241,7 +1242,7 @@ void ColorTest::tweakableErrorRgbf() { std::ostringstream out; Warning redirectWarning{&out}; Error redirectError{&out}; - Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}).first; + Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse(input).first; CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366", "rgbf", "")); CORRADE_COMPARE(state, data.state); } @@ -1254,7 +1255,7 @@ void ColorTest::tweakableErrorSrgbf() { std::ostringstream out; Warning redirectWarning{&out}; Error redirectError{&out}; - Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}).first; + Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse(input).first; CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366", "rgbf", "s")); CORRADE_COMPARE(state, data.state); } @@ -1267,7 +1268,7 @@ void ColorTest::tweakableErrorRgbaf() { std::ostringstream out; Warning redirectWarning{&out}; Error redirectError{&out}; - Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}).first; + Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse(input).first; CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366aa", "rgbaf", "")); CORRADE_COMPARE(state, data.state); } @@ -1280,7 +1281,7 @@ void ColorTest::tweakableErrorSrgbaf() { std::ostringstream out; Warning redirectWarning{&out}; Error redirectError{&out}; - Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse({input.data(), input.size()}).first; + Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse(input).first; CORRADE_COMPARE(out.str(), Corrade::Utility::formatString(data.error, "ff3366aa", "rgbaf", "s")); CORRADE_COMPARE(state, data.state); } diff --git a/src/Magnum/Math/Test/HalfTest.cpp b/src/Magnum/Math/Test/HalfTest.cpp index 188dda880..6fd750269 100644 --- a/src/Magnum/Math/Test/HalfTest.cpp +++ b/src/Magnum/Math/Test/HalfTest.cpp @@ -634,7 +634,7 @@ void HalfTest::tweakable() { setTestCaseDescription(data.name); Corrade::Utility::TweakableState state; Half result; - std::tie(state, result) = Corrade::Utility::TweakableParser::parse({data.data, std::strlen(data.data)}); + std::tie(state, result) = Corrade::Utility::TweakableParser::parse(data.data); CORRADE_COMPARE(state, Corrade::Utility::TweakableState::Success); CORRADE_COMPARE(result, data.result); } @@ -646,7 +646,7 @@ void HalfTest::tweakableError() { std::ostringstream out; Warning redirectWarning{&out}; Error redirectError{&out}; - Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse({data.data, std::strlen(data.data)}).first; + Corrade::Utility::TweakableState state = Corrade::Utility::TweakableParser::parse(data.data).first; CORRADE_COMPARE(out.str(), data.error); CORRADE_COMPARE(state, data.state); }