diff --git a/doc/changelog.dox b/doc/changelog.dox index 9291dc587..2df198489 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -308,6 +308,11 @@ See also: @subsection changelog-latest-compatibility Potential compatibility breakages, removed APIs +- Configuration value parsers and writers for @ref Math types were moved to + a dedicated @ref Magnum/Math/ConfigurationValue.h header in order to speed + up compile times. Backwards compatibility is not provided, when using + @ref Math types with @ref Corrade::Utility::Configuration or + @ref Corrade::Utility::Arguments you have to include the header explicitly - Removed all aliases to @ref GL library functionality in the root namespace (and root include path) which were deprecated in 2018.04 and everything related to this change: diff --git a/src/Magnum/Math/Angle.h b/src/Magnum/Math/Angle.h index 53ef87b4b..7f082c89f 100644 --- a/src/Magnum/Math/Angle.h +++ b/src/Magnum/Math/Angle.h @@ -252,36 +252,6 @@ extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utili namespace Corrade { namespace Utility { -/** @configurationvalue{Magnum::Math::Deg} */ -template struct ConfigurationValue> { - ConfigurationValue() = delete; - - /** @brief Writes degrees as a number */ - static std::string toString(const Magnum::Math::Deg& value, ConfigurationValueFlags flags) { - return ConfigurationValue::toString(T(value), flags); - } - - /** @brief Reads degrees as a number */ - static Magnum::Math::Deg fromString(const std::string& stringValue, ConfigurationValueFlags flags) { - return Magnum::Math::Deg(ConfigurationValue::fromString(stringValue, flags)); - } -}; - -/** @configurationvalue{Magnum::Math::Rad} */ -template struct ConfigurationValue> { - ConfigurationValue() = delete; - - /** @brief Writes degrees as a number */ - static std::string toString(const Magnum::Math::Rad& value, ConfigurationValueFlags flags) { - return ConfigurationValue::toString(T(value), flags); - } - - /** @brief Reads degrees as a number */ - static Magnum::Math::Rad fromString(const std::string& stringValue, ConfigurationValueFlags flags) { - return Magnum::Math::Rad(ConfigurationValue::fromString(stringValue, flags)); - } -}; - #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) /** @tweakableliteral{Magnum::Math::Deg} diff --git a/src/Magnum/Math/Bezier.h b/src/Magnum/Math/Bezier.h index 6eaf3f53b..2bc4b6a8a 100644 --- a/src/Magnum/Math/Bezier.h +++ b/src/Magnum/Math/Bezier.h @@ -337,60 +337,4 @@ template struct StrictWeakOr }} -namespace Corrade { namespace Utility { - -/** @configurationvalue{Magnum::Math::Bezier} */ -template struct ConfigurationValue> { - ConfigurationValue() = delete; - - /** @brief Writes elements separated with spaces */ - static std::string toString(const Magnum::Math::Bezier& value, ConfigurationValueFlags flags) { - std::string output; - - for(std::size_t o = 0; o != order + 1; ++o) { - for(std::size_t i = 0; i != dimensions; ++i) { - if(!output.empty()) output += ' '; - output += ConfigurationValue::toString(value[o][i], flags); - } - } - - return output; - } - - /** @brief Reads elements separated with whitespace */ - static Magnum::Math::Bezier fromString(const std::string& stringValue, ConfigurationValueFlags flags) { - Magnum::Math::Bezier result; - - std::size_t oldpos = 0, pos = std::string::npos, i = 0; - do { - pos = stringValue.find(' ', oldpos); - std::string part = stringValue.substr(oldpos, pos-oldpos); - - if(!part.empty()) { - result[i/dimensions][i%dimensions] = ConfigurationValue::fromString(part, flags); - ++i; - } - - oldpos = pos+1; - } while(pos != std::string::npos); - - return result; - } -}; - -/* Explicit instantiation for commonly used types */ -#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(__MINGW32__) -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; #endif - -}} - -#endif - diff --git a/src/Magnum/Math/CMakeLists.txt b/src/Magnum/Math/CMakeLists.txt index fa77b2b50..9f9471a70 100644 --- a/src/Magnum/Math/CMakeLists.txt +++ b/src/Magnum/Math/CMakeLists.txt @@ -30,6 +30,7 @@ set(MagnumMath_HEADERS Color.h Complex.h Constants.h + ConfigurationValue.h CubicHermite.h Distance.h Dual.h diff --git a/src/Magnum/Math/Color.h b/src/Magnum/Math/Color.h index f532ffb42..c6fef33c8 100644 --- a/src/Magnum/Math/Color.h +++ b/src/Magnum/Math/Color.h @@ -1221,12 +1221,6 @@ namespace Implementation { namespace Corrade { namespace Utility { -/** @configurationvalue{Magnum::Color3} */ -template struct ConfigurationValue>: ConfigurationValue> {}; - -/** @configurationvalue{Magnum::Color4} */ -template struct ConfigurationValue>: ConfigurationValue> {}; - #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) /** @tweakableliteral{Magnum::Math::Color3} diff --git a/src/Magnum/Math/Complex.h b/src/Magnum/Math/Complex.h index 2f0471189..ce3fff2ac 100644 --- a/src/Magnum/Math/Complex.h +++ b/src/Magnum/Math/Complex.h @@ -637,26 +637,4 @@ template struct StrictWeakOrdering> { }} -namespace Corrade { namespace Utility { - -/** @configurationvalue{Magnum::Math::Complex} */ -template struct ConfigurationValue> { - ConfigurationValue() = delete; - - /** @brief Writes elements separated with spaces */ - static std::string toString(const Magnum::Math::Complex& value, ConfigurationValueFlags flags) { - return ConfigurationValue>::toString(reinterpret_cast&>(value), flags); - } - - /** @brief Reads elements separated with whitespace */ - static Magnum::Math::Complex fromString(const std::string& stringValue, ConfigurationValueFlags flags) { - const Magnum::Math::Vector<2, T> value = ConfigurationValue>::fromString(stringValue, flags); - return reinterpret_cast&>(value); - } -}; - -/* No explicit instantiation needed, as Vector<2, T> is instantiated already */ - -}} - #endif diff --git a/src/Magnum/Math/ConfigurationValue.h b/src/Magnum/Math/ConfigurationValue.h new file mode 100644 index 000000000..bf69dc7f8 --- /dev/null +++ b/src/Magnum/Math/ConfigurationValue.h @@ -0,0 +1,392 @@ +#ifndef Magnum_Math_ConfigurationValue_h +#define Magnum_Math_ConfigurationValue_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/** @file + * @brief Configuration value parsers and writers for @ref Magnum::Math types + */ + +#include + +#include "Magnum/Math/Angle.h" +#include "Magnum/Math/Bezier.h" +#include "Magnum/Math/Color.h" +#include "Magnum/Math/Complex.h" +#include "Magnum/Math/DualComplex.h" +#include "Magnum/Math/DualQuaternion.h" +#include "Magnum/Math/Matrix.h" +#include "Magnum/Math/Matrix3.h" +#include "Magnum/Math/Matrix4.h" +#include "Magnum/Math/Range.h" +#include "Magnum/Math/RectangularMatrix.h" +#include "Magnum/Math/Quaternion.h" +#include "Magnum/Math/Vector.h" +#include "Magnum/Math/Vector2.h" +#include "Magnum/Math/Vector3.h" +#include "Magnum/Math/Vector4.h" + +namespace Corrade { namespace Utility { + +/** @configurationvalue{Magnum::Math::Deg} */ +template struct ConfigurationValue> { + ConfigurationValue() = delete; + + /** @brief Writes degrees as a number */ + static std::string toString(const Magnum::Math::Deg& value, ConfigurationValueFlags flags) { + return ConfigurationValue::toString(T(value), flags); + } + + /** @brief Reads degrees as a number */ + static Magnum::Math::Deg fromString(const std::string& stringValue, ConfigurationValueFlags flags) { + return Magnum::Math::Deg(ConfigurationValue::fromString(stringValue, flags)); + } +}; + +/** @configurationvalue{Magnum::Math::Rad} */ +template struct ConfigurationValue> { + ConfigurationValue() = delete; + + /** @brief Writes degrees as a number */ + static std::string toString(const Magnum::Math::Rad& value, ConfigurationValueFlags flags) { + return ConfigurationValue::toString(T(value), flags); + } + + /** @brief Reads degrees as a number */ + static Magnum::Math::Rad fromString(const std::string& stringValue, ConfigurationValueFlags flags) { + return Magnum::Math::Rad(ConfigurationValue::fromString(stringValue, flags)); + } +}; + +/** @configurationvalue{Magnum::Math::Vector} */ +template struct ConfigurationValue> { + ConfigurationValue() = delete; + + /** @brief Writes elements separated with spaces */ + static std::string toString(const Magnum::Math::Vector& value, ConfigurationValueFlags flags) { + std::string output; + + for(std::size_t i = 0; i != size; ++i) { + if(!output.empty()) output += ' '; + output += ConfigurationValue::toString(value[i], flags); + } + + return output; + } + + /** @brief Reads elements separated with whitespace */ + static Magnum::Math::Vector fromString(const std::string& stringValue, ConfigurationValueFlags flags) { + Magnum::Math::Vector result; + + std::size_t oldpos = 0, pos = std::string::npos, i = 0; + do { + pos = stringValue.find(' ', oldpos); + std::string part = stringValue.substr(oldpos, pos-oldpos); + + if(!part.empty()) { + result[i] = ConfigurationValue::fromString(part, flags); + ++i; + } + + oldpos = pos+1; + } while(pos != std::string::npos && i != size); + + return result; + } +}; + +/* Explicit instantiation for commonly used types */ +#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(__MINGW32__) +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +#endif + +/** @configurationvalue{Magnum::Math::Vector2} */ +template struct ConfigurationValue>: public ConfigurationValue> {}; + +/** @configurationvalue{Magnum::Math::Vector3} */ +template struct ConfigurationValue>: public ConfigurationValue> {}; + +/** @configurationvalue{Magnum::Math::Vector4} */ +template struct ConfigurationValue>: public ConfigurationValue> {}; + +/** @configurationvalue{Magnum::Color3} */ +template struct ConfigurationValue>: ConfigurationValue> {}; + +/** @configurationvalue{Magnum::Color4} */ +template struct ConfigurationValue>: ConfigurationValue> {}; + +/* No explicit instantiation for Vector[234] / Color[34] needed, as + Vector<2, T> / Vector<3, T> / Vector<4, T> is instantiated already */ + +/** @configurationvalue{Magnum::Math::RectangularMatrix} */ +template struct ConfigurationValue> { + ConfigurationValue() = delete; + + /** @brief Writes elements separated with spaces */ + static std::string toString(const Magnum::Math::RectangularMatrix& value, ConfigurationValueFlags flags) { + std::string output; + + for(std::size_t row = 0; row != rows; ++row) { + for(std::size_t col = 0; col != cols; ++col) { + if(!output.empty()) output += ' '; + output += ConfigurationValue::toString(value[col][row], flags); + } + } + + return output; + } + + /** @brief Reads elements separated with whitespace */ + static Magnum::Math::RectangularMatrix fromString(const std::string& stringValue, ConfigurationValueFlags flags) { + Magnum::Math::RectangularMatrix result; + + std::size_t oldpos = 0, pos = std::string::npos, i = 0; + do { + pos = stringValue.find(' ', oldpos); + std::string part = stringValue.substr(oldpos, pos-oldpos); + + if(!part.empty()) { + result[i%cols][i/cols] = ConfigurationValue::fromString(part, flags); + ++i; + } + + oldpos = pos+1; + } while(pos != std::string::npos && i != cols*rows); + + return result; + } +}; + +/* Explicit instantiation for commonly used types */ +#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(__MINGW32__) +/* Square matrices */ +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; + +/* Rectangular matrices */ +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +#endif + +/** @configurationvalue{Magnum::Math::Matrix} */ +template struct ConfigurationValue>: public ConfigurationValue> {}; + +/** @configurationvalue{Magnum::Math::Matrix3} */ +template struct ConfigurationValue>: public ConfigurationValue> {}; + +/** @configurationvalue{Magnum::Math::Matrix4} */ +template struct ConfigurationValue>: public ConfigurationValue> {}; + +/* No explicit instantiation for Matrix needed, as RectangularMatrix is + instantiated already */ + +/** @configurationvalue{Magnum::Math::Range} */ +template struct ConfigurationValue> { + ConfigurationValue() = delete; + + /** @brief Writes elements separated with spaces */ + static std::string toString(const Magnum::Math::Range& value, const ConfigurationValueFlags flags) { + return ConfigurationValue>::toString( + reinterpret_cast&>(value), flags); + } + + /** @brief Reads elements separated with whitespace */ + static Magnum::Math::Range fromString(const std::string& stringValue, const ConfigurationValueFlags flags) { + const auto vec = ConfigurationValue>::fromString(stringValue, flags); + return *reinterpret_cast*>(vec.data()); + } +}; + +/** @configurationvalue{Magnum::Math::Range2D} */ +template struct ConfigurationValue>: public ConfigurationValue> {}; + +/** @configurationvalue{Magnum::Math::Range3D} */ +template struct ConfigurationValue>: public ConfigurationValue> {}; + +/* Explicit instantiation for commonly used types */ +#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(__MINGW32__) +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +#endif + +/** @configurationvalue{Magnum::Math::Complex} */ +template struct ConfigurationValue> { + ConfigurationValue() = delete; + + /** @brief Writes elements separated with spaces */ + static std::string toString(const Magnum::Math::Complex& value, ConfigurationValueFlags flags) { + return ConfigurationValue>::toString(reinterpret_cast&>(value), flags); + } + + /** @brief Reads elements separated with whitespace */ + static Magnum::Math::Complex fromString(const std::string& stringValue, ConfigurationValueFlags flags) { + const Magnum::Math::Vector<2, T> value = ConfigurationValue>::fromString(stringValue, flags); + return reinterpret_cast&>(value); + } +}; + +/** @configurationvalue{Magnum::Math::DualComplex} */ +template struct ConfigurationValue> { + ConfigurationValue() = delete; + + /** @brief Writes elements separated with spaces */ + static std::string toString(const Magnum::Math::DualComplex& value, ConfigurationValueFlags flags) { + return ConfigurationValue>::toString(reinterpret_cast&>(value), flags); + } + + /** @brief Reads elements separated with whitespace */ + static Magnum::Math::DualComplex fromString(const std::string& stringValue, ConfigurationValueFlags flags) { + const Magnum::Math::Vector<4, T> value = ConfigurationValue>::fromString(stringValue, flags); + return reinterpret_cast&>(value); + } +}; + +/* No explicit instantiation for DualComplex needed, as Vector<4, T> is + instantiated already */ + +/** @configurationvalue{Magnum::Math::Quaternion} */ +template struct ConfigurationValue> { + ConfigurationValue() = delete; + + /** @brief Writes elements separated with spaces */ + static std::string toString(const Magnum::Math::Quaternion& value, ConfigurationValueFlags flags) { + return ConfigurationValue>::toString(reinterpret_cast&>(value), flags); + } + + /** @brief Reads elements separated with whitespace */ + static Magnum::Math::Quaternion fromString(const std::string& stringValue, ConfigurationValueFlags flags) { + const Magnum::Math::Vector<4, T> value = ConfigurationValue>::fromString(stringValue, flags); + return reinterpret_cast&>(value); + } +}; + +/* No explicit instantiation needed for Quaternion, as Vector<4, T> is + instantiated already */ + +/** @configurationvalue{Magnum::Math::DualQuaternion} */ +template struct ConfigurationValue> { + ConfigurationValue() = delete; + + /** @brief Writes elements separated with spaces */ + static std::string toString(const Magnum::Math::DualQuaternion& value, ConfigurationValueFlags flags) { + return ConfigurationValue>::toString(reinterpret_cast&>(value), flags); + } + + /** @brief Reads elements separated with whitespace */ + static Magnum::Math::DualQuaternion fromString(const std::string& stringValue, ConfigurationValueFlags flags) { + const Magnum::Math::Vector<8, T> value = ConfigurationValue>::fromString(stringValue, flags); + return reinterpret_cast&>(value); + } +}; + +/* Explicit instantiation for commonly used types */ +#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(__MINGW32__) +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +#endif + +/** @configurationvalue{Magnum::Math::Bezier} */ +template struct ConfigurationValue> { + ConfigurationValue() = delete; + + /** @brief Writes elements separated with spaces */ + static std::string toString(const Magnum::Math::Bezier& value, ConfigurationValueFlags flags) { + std::string output; + + for(std::size_t o = 0; o != order + 1; ++o) { + for(std::size_t i = 0; i != dimensions; ++i) { + if(!output.empty()) output += ' '; + output += ConfigurationValue::toString(value[o][i], flags); + } + } + + return output; + } + + /** @brief Reads elements separated with whitespace */ + static Magnum::Math::Bezier fromString(const std::string& stringValue, ConfigurationValueFlags flags) { + Magnum::Math::Bezier result; + + std::size_t oldpos = 0, pos = std::string::npos, i = 0; + do { + pos = stringValue.find(' ', oldpos); + std::string part = stringValue.substr(oldpos, pos-oldpos); + + if(!part.empty()) { + result[i/dimensions][i%dimensions] = ConfigurationValue::fromString(part, flags); + ++i; + } + + oldpos = pos+1; + } while(pos != std::string::npos); + + return result; + } +}; + +/* Explicit instantiation for commonly used types */ +#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(__MINGW32__) +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +#endif + +}} + +#endif diff --git a/src/Magnum/Math/DualComplex.h b/src/Magnum/Math/DualComplex.h index 6749997b3..edb4b7299 100644 --- a/src/Magnum/Math/DualComplex.h +++ b/src/Magnum/Math/DualComplex.h @@ -391,26 +391,4 @@ namespace Implementation { }} -namespace Corrade { namespace Utility { - -/** @configurationvalue{Magnum::Math::DualComplex} */ -template struct ConfigurationValue> { - ConfigurationValue() = delete; - - /** @brief Writes elements separated with spaces */ - static std::string toString(const Magnum::Math::DualComplex& value, ConfigurationValueFlags flags) { - return ConfigurationValue>::toString(reinterpret_cast&>(value), flags); - } - - /** @brief Reads elements separated with whitespace */ - static Magnum::Math::DualComplex fromString(const std::string& stringValue, ConfigurationValueFlags flags) { - const Magnum::Math::Vector<4, T> value = ConfigurationValue>::fromString(stringValue, flags); - return reinterpret_cast&>(value); - } -}; - -/* No explicit instantiation needed, as Vector<4, T> is instantiated already */ - -}} - #endif diff --git a/src/Magnum/Math/DualQuaternion.h b/src/Magnum/Math/DualQuaternion.h index 0ab48e530..437a5f692 100644 --- a/src/Magnum/Math/DualQuaternion.h +++ b/src/Magnum/Math/DualQuaternion.h @@ -551,30 +551,4 @@ namespace Implementation { }} -namespace Corrade { namespace Utility { - -/** @configurationvalue{Magnum::Math::DualQuaternion} */ -template struct ConfigurationValue> { - ConfigurationValue() = delete; - - /** @brief Writes elements separated with spaces */ - static std::string toString(const Magnum::Math::DualQuaternion& value, ConfigurationValueFlags flags) { - return ConfigurationValue>::toString(reinterpret_cast&>(value), flags); - } - - /** @brief Reads elements separated with whitespace */ - static Magnum::Math::DualQuaternion fromString(const std::string& stringValue, ConfigurationValueFlags flags) { - const Magnum::Math::Vector<8, T> value = ConfigurationValue>::fromString(stringValue, flags); - return reinterpret_cast&>(value); - } -}; - -/* Explicit instantiation for commonly used types */ -#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(__MINGW32__) -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -#endif - -}} - #endif diff --git a/src/Magnum/Math/Matrix.h b/src/Magnum/Math/Matrix.h index c86f6fe88..c26e42113 100644 --- a/src/Magnum/Math/Matrix.h +++ b/src/Magnum/Math/Matrix.h @@ -360,9 +360,4 @@ template Matrix Matrix::inverted() }} -namespace Corrade { namespace Utility { - /** @configurationvalue{Magnum::Math::Matrix} */ - template struct ConfigurationValue>: public ConfigurationValue> {}; -}} - #endif diff --git a/src/Magnum/Math/Matrix3.h b/src/Magnum/Math/Matrix3.h index 06adf567b..e08691e37 100644 --- a/src/Magnum/Math/Matrix3.h +++ b/src/Magnum/Math/Matrix3.h @@ -698,9 +698,4 @@ namespace Implementation { }} -namespace Corrade { namespace Utility { - /** @configurationvalue{Magnum::Math::Matrix3} */ - template struct ConfigurationValue>: public ConfigurationValue> {}; -}} - #endif diff --git a/src/Magnum/Math/Matrix4.h b/src/Magnum/Math/Matrix4.h index 23e7049b5..d7336b80c 100644 --- a/src/Magnum/Math/Matrix4.h +++ b/src/Magnum/Math/Matrix4.h @@ -1030,9 +1030,4 @@ namespace Implementation { }} -namespace Corrade { namespace Utility { - /** @configurationvalue{Magnum::Math::Matrix4} */ - template struct ConfigurationValue>: public ConfigurationValue> {}; -}} - #endif diff --git a/src/Magnum/Math/Quaternion.h b/src/Magnum/Math/Quaternion.h index a2b360736..d49dbd089 100644 --- a/src/Magnum/Math/Quaternion.h +++ b/src/Magnum/Math/Quaternion.h @@ -757,26 +757,4 @@ template struct StrictWeakOrdering> { }} -namespace Corrade { namespace Utility { - -/** @configurationvalue{Magnum::Math::Quaternion} */ -template struct ConfigurationValue> { - ConfigurationValue() = delete; - - /** @brief Writes elements separated with spaces */ - static std::string toString(const Magnum::Math::Quaternion& value, ConfigurationValueFlags flags) { - return ConfigurationValue>::toString(reinterpret_cast&>(value), flags); - } - - /** @brief Reads elements separated with whitespace */ - static Magnum::Math::Quaternion fromString(const std::string& stringValue, ConfigurationValueFlags flags) { - const Magnum::Math::Vector<4, T> value = ConfigurationValue>::fromString(stringValue, flags); - return reinterpret_cast&>(value); - } -}; - -/* No explicit instantiation needed, as Vector<4, T> is instantiated already */ - -}} - #endif diff --git a/src/Magnum/Math/Range.h b/src/Magnum/Math/Range.h index 4f2200151..b6d187d4a 100644 --- a/src/Magnum/Math/Range.h +++ b/src/Magnum/Math/Range.h @@ -773,41 +773,4 @@ template struct StrictWeakOrdering struct ConfigurationValue> { - ConfigurationValue() = delete; - - /** @brief Writes elements separated with spaces */ - static std::string toString(const Magnum::Math::Range& value, const ConfigurationValueFlags flags) { - return ConfigurationValue>::toString( - reinterpret_cast&>(value), flags); - } - - /** @brief Reads elements separated with whitespace */ - static Magnum::Math::Range fromString(const std::string& stringValue, const ConfigurationValueFlags flags) { - const auto vec = ConfigurationValue>::fromString(stringValue, flags); - return *reinterpret_cast*>(vec.data()); - } -}; - -/** @configurationvalue{Magnum::Math::Range2D} */ -template struct ConfigurationValue>: public ConfigurationValue> {}; - -/** @configurationvalue{Magnum::Math::Range3D} */ -template struct ConfigurationValue>: public ConfigurationValue> {}; - -/* Explicit instantiation for commonly used types */ -#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(__MINGW32__) -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -#endif - -}} - #endif diff --git a/src/Magnum/Math/RectangularMatrix.h b/src/Magnum/Math/RectangularMatrix.h index ed0dff6da..cb15e2ac1 100644 --- a/src/Magnum/Math/RectangularMatrix.h +++ b/src/Magnum/Math/RectangularMatrix.h @@ -773,72 +773,4 @@ template struct StrictWeakOrdering< }} -namespace Corrade { namespace Utility { - -/** @configurationvalue{Magnum::Math::RectangularMatrix} */ -template struct ConfigurationValue> { - ConfigurationValue() = delete; - - /** @brief Writes elements separated with spaces */ - static std::string toString(const Magnum::Math::RectangularMatrix& value, ConfigurationValueFlags flags) { - std::string output; - - for(std::size_t row = 0; row != rows; ++row) { - for(std::size_t col = 0; col != cols; ++col) { - if(!output.empty()) output += ' '; - output += ConfigurationValue::toString(value[col][row], flags); - } - } - - return output; - } - - /** @brief Reads elements separated with whitespace */ - static Magnum::Math::RectangularMatrix fromString(const std::string& stringValue, ConfigurationValueFlags flags) { - Magnum::Math::RectangularMatrix result; - - std::size_t oldpos = 0, pos = std::string::npos, i = 0; - do { - pos = stringValue.find(' ', oldpos); - std::string part = stringValue.substr(oldpos, pos-oldpos); - - if(!part.empty()) { - result[i%cols][i/cols] = ConfigurationValue::fromString(part, flags); - ++i; - } - - oldpos = pos+1; - } while(pos != std::string::npos && i != cols*rows); - - return result; - } -}; - -/* Explicit instantiation for commonly used types */ -#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(__MINGW32__) -/* Square matrices */ -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; - -/* Rectangular matrices */ -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -#endif - -}} - #endif diff --git a/src/Magnum/Math/Test/AngleTest.cpp b/src/Magnum/Math/Test/AngleTest.cpp index 643c70ca6..b3d5563da 100644 --- a/src/Magnum/Math/Test/AngleTest.cpp +++ b/src/Magnum/Math/Test/AngleTest.cpp @@ -27,7 +27,6 @@ #include #include #include -#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 @@ -51,8 +50,6 @@ struct AngleTest: Corrade::TestSuite::Tester { void debugDeg(); void debugRad(); - void configurationDeg(); - void configurationRad(); #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) template void tweakable(); template void tweakableError(); @@ -125,9 +122,7 @@ AngleTest::AngleTest() { &AngleTest::conversion, &AngleTest::debugDeg, - &AngleTest::debugRad, - &AngleTest::configurationDeg, - &AngleTest::configurationRad}); + &AngleTest::debugRad}); #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) addInstancedTests({ @@ -286,28 +281,6 @@ void AngleTest::debugRad() { CORRADE_COMPARE(o.str(), "Rad(-1.5708)\n"); } -void AngleTest::configurationDeg() { - Corrade::Utility::Configuration c; - - Deg angle{25.3f}; - std::string value("25.3"); - - c.setValue("angle", angle); - CORRADE_COMPARE(c.value("angle"), value); - CORRADE_COMPARE(c.value("angle"), angle); -} - -void AngleTest::configurationRad() { - Corrade::Utility::Configuration c; - - Rad angle{3.14159f}; - std::string value("3.14159"); - - c.setValue("angle", angle); - CORRADE_COMPARE(c.value("angle"), value); - CORRADE_COMPARE(c.value("angle"), angle); -} - #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) template void AngleTest::tweakable() { auto&& data = TweakableData[testCaseInstanceId()]; diff --git a/src/Magnum/Math/Test/BezierTest.cpp b/src/Magnum/Math/Test/BezierTest.cpp index 4e7860ee0..aaddcaf8f 100644 --- a/src/Magnum/Math/Test/BezierTest.cpp +++ b/src/Magnum/Math/Test/BezierTest.cpp @@ -26,7 +26,6 @@ #include #include -#include #include "Magnum/Math/Bezier.h" #include "Magnum/Math/CubicHermite.h" @@ -89,7 +88,6 @@ struct BezierTest: Corrade::TestSuite::Tester { void strictWeakOrdering(); void debug(); - void configuration(); }; BezierTest::BezierTest() { @@ -114,8 +112,7 @@ BezierTest::BezierTest() { &BezierTest::strictWeakOrdering, - &BezierTest::debug, - &BezierTest::configuration}); + &BezierTest::debug}); } void BezierTest::construct() { @@ -338,17 +335,6 @@ void BezierTest::debug() { CORRADE_COMPARE(out.str(), "Bezier({0, 1}, {1.5, -0.3}, {2.1, 0.5}, {0, 2})\n"); } -void BezierTest::configuration() { - Corrade::Utility::Configuration c; - - CubicBezier2D bezier{Vector2{0.0f, 1.0f}, Vector2{1.5f, -0.3f}, Vector2{2.1f, 0.5f}, Vector2{0.0f, 2.0f}}; - std::string value("0 1 1.5 -0.3 2.1 0.5 0 2"); - - c.setValue("bezier", bezier); - CORRADE_COMPARE(c.value("bezier"), value); - CORRADE_COMPARE(c.value("bezier"), bezier); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::BezierTest) diff --git a/src/Magnum/Math/Test/CMakeLists.txt b/src/Magnum/Math/Test/CMakeLists.txt index 151e95c7d..0eabb7995 100644 --- a/src/Magnum/Math/Test/CMakeLists.txt +++ b/src/Magnum/Math/Test/CMakeLists.txt @@ -63,6 +63,7 @@ corrade_add_test(MathIntersectionBenchmark IntersectionBenchmark.cpp LIBRARIES M corrade_add_test(MathInterpolationBenchmark InterpolationBenchmark.cpp LIBRARIES MagnumMathTestLib) +corrade_add_test(MathConfigurationValueTest ConfigurationValueTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathStrictWeakOrderingTest StrictWeakOrderingTest.cpp LIBRARIES MagnumMathTestLib) set_property(TARGET @@ -119,5 +120,6 @@ set_target_properties( MathIntersectionTest MathIntersectionBenchmark + MathConfigurationValueTest MathStrictWeakOrderingTest PROPERTIES FOLDER "Magnum/Math/Test") diff --git a/src/Magnum/Math/Test/ColorTest.cpp b/src/Magnum/Math/Test/ColorTest.cpp index 22a3f7cc9..d98701765 100644 --- a/src/Magnum/Math/Test/ColorTest.cpp +++ b/src/Magnum/Math/Test/ColorTest.cpp @@ -26,7 +26,6 @@ #include #include #include -#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 @@ -115,7 +114,6 @@ struct ColorTest: Corrade::TestSuite::Tester { void swizzleType(); void debug(); void debugUb(); - void configuration(); #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) void tweakableRgb(); @@ -229,8 +227,7 @@ ColorTest::ColorTest() { &ColorTest::swizzleType, &ColorTest::debug, - &ColorTest::debugUb, - &ColorTest::configuration}); + &ColorTest::debugUb}); #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) addInstancedTests({&ColorTest::tweakableRgb, @@ -927,24 +924,6 @@ void ColorTest::debugUb() { CORRADE_COMPARE(o.str(), "#12345678 #90abcdef\n"); } -void ColorTest::configuration() { - Corrade::Utility::Configuration c; - - Color3 color3(0.5f, 0.75f, 1.0f); - std::string value3("0.5 0.75 1"); - - c.setValue("color3", color3); - CORRADE_COMPARE(c.value("color3"), value3); - CORRADE_COMPARE(c.value("color3"), color3); - - Color4 color4(0.5f, 0.75f, 0.0f, 1.0f); - std::string value4("0.5 0.75 0 1"); - - c.setValue("color4", color4); - CORRADE_COMPARE(c.value("color4"), value4); - CORRADE_COMPARE(c.value("color4"), color4); -} - #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) void ColorTest::tweakableRgb() { auto&& data = TweakableData[testCaseInstanceId()]; diff --git a/src/Magnum/Math/Test/ComplexTest.cpp b/src/Magnum/Math/Test/ComplexTest.cpp index 351debff5..4113734b7 100644 --- a/src/Magnum/Math/Test/ComplexTest.cpp +++ b/src/Magnum/Math/Test/ComplexTest.cpp @@ -25,7 +25,6 @@ #include #include -#include #include "Magnum/Math/Complex.h" #include "Magnum/Math/Matrix3.h" @@ -102,7 +101,6 @@ struct ComplexTest: Corrade::TestSuite::Tester { void strictWeakOrdering(); void debug(); - void configuration(); }; ComplexTest::ComplexTest() { @@ -155,8 +153,7 @@ ComplexTest::ComplexTest() { &ComplexTest::strictWeakOrdering, - &ComplexTest::debug, - &ComplexTest::configuration}); + &ComplexTest::debug}); } typedef Math::Deg Deg; @@ -556,25 +553,6 @@ void ComplexTest::debug() { CORRADE_COMPARE(o.str(), "Complex(2.5, -7.5)\n"); } -void ComplexTest::configuration() { - Corrade::Utility::Configuration c; - - Complex x{3.0f, 3.125f}; - std::string value{"3 3.125"}; - - c.setValue("complex", x); - CORRADE_COMPARE(c.value("complex"), value); - CORRADE_COMPARE(c.value("complex"), x); - - /* Underflow */ - c.setValue("underflow", "2.1"); - CORRADE_COMPARE(c.value("underflow"), (Complex{2.1f, 0.0f})); - - /* Overflow */ - c.setValue("overflow", "2 9 16 33"); - CORRADE_COMPARE(c.value("overflow"), (Complex{2.0f, 9.0f})); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::ComplexTest) diff --git a/src/Magnum/Math/Test/ConfigurationValueTest.cpp b/src/Magnum/Math/Test/ConfigurationValueTest.cpp new file mode 100644 index 000000000..b83442355 --- /dev/null +++ b/src/Magnum/Math/Test/ConfigurationValueTest.cpp @@ -0,0 +1,383 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include +#include + +#include "Magnum/Math/ConfigurationValue.h" + +namespace Magnum { namespace Math { namespace Test { namespace { + +struct ConfigurationValueTest: Corrade::TestSuite::Tester { + explicit ConfigurationValueTest(); + + void deg(); + void rad(); + + void vector(); + void vector2(); + void vector3(); + void vector4(); + void color(); + + void rectangularMatrix(); + void matrix(); + void matrix3(); + void matrix4(); + + void range(); + + void complex(); + void dualComplex(); + void quaternion(); + void dualQuaternion(); + + void bezier(); +}; + +ConfigurationValueTest::ConfigurationValueTest() { + addTests({&ConfigurationValueTest::deg, + &ConfigurationValueTest::rad, + + &ConfigurationValueTest::vector, + &ConfigurationValueTest::vector2, + &ConfigurationValueTest::vector3, + &ConfigurationValueTest::vector4, + &ConfigurationValueTest::color, + + &ConfigurationValueTest::rectangularMatrix, + &ConfigurationValueTest::matrix, + &ConfigurationValueTest::matrix3, + &ConfigurationValueTest::matrix4, + + &ConfigurationValueTest::range, + + &ConfigurationValueTest::complex, + &ConfigurationValueTest::dualComplex, + &ConfigurationValueTest::quaternion, + &ConfigurationValueTest::dualQuaternion, + + &ConfigurationValueTest::bezier}); +} + +void ConfigurationValueTest::deg() { + typedef Math::Deg Deg; + + Corrade::Utility::Configuration c; + + Deg angle{25.3f}; + std::string value("25.3"); + + c.setValue("angle", angle); + CORRADE_COMPARE(c.value("angle"), value); + CORRADE_COMPARE(c.value("angle"), angle); +} + +void ConfigurationValueTest::rad() { + typedef Math::Rad Rad; + + Corrade::Utility::Configuration c; + + Rad angle{3.14159f}; + std::string value("3.14159"); + + c.setValue("angle", angle); + CORRADE_COMPARE(c.value("angle"), value); + CORRADE_COMPARE(c.value("angle"), angle); +} + +void ConfigurationValueTest::vector() { + typedef Vector<4, Float> Vector4; + + Corrade::Utility::Configuration c; + + Vector4 vec(3.0f, 3.125f, 9.0f, 9.55f); + std::string value("3 3.125 9 9.55"); + + c.setValue("vector", vec); + CORRADE_COMPARE(c.value("vector"), value); + CORRADE_COMPARE(c.value("vector"), vec); + + /* Underflow */ + c.setValue("underflow", "2.1 8.9"); + CORRADE_COMPARE(c.value("underflow"), (Vector4{2.1f, 8.9f, 0.0f, 0.0f})); + + /* Overflow */ + c.setValue("overflow", "2 1 8 9 16 33"); + CORRADE_COMPARE(c.value("overflow"), (Vector4{2.0f, 1.0f, 8.0f, 9.0f})); +} + +void ConfigurationValueTest::vector2() { + typedef Math::Vector2 Vector2; + + Corrade::Utility::Configuration c; + + Vector2 vec(3.125f, 9.0f); + std::string value("3.125 9"); + + c.setValue("vector", vec); + CORRADE_COMPARE(c.value("vector"), value); + CORRADE_COMPARE(c.value("vector"), vec); +} + +void ConfigurationValueTest::vector3() { + typedef Math::Vector3 Vector3; + + Corrade::Utility::Configuration c; + + Vector3 vec(3.0f, 3.125f, 9.55f); + std::string value("3 3.125 9.55"); + + c.setValue("vector", vec); + CORRADE_COMPARE(c.value("vector"), value); + CORRADE_COMPARE(c.value("vector"), vec); +} + +void ConfigurationValueTest::vector4() { + typedef Math::Vector4 Vector4; + + Corrade::Utility::Configuration c; + + Vector4 vec(3.0f, 3.125f, 9.0f, 9.55f); + std::string value("3 3.125 9 9.55"); + + c.setValue("vector", vec); + CORRADE_COMPARE(c.value("vector"), value); + CORRADE_COMPARE(c.value("vector"), vec); +} + +void ConfigurationValueTest::color() { + typedef Math::Color3 Color3; + typedef Math::Color4 Color4; + + Corrade::Utility::Configuration c; + + Color3 color3(0.5f, 0.75f, 1.0f); + std::string value3("0.5 0.75 1"); + + c.setValue("color3", color3); + CORRADE_COMPARE(c.value("color3"), value3); + CORRADE_COMPARE(c.value("color3"), color3); + + Color4 color4(0.5f, 0.75f, 0.0f, 1.0f); + std::string value4("0.5 0.75 0 1"); + + c.setValue("color4", color4); + CORRADE_COMPARE(c.value("color4"), value4); + CORRADE_COMPARE(c.value("color4"), color4); +} + +void ConfigurationValueTest::rectangularMatrix() { + typedef Math::Vector4 Vector4; + typedef Math::Matrix3x4 Matrix3x4; + + Matrix3x4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f), + Vector4(4.0f, 4.0f, 7.0f, 3.125f), + Vector4(7.0f, -1.0f, 8.0f, 9.55f)); + std::string value("3 4 7 5 4 -1 8 7 8 4 3.125 9.55"); + + Corrade::Utility::Configuration c; + c.setValue("matrix", m); + + CORRADE_COMPARE(c.value("matrix"), value); + CORRADE_COMPARE(c.value("matrix"), m); + + /* Underflow */ + c.setValue("underflow", "2.1 8.9 1.3 1 5 7 1.5"); + CORRADE_COMPARE(c.value("underflow"), (Matrix3x4{ + Vector4{2.1f, 1.0f, 1.5f, 0.0f}, + Vector4{8.9f, 5.0f, 0.0f, 0.0f}, + Vector4{1.3f, 7.0f, 0.0f, 0.0f}})); + + /* Overflow */ + c.setValue("overflow", "2 1 8 9 1 3 1 5 7 1 6 3 3 1.5 23 17"); + CORRADE_COMPARE(c.value("overflow"), (Matrix3x4{ + Vector4{2.0f, 9.0f, 1.0f, 1.0f}, + Vector4{1.0f, 1.0f, 5.0f, 6.0f}, + Vector4{8.0f, 3.0f, 7.0f, 3.0f}})); +} + +void ConfigurationValueTest::matrix() { + typedef Math::Vector4 Vector4; + typedef Math::Matrix4x4 Matrix4x4; + + Corrade::Utility::Configuration c; + + Matrix4x4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f), + Vector4(4.0f, 4.0f, 7.0f, 3.125f), + Vector4(7.0f, -1.0f, 8.0f, 0.0f), + Vector4(9.0f, 4.0f, 5.0f, 9.55f)); + std::string value("3 4 7 9 5 4 -1 4 8 7 8 5 4 3.125 0 9.55"); + + c.setValue("matrix", m); + CORRADE_COMPARE(c.value("matrix"), value); + CORRADE_COMPARE(c.value("matrix"), m); +} + +void ConfigurationValueTest::matrix3() { + typedef Math::Matrix3 Matrix3; + + Corrade::Utility::Configuration c; + + Matrix3 m({5.0f, 8.0f, 4.0f}, + {4.0f, 7.0f, 3.125f}, + {4.0f, 5.0f, 9.55f}); + std::string value("5 4 4 8 7 5 4 3.125 9.55"); + + c.setValue("matrix", m); + CORRADE_COMPARE(c.value("matrix"), value); + CORRADE_COMPARE(c.value("matrix"), m); +} + +void ConfigurationValueTest::matrix4() { + typedef Math::Matrix4 Matrix4; + + Corrade::Utility::Configuration c; + + Matrix4 m({3.0f, 5.0f, 8.0f, 4.0f}, + {4.0f, 4.0f, 7.0f, 3.125f}, + {7.0f, -1.0f, 8.0f, 0.0f}, + {9.0f, 4.0f, 5.0f, 9.55f}); + std::string value("3 4 7 9 5 4 -1 4 8 7 8 5 4 3.125 0 9.55"); + + c.setValue("matrix", m); + CORRADE_COMPARE(c.value("matrix"), value); + CORRADE_COMPARE(c.value("matrix"), m); +} + +void ConfigurationValueTest::complex() { + typedef Math::Complex Complex; + + Corrade::Utility::Configuration c; + + Complex x{3.0f, 3.125f}; + std::string value{"3 3.125"}; + + c.setValue("complex", x); + CORRADE_COMPARE(c.value("complex"), value); + CORRADE_COMPARE(c.value("complex"), x); + + /* Underflow */ + c.setValue("underflow", "2.1"); + CORRADE_COMPARE(c.value("underflow"), (Complex{2.1f, 0.0f})); + + /* Overflow */ + c.setValue("overflow", "2 9 16 33"); + CORRADE_COMPARE(c.value("overflow"), (Complex{2.0f, 9.0f})); +} + +void ConfigurationValueTest::dualComplex() { + typedef Math::DualComplex DualComplex; + + Corrade::Utility::Configuration c; + + DualComplex a{{3.0f, 3.125f}, {9.0f, 9.55f}}; + std::string value("3 3.125 9 9.55"); + + c.setValue("dualcomplex", a); + CORRADE_COMPARE(c.value("dualcomplex"), value); + CORRADE_COMPARE(c.value("dualcomplex"), a); + + /* Underflow */ + c.setValue("underflow", "2.1 8.9"); + CORRADE_COMPARE(c.value("underflow"), (DualComplex{{2.1f, 8.9f}, {0.0f, 0.0f}})); + + /* Overflow */ + c.setValue("overflow", "2 1 8 9 16 33"); + CORRADE_COMPARE(c.value("overflow"), (DualComplex{{2.0f, 1.0f}, {8.0f, 9.0f}})); +} + +void ConfigurationValueTest::quaternion() { + typedef Math::Quaternion Quaternion; + + Corrade::Utility::Configuration c; + + Quaternion q{{3.0f, 3.125f, 9.0f}, 9.55f}; + std::string value{"3 3.125 9 9.55"}; + + c.setValue("quat", q); + CORRADE_COMPARE(c.value("quat"), value); + CORRADE_COMPARE(c.value("quat"), q); + + /* Underflow */ + c.setValue("underflow", "2.1 8.9"); + CORRADE_COMPARE(c.value("underflow"), (Quaternion{{2.1f, 8.9f, 0.0f}, 0.0f})); + + /* Overflow */ + c.setValue("overflow", "2 1 8 9 16 33"); + CORRADE_COMPARE(c.value("overflow"), (Quaternion{{2.0f, 1.0f, 8.0f}, 9.0f})); +} + +void ConfigurationValueTest::dualQuaternion() { + typedef Math::DualQuaternion DualQuaternion; + + Corrade::Utility::Configuration c; + + DualQuaternion a{{{3.0f, 3.125f, 9.0f}, 9.55f}, {{-1.2f, 0.3f, 1.1f}, 92.05f}}; + std::string value{"3 3.125 9 9.55 -1.2 0.3 1.1 92.05"}; + + c.setValue("dualquat", a); + CORRADE_COMPARE(c.value("dualquat"), value); + CORRADE_COMPARE(c.value("dualquat"), a); + + /* Underflow */ + c.setValue("underflow", "2.1 8.9"); + CORRADE_COMPARE(c.value("underflow"), (DualQuaternion{{{2.1f, 8.9f, 0.0f}, 0.0f}, {{0.0f, 0.0f, 0.0f}, 0.0f}})); + + /* Overflow */ + c.setValue("overflow", "2 1 8 9 16 33 -1 5 2 10"); + CORRADE_COMPARE(c.value("overflow"), (DualQuaternion{{{2.0f, 1.0f, 8.0f}, 9.0f}, {{16.0f, 33.0f, -1.0f}, 5.0f}})); +} + +void ConfigurationValueTest::range() { + typedef Math::Range2D Range2D; + + Corrade::Utility::Configuration c; + + Range2D rect({3.0f, 3.125f}, {9.0f, 9.55f}); + std::string value("3 3.125 9 9.55"); + + c.setValue("rectangle", rect); + CORRADE_COMPARE(c.value("rectangle"), value); + CORRADE_COMPARE(c.value("rectangle"), rect); +} + +void ConfigurationValueTest::bezier() { + typedef Math::Vector2 Vector2; + typedef Math::CubicBezier2D CubicBezier2D; + + Corrade::Utility::Configuration c; + + CubicBezier2D bezier{Vector2{0.0f, 1.0f}, Vector2{1.5f, -0.3f}, Vector2{2.1f, 0.5f}, Vector2{0.0f, 2.0f}}; + std::string value("0 1 1.5 -0.3 2.1 0.5 0 2"); + + c.setValue("bezier", bezier); + CORRADE_COMPARE(c.value("bezier"), value); + CORRADE_COMPARE(c.value("bezier"), bezier); +} + +}}}} + +CORRADE_TEST_MAIN(Magnum::Math::Test::ConfigurationValueTest) diff --git a/src/Magnum/Math/Test/DualComplexTest.cpp b/src/Magnum/Math/Test/DualComplexTest.cpp index c8a529014..390a9575d 100644 --- a/src/Magnum/Math/Test/DualComplexTest.cpp +++ b/src/Magnum/Math/Test/DualComplexTest.cpp @@ -25,7 +25,6 @@ #include #include -#include #include "Magnum/Math/DualComplex.h" #include "Magnum/Math/DualQuaternion.h" @@ -95,7 +94,6 @@ struct DualComplexTest: Corrade::TestSuite::Tester { void strictWeakOrdering(); void debug(); - void configuration(); }; using namespace Math::Literals; @@ -152,8 +150,7 @@ DualComplexTest::DualComplexTest() { &DualComplexTest::strictWeakOrdering, - &DualComplexTest::debug, - &DualComplexTest::configuration}); + &DualComplexTest::debug}); } void DualComplexTest::construct() { @@ -470,25 +467,6 @@ void DualComplexTest::debug() { CORRADE_COMPARE(o.str(), "DualComplex({-1, -2.5}, {-3, -7.5})\n"); } -void DualComplexTest::configuration() { - Corrade::Utility::Configuration c; - - DualComplex a{{3.0f, 3.125f}, {9.0f, 9.55f}}; - std::string value("3 3.125 9 9.55"); - - c.setValue("dualcomplex", a); - CORRADE_COMPARE(c.value("dualcomplex"), value); - CORRADE_COMPARE(c.value("dualcomplex"), a); - - /* Underflow */ - c.setValue("underflow", "2.1 8.9"); - CORRADE_COMPARE(c.value("underflow"), (DualComplex{{2.1f, 8.9f}, {0.0f, 0.0f}})); - - /* Overflow */ - c.setValue("overflow", "2 1 8 9 16 33"); - CORRADE_COMPARE(c.value("overflow"), (DualComplex{{2.0f, 1.0f}, {8.0f, 9.0f}})); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::DualComplexTest) diff --git a/src/Magnum/Math/Test/DualQuaternionTest.cpp b/src/Magnum/Math/Test/DualQuaternionTest.cpp index c8f41a9e7..82a2c08f2 100644 --- a/src/Magnum/Math/Test/DualQuaternionTest.cpp +++ b/src/Magnum/Math/Test/DualQuaternionTest.cpp @@ -25,7 +25,6 @@ #include #include -#include #include "Magnum/Math/DualQuaternion.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -102,7 +101,6 @@ struct DualQuaternionTest: Corrade::TestSuite::Tester { void strictWeakOrdering(); void debug(); - void configuration(); }; typedef Math::Deg Deg; @@ -164,8 +162,7 @@ DualQuaternionTest::DualQuaternionTest() { &DualQuaternionTest::strictWeakOrdering, - &DualQuaternionTest::debug, - &DualQuaternionTest::configuration}); + &DualQuaternionTest::debug}); } void DualQuaternionTest::construct() { @@ -645,25 +642,6 @@ void DualQuaternionTest::debug() { CORRADE_COMPARE(o.str(), "DualQuaternion({{1, 2, 3}, -4}, {{0.5, -3.1, 3.3}, 2})\n"); } -void DualQuaternionTest::configuration() { - Corrade::Utility::Configuration c; - - DualQuaternion a{{{3.0f, 3.125f, 9.0f}, 9.55f}, {{-1.2f, 0.3f, 1.1f}, 92.05f}}; - std::string value{"3 3.125 9 9.55 -1.2 0.3 1.1 92.05"}; - - c.setValue("dualquat", a); - CORRADE_COMPARE(c.value("dualquat"), value); - CORRADE_COMPARE(c.value("dualquat"), a); - - /* Underflow */ - c.setValue("underflow", "2.1 8.9"); - CORRADE_COMPARE(c.value("underflow"), (DualQuaternion{{{2.1f, 8.9f, 0.0f}, 0.0f}, {{0.0f, 0.0f, 0.0f}, 0.0f}})); - - /* Overflow */ - c.setValue("overflow", "2 1 8 9 16 33 -1 5 2 10"); - CORRADE_COMPARE(c.value("overflow"), (DualQuaternion{{{2.0f, 1.0f, 8.0f}, 9.0f}, {{16.0f, 33.0f, -1.0f}, 5.0f}})); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::DualQuaternionTest) diff --git a/src/Magnum/Math/Test/Matrix3Test.cpp b/src/Magnum/Math/Test/Matrix3Test.cpp index c68dbd2b3..22a2321ce 100644 --- a/src/Magnum/Math/Test/Matrix3Test.cpp +++ b/src/Magnum/Math/Test/Matrix3Test.cpp @@ -25,7 +25,6 @@ #include #include -#include #include "Magnum/Math/Matrix3.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -100,7 +99,6 @@ struct Matrix3Test: Corrade::TestSuite::Tester { void strictWeakOrdering(); void debug(); - void configuration(); }; typedef Math::Deg Deg; @@ -150,8 +148,7 @@ Matrix3Test::Matrix3Test() { &Matrix3Test::strictWeakOrdering, - &Matrix3Test::debug, - &Matrix3Test::configuration}); + &Matrix3Test::debug}); } using namespace Literals; @@ -626,19 +623,6 @@ void Matrix3Test::debug() { " 8, 7, 8)\n"); } -void Matrix3Test::configuration() { - Corrade::Utility::Configuration c; - - Matrix3 m({5.0f, 8.0f, 4.0f}, - {4.0f, 7.0f, 3.125f}, - {4.0f, 5.0f, 9.55f}); - std::string value("5 4 4 8 7 5 4 3.125 9.55"); - - c.setValue("matrix", m); - CORRADE_COMPARE(c.value("matrix"), value); - CORRADE_COMPARE(c.value("matrix"), m); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::Matrix3Test) diff --git a/src/Magnum/Math/Test/Matrix4Test.cpp b/src/Magnum/Math/Test/Matrix4Test.cpp index f6a46334d..7eee0322e 100644 --- a/src/Magnum/Math/Test/Matrix4Test.cpp +++ b/src/Magnum/Math/Test/Matrix4Test.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include "Magnum/Math/Matrix4.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -114,7 +113,6 @@ struct Matrix4Test: Corrade::TestSuite::Tester { void strictWeakOrdering(); void debug(); - void configuration(); }; typedef Math::Deg Deg; @@ -179,8 +177,7 @@ Matrix4Test::Matrix4Test() { &Matrix4Test::strictWeakOrdering, - &Matrix4Test::debug, - &Matrix4Test::configuration}); + &Matrix4Test::debug}); } using namespace Literals; @@ -830,20 +827,6 @@ void Matrix4Test::debug() { " 4, 3, 0, 9)\n"); } -void Matrix4Test::configuration() { - Corrade::Utility::Configuration c; - - Matrix4 m({3.0f, 5.0f, 8.0f, 4.0f}, - {4.0f, 4.0f, 7.0f, 3.125f}, - {7.0f, -1.0f, 8.0f, 0.0f}, - {9.0f, 4.0f, 5.0f, 9.55f}); - std::string value("3 4 7 9 5 4 -1 4 8 7 8 5 4 3.125 0 9.55"); - - c.setValue("matrix", m); - CORRADE_COMPARE(c.value("matrix"), value); - CORRADE_COMPARE(c.value("matrix"), m); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::Matrix4Test) diff --git a/src/Magnum/Math/Test/MatrixTest.cpp b/src/Magnum/Math/Test/MatrixTest.cpp index 1e122b3d9..ebf8ad238 100644 --- a/src/Magnum/Math/Test/MatrixTest.cpp +++ b/src/Magnum/Math/Test/MatrixTest.cpp @@ -25,7 +25,6 @@ #include #include -#include #include "Magnum/Math/Matrix.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -86,7 +85,6 @@ struct MatrixTest: Corrade::TestSuite::Tester { void subclass(); void debug(); - void configuration(); }; typedef Matrix<2, Float> Matrix2x2; @@ -125,8 +123,7 @@ MatrixTest::MatrixTest() { &MatrixTest::subclassTypes, &MatrixTest::subclass, - &MatrixTest::debug, - &MatrixTest::configuration}); + &MatrixTest::debug}); } void MatrixTest::construct() { @@ -489,20 +486,6 @@ void MatrixTest::debug() { " 0, 0, 0, 1)\n"); } -void MatrixTest::configuration() { - Corrade::Utility::Configuration c; - - Matrix4x4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f), - Vector4(4.0f, 4.0f, 7.0f, 3.125f), - Vector4(7.0f, -1.0f, 8.0f, 0.0f), - Vector4(9.0f, 4.0f, 5.0f, 9.55f)); - std::string value("3 4 7 9 5 4 -1 4 8 7 8 5 4 3.125 0 9.55"); - - c.setValue("matrix", m); - CORRADE_COMPARE(c.value("matrix"), value); - CORRADE_COMPARE(c.value("matrix"), m); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::MatrixTest) diff --git a/src/Magnum/Math/Test/QuaternionTest.cpp b/src/Magnum/Math/Test/QuaternionTest.cpp index 2d81022b0..d1751b0d7 100644 --- a/src/Magnum/Math/Test/QuaternionTest.cpp +++ b/src/Magnum/Math/Test/QuaternionTest.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include "Magnum/Math/Matrix4.h" #include "Magnum/Math/Quaternion.h" @@ -115,7 +114,6 @@ struct QuaternionTest: Corrade::TestSuite::Tester { void strictWeakOrdering(); void debug(); - void configuration(); }; typedef Math::Deg Deg; @@ -190,8 +188,7 @@ QuaternionTest::QuaternionTest() { &QuaternionTest::strictWeakOrdering, - &QuaternionTest::debug, - &QuaternionTest::configuration}); + &QuaternionTest::debug}); } void QuaternionTest::construct() { @@ -744,25 +741,6 @@ void QuaternionTest::debug() { CORRADE_COMPARE(o.str(), "Quaternion({1, 2, 3}, -4)\n"); } -void QuaternionTest::configuration() { - Corrade::Utility::Configuration c; - - Quaternion q{{3.0f, 3.125f, 9.0f}, 9.55f}; - std::string value{"3 3.125 9 9.55"}; - - c.setValue("quat", q); - CORRADE_COMPARE(c.value("quat"), value); - CORRADE_COMPARE(c.value("quat"), q); - - /* Underflow */ - c.setValue("underflow", "2.1 8.9"); - CORRADE_COMPARE(c.value("underflow"), (Quaternion{{2.1f, 8.9f, 0.0f}, 0.0f})); - - /* Overflow */ - c.setValue("overflow", "2 1 8 9 16 33"); - CORRADE_COMPARE(c.value("overflow"), (Quaternion{{2.0f, 1.0f, 8.0f}, 9.0f})); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::QuaternionTest) diff --git a/src/Magnum/Math/Test/RangeTest.cpp b/src/Magnum/Math/Test/RangeTest.cpp index 92fffc316..6a9dcbe16 100644 --- a/src/Magnum/Math/Test/RangeTest.cpp +++ b/src/Magnum/Math/Test/RangeTest.cpp @@ -25,7 +25,6 @@ #include #include -#include #include "Magnum/Math/Range.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -141,7 +140,6 @@ struct RangeTest: Corrade::TestSuite::Tester { void subclass(); void debug(); - void configuration(); }; typedef Math::Range1D Range1D; @@ -193,8 +191,7 @@ RangeTest::RangeTest() { &RangeTest::subclassTypes, &RangeTest::subclass, - &RangeTest::debug, - &RangeTest::configuration}); + &RangeTest::debug}); } void RangeTest::construct() { @@ -887,17 +884,6 @@ void RangeTest::debug() { CORRADE_COMPARE(o.str(), "Range({34, 23}, {47, 30})\n"); } -void RangeTest::configuration() { - Corrade::Utility::Configuration c; - - Range2D rect({3.0f, 3.125f}, {9.0f, 9.55f}); - std::string value("3 3.125 9 9.55"); - - c.setValue("rectangle", rect); - CORRADE_COMPARE(c.value("rectangle"), value); - CORRADE_COMPARE(c.value("rectangle"), rect); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::RangeTest) diff --git a/src/Magnum/Math/Test/RectangularMatrixTest.cpp b/src/Magnum/Math/Test/RectangularMatrixTest.cpp index 70443fb36..82a11b67c 100644 --- a/src/Magnum/Math/Test/RectangularMatrixTest.cpp +++ b/src/Magnum/Math/Test/RectangularMatrixTest.cpp @@ -25,7 +25,6 @@ #include #include -#include #include "Magnum/Math/RectangularMatrix.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -94,7 +93,6 @@ struct RectangularMatrixTest: Corrade::TestSuite::Tester { void strictWeakOrdering(); void debug(); - void configuration(); }; typedef RectangularMatrix<4, 3, Float> Matrix4x3; @@ -147,8 +145,7 @@ RectangularMatrixTest::RectangularMatrixTest() { &RectangularMatrixTest::strictWeakOrdering, - &RectangularMatrixTest::debug, - &RectangularMatrixTest::configuration}); + &RectangularMatrixTest::debug}); } void RectangularMatrixTest::construct() { @@ -717,33 +714,6 @@ void RectangularMatrixTest::debug() { " 0, 0, 0, 0)\n"); } -void RectangularMatrixTest::configuration() { - Matrix3x4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f), - Vector4(4.0f, 4.0f, 7.0f, 3.125f), - Vector4(7.0f, -1.0f, 8.0f, 9.55f)); - std::string value("3 4 7 5 4 -1 8 7 8 4 3.125 9.55"); - - Corrade::Utility::Configuration c; - c.setValue("matrix", m); - - CORRADE_COMPARE(c.value("matrix"), value); - CORRADE_COMPARE(c.value("matrix"), m); - - /* Underflow */ - c.setValue("underflow", "2.1 8.9 1.3 1 5 7 1.5"); - CORRADE_COMPARE(c.value("underflow"), (Matrix3x4{ - Vector4{2.1f, 1.0f, 1.5f, 0.0f}, - Vector4{8.9f, 5.0f, 0.0f, 0.0f}, - Vector4{1.3f, 7.0f, 0.0f, 0.0f}})); - - /* Overflow */ - c.setValue("overflow", "2 1 8 9 1 3 1 5 7 1 6 3 3 1.5 23 17"); - CORRADE_COMPARE(c.value("overflow"), (Matrix3x4{ - Vector4{2.0f, 9.0f, 1.0f, 1.0f}, - Vector4{1.0f, 1.0f, 5.0f, 6.0f}, - Vector4{8.0f, 3.0f, 7.0f, 3.0f}})); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::RectangularMatrixTest) diff --git a/src/Magnum/Math/Test/Vector2Test.cpp b/src/Magnum/Math/Test/Vector2Test.cpp index 7f50ca2c5..8b6026f58 100644 --- a/src/Magnum/Math/Test/Vector2Test.cpp +++ b/src/Magnum/Math/Test/Vector2Test.cpp @@ -25,7 +25,6 @@ #include #include -#include #include "Magnum/Math/Vector3.h" /* Vector3 used in Vector2Test::cross() */ #include "Magnum/Math/StrictWeakOrdering.h" @@ -74,7 +73,6 @@ struct Vector2Test: Corrade::TestSuite::Tester { void swizzleType(); void debug(); - void configuration(); }; typedef Math::Vector3 Vector3i; @@ -100,8 +98,7 @@ Vector2Test::Vector2Test() { &Vector2Test::strictWeakOrdering, &Vector2Test::swizzleType, - &Vector2Test::debug, - &Vector2Test::configuration}); + &Vector2Test::debug}); } void Vector2Test::construct() { @@ -259,17 +256,6 @@ void Vector2Test::debug() { CORRADE_COMPARE(o.str(), "Vector(0.5, 15)\n"); } -void Vector2Test::configuration() { - Corrade::Utility::Configuration c; - - Vector2 vec(3.125f, 9.0f); - std::string value("3.125 9"); - - c.setValue("vector", vec); - CORRADE_COMPARE(c.value("vector"), value); - CORRADE_COMPARE(c.value("vector"), vec); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::Vector2Test) diff --git a/src/Magnum/Math/Test/Vector3Test.cpp b/src/Magnum/Math/Test/Vector3Test.cpp index 2fbafa049..73bb079af 100644 --- a/src/Magnum/Math/Test/Vector3Test.cpp +++ b/src/Magnum/Math/Test/Vector3Test.cpp @@ -25,7 +25,6 @@ #include #include -#include #include "Magnum/Math/Vector3.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -74,7 +73,6 @@ struct Vector3Test: Corrade::TestSuite::Tester { void swizzleType(); void debug(); - void configuration(); }; typedef Math::Vector3 Vector3; @@ -100,8 +98,7 @@ Vector3Test::Vector3Test() { &Vector3Test::strictWeakOrdering, &Vector3Test::swizzleType, - &Vector3Test::debug, - &Vector3Test::configuration}); + &Vector3Test::debug}); } void Vector3Test::construct() { @@ -283,17 +280,6 @@ void Vector3Test::debug() { CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1)\n"); } -void Vector3Test::configuration() { - Corrade::Utility::Configuration c; - - Vector3 vec(3.0f, 3.125f, 9.55f); - std::string value("3 3.125 9.55"); - - c.setValue("vector", vec); - CORRADE_COMPARE(c.value("vector"), value); - CORRADE_COMPARE(c.value("vector"), vec); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::Vector3Test) diff --git a/src/Magnum/Math/Test/Vector4Test.cpp b/src/Magnum/Math/Test/Vector4Test.cpp index e545964bb..9ec83db8a 100644 --- a/src/Magnum/Math/Test/Vector4Test.cpp +++ b/src/Magnum/Math/Test/Vector4Test.cpp @@ -25,7 +25,6 @@ #include #include -#include #include "Magnum/Math/Vector4.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -76,7 +75,6 @@ struct Vector4Test: Corrade::TestSuite::Tester { void swizzleType(); void debug(); - void configuration(); }; typedef Math::Vector4 Vector4; @@ -105,8 +103,7 @@ Vector4Test::Vector4Test() { &Vector4Test::strictWeakOrdering, &Vector4Test::swizzleType, - &Vector4Test::debug, - &Vector4Test::configuration}); + &Vector4Test::debug}); } void Vector4Test::construct() { @@ -326,17 +323,6 @@ void Vector4Test::debug() { CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1, 1)\n"); } -void Vector4Test::configuration() { - Corrade::Utility::Configuration c; - - Vector4 vec(3.0f, 3.125f, 9.0f, 9.55f); - std::string value("3 3.125 9 9.55"); - - c.setValue("vector", vec); - CORRADE_COMPARE(c.value("vector"), value); - CORRADE_COMPARE(c.value("vector"), vec); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::Vector4Test) diff --git a/src/Magnum/Math/Test/VectorTest.cpp b/src/Magnum/Math/Test/VectorTest.cpp index 789efcbf1..5dee0ce9e 100644 --- a/src/Magnum/Math/Test/VectorTest.cpp +++ b/src/Magnum/Math/Test/VectorTest.cpp @@ -25,7 +25,6 @@ #include #include -#include #include "Magnum/Math/Vector.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -111,7 +110,6 @@ struct VectorTest: Corrade::TestSuite::Tester { void strictWeakOrdering(); void debug(); - void configuration(); }; typedef Math::Rad Rad; @@ -176,8 +174,7 @@ VectorTest::VectorTest() { &VectorTest::strictWeakOrdering, - &VectorTest::debug, - &VectorTest::configuration}); + &VectorTest::debug}); } void VectorTest::construct() { @@ -754,25 +751,6 @@ void VectorTest::debug() { CORRADE_COMPARE(o.str(), "a Vector(0, 0, 0, 0) b Vector(0, 0, 0, 0)\n"); } -void VectorTest::configuration() { - Corrade::Utility::Configuration c; - - Vector4 vec(3.0f, 3.125f, 9.0f, 9.55f); - std::string value("3 3.125 9 9.55"); - - c.setValue("vector", vec); - CORRADE_COMPARE(c.value("vector"), value); - CORRADE_COMPARE(c.value("vector"), vec); - - /* Underflow */ - c.setValue("underflow", "2.1 8.9"); - CORRADE_COMPARE(c.value("underflow"), (Vector4{2.1f, 8.9f, 0.0f, 0.0f})); - - /* Overflow */ - c.setValue("overflow", "2 1 8 9 16 33"); - CORRADE_COMPARE(c.value("overflow"), (Vector4{2.0f, 1.0f, 8.0f, 9.0f})); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::VectorTest) diff --git a/src/Magnum/Math/Vector.h b/src/Magnum/Math/Vector.h index ceac3d632..958feef52 100644 --- a/src/Magnum/Math/Vector.h +++ b/src/Magnum/Math/Vector.h @@ -34,7 +34,6 @@ #include /* std::max() */ #endif #include -#include #include #include "Magnum/visibility.h" @@ -1426,61 +1425,4 @@ template struct StrictWeakOrdering> { }} -namespace Corrade { namespace Utility { - -/** @configurationvalue{Magnum::Math::Vector} */ -template struct ConfigurationValue> { - ConfigurationValue() = delete; - - /** @brief Writes elements separated with spaces */ - static std::string toString(const Magnum::Math::Vector& value, ConfigurationValueFlags flags) { - std::string output; - - for(std::size_t i = 0; i != size; ++i) { - if(!output.empty()) output += ' '; - output += ConfigurationValue::toString(value[i], flags); - } - - return output; - } - - /** @brief Reads elements separated with whitespace */ - static Magnum::Math::Vector fromString(const std::string& stringValue, ConfigurationValueFlags flags) { - Magnum::Math::Vector result; - - std::size_t oldpos = 0, pos = std::string::npos, i = 0; - do { - pos = stringValue.find(' ', oldpos); - std::string part = stringValue.substr(oldpos, pos-oldpos); - - if(!part.empty()) { - result[i] = ConfigurationValue::fromString(part, flags); - ++i; - } - - oldpos = pos+1; - } while(pos != std::string::npos && i != size); - - return result; - } -}; - -/* Explicit instantiation for commonly used types */ -#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(__MINGW32__) -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -#endif - -}} - #endif diff --git a/src/Magnum/Math/Vector2.h b/src/Magnum/Math/Vector2.h index 813bb5cb0..5cfe22fce 100644 --- a/src/Magnum/Math/Vector2.h +++ b/src/Magnum/Math/Vector2.h @@ -192,9 +192,4 @@ namespace Implementation { }} -namespace Corrade { namespace Utility { - /** @configurationvalue{Magnum::Math::Vector2} */ - template struct ConfigurationValue>: public ConfigurationValue> {}; -}} - #endif diff --git a/src/Magnum/Math/Vector3.h b/src/Magnum/Math/Vector3.h index 4bc0ce0b3..e75855c04 100644 --- a/src/Magnum/Math/Vector3.h +++ b/src/Magnum/Math/Vector3.h @@ -246,9 +246,4 @@ namespace Implementation { }} -namespace Corrade { namespace Utility { - /** @configurationvalue{Magnum::Math::Vector3} */ - template struct ConfigurationValue>: public ConfigurationValue> {}; -}} - #endif diff --git a/src/Magnum/Math/Vector4.h b/src/Magnum/Math/Vector4.h index 1252e2537..d18e0015a 100644 --- a/src/Magnum/Math/Vector4.h +++ b/src/Magnum/Math/Vector4.h @@ -260,9 +260,4 @@ namespace Implementation { }} -namespace Corrade { namespace Utility { - /** @configurationvalue{Magnum::Math::Vector4} */ - template struct ConfigurationValue>: public ConfigurationValue> {}; -}} - #endif diff --git a/src/Magnum/Math/instantiation.cpp b/src/Magnum/Math/instantiation.cpp index 0ff82a3d4..1282dd920 100644 --- a/src/Magnum/Math/instantiation.cpp +++ b/src/Magnum/Math/instantiation.cpp @@ -24,6 +24,7 @@ */ #include "Magnum/Math/Bezier.h" +#include "Magnum/Math/ConfigurationValue.h" #include "Magnum/Math/CubicHermite.h" #include "Magnum/Math/DualComplex.h" #include "Magnum/Math/DualQuaternion.h" diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp index 32b90354b..ad4baea44 100644 --- a/src/Magnum/Platform/GlfwApplication.cpp +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -32,6 +32,7 @@ #include #include +#include "Magnum/Math/ConfigurationValue.h" #include "Magnum/Platform/ScreenedApplication.hpp" #include "Magnum/Platform/Implementation/DpiScaling.h" diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 745f212e0..b8aa5b828 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -35,6 +35,7 @@ #endif #include +#include "Magnum/Math/ConfigurationValue.h" #include "Magnum/Math/Range.h" #include "Magnum/Platform/ScreenedApplication.hpp" #include "Magnum/Platform/Implementation/DpiScaling.h" diff --git a/src/Magnum/Text/fontconverter.cpp b/src/Magnum/Text/fontconverter.cpp index a7021871a..281b55f7d 100644 --- a/src/Magnum/Text/fontconverter.cpp +++ b/src/Magnum/Text/fontconverter.cpp @@ -27,6 +27,7 @@ #include #include +#include "Magnum/Math/ConfigurationValue.h" #include "Magnum/Text/AbstractFont.h" #include "Magnum/Text/AbstractFontConverter.h" #include "Magnum/Text/DistanceFieldGlyphCache.h" diff --git a/src/Magnum/TextureTools/distancefieldconverter.cpp b/src/Magnum/TextureTools/distancefieldconverter.cpp index 0585bf858..da9686b80 100644 --- a/src/Magnum/TextureTools/distancefieldconverter.cpp +++ b/src/Magnum/TextureTools/distancefieldconverter.cpp @@ -30,6 +30,7 @@ #include "Magnum/Image.h" #include "Magnum/PixelFormat.h" +#include "Magnum/Math/ConfigurationValue.h" #include "Magnum/Math/Range.h" #include "Magnum/GL/Renderer.h" #include "Magnum/GL/Texture.h" diff --git a/src/MagnumPlugins/MagnumFont/MagnumFont.cpp b/src/MagnumPlugins/MagnumFont/MagnumFont.cpp index 44dcc7d1c..4912c60b7 100644 --- a/src/MagnumPlugins/MagnumFont/MagnumFont.cpp +++ b/src/MagnumPlugins/MagnumFont/MagnumFont.cpp @@ -32,6 +32,7 @@ #include #include +#include "Magnum/Math/ConfigurationValue.h" #include "Magnum/Text/GlyphCache.h" #include "Magnum/Trade/ImageData.h" #include "MagnumPlugins/TgaImporter/TgaImporter.h" diff --git a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp index 8b1a8422a..f4868c647 100644 --- a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp +++ b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp @@ -33,6 +33,7 @@ #include "Magnum/Image.h" #include "Magnum/PixelFormat.h" +#include "Magnum/Math/ConfigurationValue.h" #include "Magnum/Text/AbstractFont.h" #include "Magnum/Text/AbstractGlyphCache.h" #include "MagnumPlugins/TgaImageConverter/TgaImageConverter.h"