From caf844670748f8293e3bbbd510df8dfd1d7e372b Mon Sep 17 00:00:00 2001 From: SirLynix Date: Tue, 6 Jun 2023 08:59:58 +0200 Subject: [PATCH] Math: Remove Algorithm file and move string functions to StringExt --- include/Nazara/Core/StringExt.hpp | 5 +- include/Nazara/Core/StringExt.inl | 103 +++++- include/Nazara/Math.hpp | 1 - include/Nazara/Math/Algorithm.hpp | 38 --- include/Nazara/Math/Algorithm.inl | 298 ------------------ include/Nazara/Math/Angle.hpp | 2 +- include/Nazara/Math/Angle.inl | 21 ++ include/Nazara/Math/BoundingVolume.inl | 1 - include/Nazara/Math/Box.inl | 2 +- include/Nazara/Math/EulerAngles.inl | 1 - include/Nazara/Math/Frustum.inl | 1 - include/Nazara/Math/Matrix4.inl | 1 - include/Nazara/Math/OrientedBox.inl | 1 - include/Nazara/Math/Plane.inl | 1 - include/Nazara/Math/Quaternion.inl | 1 - include/Nazara/Math/Rect.inl | 2 +- include/Nazara/Math/Sphere.inl | 1 - include/Nazara/Math/Vector2.inl | 1 - include/Nazara/Math/Vector3.inl | 1 - include/Nazara/Math/Vector4.inl | 1 - include/Nazara/Renderer/RenderStates.inl | 1 - include/Nazara/Renderer/TextureSampler.inl | 1 - include/Nazara/Widgets/BaseWidget.inl | 1 - src/Nazara/Core/AbstractHash.cpp | 2 +- src/Nazara/Core/Win32/DynLibImpl.hpp | 2 +- src/Nazara/Graphics/MaterialPipeline.cpp | 2 +- src/Nazara/Network/ENetHost.cpp | 4 +- src/Nazara/Utility/PixelFormat.cpp | 1 - src/Nazara/Widgets/ScrollAreaWidget.cpp | 1 - src/Nazara/Widgets/ScrollbarWidget.cpp | 1 - .../Engine/Math/AlgorithmMathTest.cpp | 58 ---- 31 files changed, 132 insertions(+), 425 deletions(-) delete mode 100644 include/Nazara/Math/Algorithm.hpp delete mode 100644 include/Nazara/Math/Algorithm.inl diff --git a/include/Nazara/Core/StringExt.hpp b/include/Nazara/Core/StringExt.hpp index ee70d7ad4..ae167ad7e 100644 --- a/include/Nazara/Core/StringExt.hpp +++ b/include/Nazara/Core/StringExt.hpp @@ -9,7 +9,6 @@ #include #include -#include //< FIXME #include #include @@ -38,6 +37,8 @@ namespace Nz NAZARA_CORE_API bool MatchPattern(const std::string_view& str, const std::string_view& pattern); + inline std::string NumberToString(long long number, UInt8 radix = 10); + NAZARA_CORE_API std::string PointerToString(const void* ptr); inline std::string& ReplaceStr(std::string& str, const std::string_view& from, const std::string_view& to); @@ -55,6 +56,8 @@ namespace Nz NAZARA_CORE_API bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, UnicodeAware); NAZARA_CORE_API bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent, UnicodeAware); + inline long long StringToNumber(const std::string_view& str, UInt8 radix = 10, bool* ok = nullptr); + NAZARA_CORE_API std::string ToLower(const std::string_view& str); NAZARA_CORE_API std::string ToLower(const std::string_view& str, UnicodeAware); diff --git a/include/Nazara/Core/StringExt.inl b/include/Nazara/Core/StringExt.inl index 4d96b4cbc..5631d4c7d 100644 --- a/include/Nazara/Core/StringExt.inl +++ b/include/Nazara/Core/StringExt.inl @@ -11,8 +11,7 @@ namespace Nz { inline bool EndsWith(const std::string_view& str, const std::string_view& s) { - //FIXME: Replace with proper C++20 value once it's available -#if NAZARA_CPP_VER > 201703L +#if NAZARA_CPP_VER >= NAZARA_CPP20 // C++20 return str.ends_with(s); #else @@ -34,6 +33,49 @@ namespace Nz return std::find_if(str.begin(), str.end(), [](unsigned char c) { return !std::isdigit(c); }) == str.end(); } + + /*! + * \ingroup math + * \brief Converts the number to String + * \return String representation of the number + * + * \param number Number to represent + * \param radix Base of the number + * + * \remark radix is meant to be between 2 and 36, other values are potentially undefined behavior + * \remark With NAZARA_MATH_SAFE, a NazaraError is produced and String() is returned + */ + inline std::string NumberToString(long long number, UInt8 radix) + { + NazaraAssert(radix >= 2 && radix <= 36, "base must be between 2 and 36"); + + bool negative; + if (number < 0) + { + negative = true; + number = -number; + } + else + negative = false; + + std::string str; + + constexpr char symbols[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + do + { + str.push_back(symbols[number % radix]); + number /= radix; + } while (number > 0); + + if (negative) + str.push_back('-'); + + std::reverse(str.begin(), str.end()); + + return str; + } + inline std::string& ReplaceStr(std::string& str, const std::string_view& from, const std::string_view& to) { if (str.empty()) @@ -51,8 +93,7 @@ namespace Nz inline bool StartsWith(const std::string_view& str, const std::string_view& s) { - //FIXME: Replace with proper C++20 value once it's available -#if NAZARA_CPP_VER > 201703L +#if NAZARA_CPP_VER >= NAZARA_CPP20 // C++20 return str.starts_with(s); #else @@ -115,6 +156,60 @@ namespace Nz return true; } + + /*! + * \ingroup math + * \brief Converts the string to number + * \return Number which is represented by the string + * + * \param str String representation + * \param radix Base of the number + * \param ok Optional argument to know if convertion is correct + * + * \remark radix is meant to be between 2 and 36, other values are potentially undefined behavior + * \remark With NAZARA_MATH_SAFE, a NazaraError is produced and 0 is returned + */ + inline long long StringToNumber(const std::string_view& str, UInt8 radix, bool* ok) + { + NazaraAssert(radix >= 2 && radix <= 36, "base must be between 2 and 36"); + + if (str.empty()) + { + if (ok) + *ok = false; + + return 0; + } + + constexpr char symbols[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + bool negative = (str.front() == '-'); + + const char* digit = &str[(negative) ? 1 : 0]; + unsigned long long total = 0; + do + { + if (*digit == ' ') + continue; + + total *= radix; + const char* c = std::strchr(symbols, *digit); + if (c && c - symbols < radix) + total += c - symbols; + else + { + if (ok) + *ok = false; + + return 0; + } + } while (*++digit); + + if (ok) + *ok = true; + + return (negative) ? -static_cast(total) : total; + } inline std::string_view Trim(std::string_view str) { diff --git a/include/Nazara/Math.hpp b/include/Nazara/Math.hpp index 2d471783a..adf5355d1 100644 --- a/include/Nazara/Math.hpp +++ b/include/Nazara/Math.hpp @@ -30,7 +30,6 @@ #ifndef NAZARA_GLOBAL_MATH_HPP #define NAZARA_GLOBAL_MATH_HPP -#include #include #include #include diff --git a/include/Nazara/Math/Algorithm.hpp b/include/Nazara/Math/Algorithm.hpp deleted file mode 100644 index 65accf09a..000000000 --- a/include/Nazara/Math/Algorithm.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) -// This file is part of the "Nazara Engine - Math module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_MATH_ALGORITHM_HPP -#define NAZARA_MATH_ALGORITHM_HPP - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - template class Angle; - - template constexpr Angle Clamp(Angle value, T min, T max); - - constexpr unsigned int GetNumberLength(signed char number); - constexpr unsigned int GetNumberLength(unsigned char number); - unsigned int GetNumberLength(int number); - /*constexpr*/ unsigned int GetNumberLength(unsigned int number); - unsigned int GetNumberLength(long long number); - /*constexpr*/ unsigned int GetNumberLength(unsigned long long number); - unsigned int GetNumberLength(float number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS); - unsigned int GetNumberLength(double number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS); - unsigned int GetNumberLength(long double number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS); - inline std::string NumberToString(long long number, UInt8 radix = 10); - inline long long StringToNumber(const std::string_view& str, UInt8 radix = 10, bool* ok = nullptr); -} - -#include - -#endif // NAZARA_MATH_ALGORITHM_HPP diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl deleted file mode 100644 index 037cf2ee1..000000000 --- a/include/Nazara/Math/Algorithm.inl +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com) -// This file is part of the "Nazara Engine - Math module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - /*! - * \ingroup math - * \brief Clamps an angle value between min and max and returns the expected value - * \return If value is not in the interval of min..max, value obtained is the nearest limit of this interval - * - * \param value Value to clamp - * \param min Minimum of the interval - * \param max Maximum of the interval - */ - template - constexpr Angle Clamp(Angle value, T min, T max) - { - return std::max(std::min(value.value, max), min); - } - - /*! - * \ingroup math - * \brief Gets the number of digits to represent the number in base 10 - * \return Number of digits - * - * \param number Number to get number of digits - */ - constexpr inline unsigned int GetNumberLength(signed char number) - { - // Char is expected to be 1 byte - static_assert(sizeof(number) == 1, "Signed char must be one byte-sized"); - - if (number >= 100) - return 3; - else if (number >= 10) - return 2; - else if (number >= 0) - return 1; - else if (number > -10) - return 2; - else if (number > -100) - return 3; - else - return 4; - } - - /*! - * \ingroup math - * \brief Gets the number of digits to represent the number in base 10 - * \return Number of digits - * - * \param number Number to get number of digits - */ - constexpr inline unsigned int GetNumberLength(unsigned char number) - { - // Char is expected to be 1 byte - static_assert(sizeof(number) == 1, "Unsigned char must be one byte-sized"); - - if (number >= 100) - return 3; - else if (number >= 10) - return 2; - else - return 1; - } - - /*! - * \ingroup math - * \brief Gets the number of digits to represent the number in base 10 - * \return Number of digits - * - * \param number Number to get number of digits - */ - inline unsigned int GetNumberLength(int number) - { - if (number == 0) - return 1; - - return static_cast(std::log10(std::abs(number))) + (number < 0 ? 2 : 1); - } - - /*! - * \ingroup math - * \brief Gets the number of digits to represent the number in base 10 - * \return Number of digits - * - * \param number Number to get number of digits - */ - //TODO: Mark as constexpr when supported by all major compilers - /*constexpr*/ inline unsigned int GetNumberLength(unsigned int number) - { - if (number == 0) - return 1; - - return static_cast(std::log10(number))+1; - } - - /*! - * \ingroup math - * \brief Gets the number of digits to represent the number in base 10 - * \return Number of digits - * - * \param number Number to get number of digits - */ - inline unsigned int GetNumberLength(long long number) - { - if (number == 0) - return 1; - - return static_cast(std::log10(std::abs(number))) + (number < 0 ? 2 : 1); - } - - /*! - * \ingroup math - * \brief Gets the number of digits to represent the number in base 10 - * \return Number of digits - * - * \param number Number to get number of digits - */ - //TODO: Mark as constexpr when supported by all major compilers - /*constexpr*/ inline unsigned int GetNumberLength(unsigned long long number) - { - if (number == 0) - return 1; - - return static_cast(std::log10(number)) + 1; - } - - /*! - * \ingroup math - * \brief Gets the number of digits to represent the number in base 10 - * \return Number of digits + 1 for the dot - * - * \param number Number to get number of digits - * \param precision Number of digit after the dot - */ - inline unsigned int GetNumberLength(float number, UInt8 precision) - { - // The imprecision of floats need a cast (log10(9.99999) = 0.99999) - return GetNumberLength(static_cast(number)) + precision + 1; // Plus one for the dot - } - - /*! - * \ingroup math - * \brief Gets the number of digits to represent the number in base 10 - * \return Number of digits + 1 for the dot - * - * \param number Number to get number of digits - * \param precision Number of digit after the dot - */ - inline unsigned int GetNumberLength(double number, UInt8 precision) - { - // The imprecision of floats need a cast (log10(9.99999) = 0.99999) - return GetNumberLength(static_cast(number)) + precision + 1; // Plus one for the dot - } - - /*! - * \ingroup math - * \brief Gets the number of digits to represent the number in base 10 - * \return Number of digits + 1 for the dot - * - * \param number Number to get number of digits - * \param precision Number of digit after the dot - */ - inline unsigned int GetNumberLength(long double number, UInt8 precision) - { - // The imprecision of floats need a cast (log10(9.99999) = 0.99999) - return GetNumberLength(static_cast(number)) + precision + 1; // Plus one for the dot - } - - /*! - * \ingroup math - * \brief Converts the number to String - * \return String representation of the number - * - * \param number Number to represent - * \param radix Base of the number - * - * \remark radix is meant to be between 2 and 36, other values are potentially undefined behavior - * \remark With NAZARA_MATH_SAFE, a NazaraError is produced and String() is returned - */ - inline std::string NumberToString(long long number, UInt8 radix) - { - #if NAZARA_MATH_SAFE - if (radix < 2 || radix > 36) - { - NazaraError("Base must be between 2 and 36"); - return {}; - } - #endif - - if (number == 0) - return "0"; - - bool negative; - if (number < 0) - { - negative = true; - number = -number; - } - else - negative = false; - - std::string str; - - const char symbols[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - do - { - str.push_back(symbols[number % radix]); - number /= radix; - } - while (number > 0); - - if (negative) - str.push_back('-'); - - std::reverse(str.begin(), str.end()); - - return str; - } - - /*! - * \ingroup math - * \brief Converts the string to number - * \return Number which is represented by the string - * - * \param str String representation - * \param radix Base of the number - * \param ok Optional argument to know if convertion is correct - * - * \remark radix is meant to be between 2 and 36, other values are potentially undefined behavior - * \remark With NAZARA_MATH_SAFE, a NazaraError is produced and 0 is returned - */ - inline long long StringToNumber(const std::string_view& str, UInt8 radix, bool* ok) - { - #if NAZARA_MATH_SAFE - if (radix < 2 || radix > 36) - { - NazaraError("Radix must be between 2 and 36"); - - if (ok) - *ok = false; - - return 0; - } - #endif - - if (str.empty()) - { - if (ok) - *ok = false; - - return 0; - } - - const char symbols[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - bool negative = (str.front() == '-'); - - const char* digit = &str[(negative) ? 1 : 0]; - unsigned long long total = 0; - do - { - if (*digit == ' ') - continue; - - total *= radix; - const char* c = std::strchr(symbols, *digit); - if (c && c-symbols < radix) - total += c-symbols; - else - { - if (ok) - *ok = false; - - return 0; - } - } - while (*++digit); - - if (ok) - *ok = true; - - return (negative) ? -static_cast(total) : total; - } -} - -#include diff --git a/include/Nazara/Math/Angle.hpp b/include/Nazara/Math/Angle.hpp index 6fb3acce6..643242cef 100644 --- a/include/Nazara/Math/Angle.hpp +++ b/include/Nazara/Math/Angle.hpp @@ -7,7 +7,6 @@ #ifndef NAZARA_MATH_ANGLE_HPP #define NAZARA_MATH_ANGLE_HPP -#include #include #include #include @@ -81,6 +80,7 @@ namespace Nz static constexpr bool ApproxEqual(const Angle& lhs, const Angle& rhs); static constexpr bool ApproxEqual(const Angle& lhs, const Angle& rhs, T maxDifference); + static constexpr Angle Clamp(Angle angle, Angle min, Angle max); template static constexpr Angle From(T value); static constexpr Angle FromDegrees(T degrees); static constexpr Angle FromRadians(T radians); diff --git a/include/Nazara/Math/Angle.inl b/include/Nazara/Math/Angle.inl index c2c46a653..617b7f5cc 100644 --- a/include/Nazara/Math/Angle.inl +++ b/include/Nazara/Math/Angle.inl @@ -619,6 +619,12 @@ namespace Nz return lhs.ApproxEqual(rhs, maxDifference); } + template + constexpr Angle Angle::Clamp(Angle angle, Angle min, Angle max) + { + return Angle(std::clamp(angle.value, min.value, max.value)); + } + /*! * \brief Builds an Angle instance using a FromUnit angle, converting if needed * \return An angle describing the FromUnit angle as Unit @@ -720,6 +726,21 @@ namespace Nz return Detail::AngleUtils::ToString(out, angle.value); } + /*! + * \ingroup math + * \brief Clamps an angle value between min and max and returns the expected value + * \return If value is not in the interval of min..max, value obtained is the nearest limit of this interval + * + * \param value Value to clamp + * \param min Minimum of the interval + * \param max Maximum of the interval + */ + template + constexpr Angle Clamp(Angle value, T min, T max) + { + return std::max(std::min(value.value, max), min); + } + /*! * \brief Serializes an Angle * \return true if successfully serialized diff --git a/include/Nazara/Math/BoundingVolume.inl b/include/Nazara/Math/BoundingVolume.inl index 06003f0f5..3b909d58b 100644 --- a/include/Nazara/Math/BoundingVolume.inl +++ b/include/Nazara/Math/BoundingVolume.inl @@ -4,7 +4,6 @@ #include #include -#include #include #include #include diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index 25b0436f2..83c00e6dd 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include +#include #include #include #include diff --git a/include/Nazara/Math/EulerAngles.inl b/include/Nazara/Math/EulerAngles.inl index 0f2ed7428..130f06a41 100644 --- a/include/Nazara/Math/EulerAngles.inl +++ b/include/Nazara/Math/EulerAngles.inl @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include #include diff --git a/include/Nazara/Math/Frustum.inl b/include/Nazara/Math/Frustum.inl index 4250b9ec3..24d82162d 100644 --- a/include/Nazara/Math/Frustum.inl +++ b/include/Nazara/Math/Frustum.inl @@ -7,7 +7,6 @@ // http://www.lighthouse3d.com/tutorials/view-frustum-culling/ #include -#include #include #include #include diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index 57c6c4771..276d1e3d5 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/include/Nazara/Math/OrientedBox.inl b/include/Nazara/Math/OrientedBox.inl index 76b508156..4e0e78285 100644 --- a/include/Nazara/Math/OrientedBox.inl +++ b/include/Nazara/Math/OrientedBox.inl @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include #include diff --git a/include/Nazara/Math/Plane.inl b/include/Nazara/Math/Plane.inl index 1c860dfc6..dbe80f1fd 100644 --- a/include/Nazara/Math/Plane.inl +++ b/include/Nazara/Math/Plane.inl @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include #include diff --git a/include/Nazara/Math/Quaternion.inl b/include/Nazara/Math/Quaternion.inl index 0706c9431..353b68684 100644 --- a/include/Nazara/Math/Quaternion.inl +++ b/include/Nazara/Math/Quaternion.inl @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include #include diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index 6f8b5e534..a0f92c8d0 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include +#include #include #include #include diff --git a/include/Nazara/Math/Sphere.inl b/include/Nazara/Math/Sphere.inl index 1eb52fc76..90e24bea9 100644 --- a/include/Nazara/Math/Sphere.inl +++ b/include/Nazara/Math/Sphere.inl @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include #include diff --git a/include/Nazara/Math/Vector2.inl b/include/Nazara/Math/Vector2.inl index 85dd540d0..c92389bea 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include #include diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index 280905305..7b77f9a37 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include #include diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index 8ea3dac55..726247f59 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include #include diff --git a/include/Nazara/Renderer/RenderStates.inl b/include/Nazara/Renderer/RenderStates.inl index 63b85ed16..a8c4f8ab0 100644 --- a/include/Nazara/Renderer/RenderStates.inl +++ b/include/Nazara/Renderer/RenderStates.inl @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include diff --git a/include/Nazara/Renderer/TextureSampler.inl b/include/Nazara/Renderer/TextureSampler.inl index db998c573..282766f75 100644 --- a/include/Nazara/Renderer/TextureSampler.inl +++ b/include/Nazara/Renderer/TextureSampler.inl @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include namespace Nz diff --git a/include/Nazara/Widgets/BaseWidget.inl b/include/Nazara/Widgets/BaseWidget.inl index a03ae3c45..5465e04df 100644 --- a/include/Nazara/Widgets/BaseWidget.inl +++ b/include/Nazara/Widgets/BaseWidget.inl @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include diff --git a/src/Nazara/Core/AbstractHash.cpp b/src/Nazara/Core/AbstractHash.cpp index 67c056e25..5fdefa029 100644 --- a/src/Nazara/Core/AbstractHash.cpp +++ b/src/Nazara/Core/AbstractHash.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -15,7 +16,6 @@ #include #include #include -#include #include namespace Nz diff --git a/src/Nazara/Core/Win32/DynLibImpl.hpp b/src/Nazara/Core/Win32/DynLibImpl.hpp index d4ac15327..bfd00be85 100644 --- a/src/Nazara/Core/Win32/DynLibImpl.hpp +++ b/src/Nazara/Core/Win32/DynLibImpl.hpp @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include namespace Nz { diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index 917f1a17b..81f00c3d7 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -44,7 +44,7 @@ namespace Nz } RenderPipelineInfo renderPipelineInfo; - static_cast(renderPipelineInfo).operator=(m_pipelineInfo); + static_cast(renderPipelineInfo) = m_pipelineInfo; renderPipelineInfo.pipelineLayout = m_pipelineInfo.pipelineLayout; diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 64074966b..fdfd9ebd0 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -13,7 +13,7 @@ */ #include -#include +#include #include #include #include @@ -24,7 +24,7 @@ namespace Nz { namespace { - static std::size_t s_enetCommandSizes[ENetProtocolCommand_Count] = + constexpr std::size_t s_enetCommandSizes[ENetProtocolCommand_Count] = { 0, sizeof(ENetProtocolAcknowledge), diff --git a/src/Nazara/Utility/PixelFormat.cpp b/src/Nazara/Utility/PixelFormat.cpp index 3631abb92..b529bbaeb 100644 --- a/src/Nazara/Utility/PixelFormat.cpp +++ b/src/Nazara/Utility/PixelFormat.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include diff --git a/src/Nazara/Widgets/ScrollAreaWidget.cpp b/src/Nazara/Widgets/ScrollAreaWidget.cpp index c941e6887..ce1bcb446 100644 --- a/src/Nazara/Widgets/ScrollAreaWidget.cpp +++ b/src/Nazara/Widgets/ScrollAreaWidget.cpp @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include diff --git a/src/Nazara/Widgets/ScrollbarWidget.cpp b/src/Nazara/Widgets/ScrollbarWidget.cpp index 49b004783..765127233 100644 --- a/src/Nazara/Widgets/ScrollbarWidget.cpp +++ b/src/Nazara/Widgets/ScrollbarWidget.cpp @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include #include diff --git a/tests/UnitTests/Engine/Math/AlgorithmMathTest.cpp b/tests/UnitTests/Engine/Math/AlgorithmMathTest.cpp index 2579f4182..ca6b36a6e 100644 --- a/tests/UnitTests/Engine/Math/AlgorithmMathTest.cpp +++ b/tests/UnitTests/Engine/Math/AlgorithmMathTest.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -84,63 +83,6 @@ TEST_CASE("GetNearestPowerOfTwo", "[MATH][ALGORITHM]") } } -TEST_CASE("GetNumberLength", "[MATH][ALGORITHM]") -{ - SECTION("GetNumberLength of -127 signed char") - { - signed char minus127 = -127; - REQUIRE(Nz::GetNumberLength(minus127) == 4); - } - - SECTION("GetNumberLength of 255 unsigned char") - { - unsigned char plus255 = 255; - REQUIRE(Nz::GetNumberLength(plus255) == 3); - } - - SECTION("GetNumberLength of -1270 signed int") - { - signed int minus1270 = -1270; - REQUIRE(Nz::GetNumberLength(minus1270) == 5); - } - - SECTION("GetNumberLength of 2550 unsigned int") - { - unsigned int plus2550 = 2550; - REQUIRE(Nz::GetNumberLength(plus2550) == 4); - } - - SECTION("GetNumberLength of -1270 signed long long") - { - signed long long minus12700 = -12700; - REQUIRE(Nz::GetNumberLength(minus12700) == 6); - } - - SECTION("GetNumberLength of 2550 unsigned long long") - { - unsigned long long plus25500 = 25500; - REQUIRE(Nz::GetNumberLength(plus25500) == 5); - } - - SECTION("GetNumberLength of -2.456f float") - { - float minus2P456 = -2.456f; - REQUIRE(Nz::GetNumberLength(minus2P456, 3) == 6); - } - - SECTION("GetNumberLength of -2.456 double") - { - double minus2P456 = -2.456; - REQUIRE(Nz::GetNumberLength(minus2P456, 3) == 6); - } - - SECTION("GetNumberLength of -2.456 long double") - { - long double minus2P456 = -2.456L; - REQUIRE(Nz::GetNumberLength(minus2P456, 3) == 6); - } -} - TEST_CASE("IntegralLog2", "[MATH][ALGORITHM]") { SECTION("According to implementation, log in base 2 of 0 = 0")