diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2022-08-19 17:34:12 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2022-08-19 17:34:55 +0200 |
commit | 2effe9775db423d61d8a2bdd15c40e6015bac6f5 (patch) | |
tree | c39246dbbd85c66987dd8c2c071648f2da7eaede /src/utils | |
parent | 109b602701578b9f2b29282f84bf2757544f8d32 (diff) | |
download | manaserv-2effe9775db423d61d8a2bdd15c40e6015bac6f5.tar.gz manaserv-2effe9775db423d61d8a2bdd15c40e6015bac6f5.tar.bz2 manaserv-2effe9775db423d61d8a2bdd15c40e6015bac6f5.tar.xz manaserv-2effe9775db423d61d8a2bdd15c40e6015bac6f5.zip |
Apply C++11 fixits
modernize-loop-convert
modernize-deprecated-headers
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/mathutils.cpp | 6 | ||||
-rw-r--r-- | src/utils/sha256.cpp | 6 | ||||
-rw-r--r-- | src/utils/string.cpp | 4 | ||||
-rw-r--r-- | src/utils/stringfilter.cpp | 7 | ||||
-rw-r--r-- | src/utils/timer.cpp | 2 | ||||
-rw-r--r-- | src/utils/timer.h | 2 | ||||
-rw-r--r-- | src/utils/tokencollector.h | 4 |
7 files changed, 15 insertions, 16 deletions
diff --git a/src/utils/mathutils.cpp b/src/utils/mathutils.cpp index a11538e5..cc87ec0b 100644 --- a/src/utils/mathutils.cpp +++ b/src/utils/mathutils.cpp @@ -20,10 +20,10 @@ #include "mathutils.h" +#include <cfloat> #include <cmath> -#include <stdint.h> -#include <string.h> -#include <float.h> +#include <cstdint> +#include <cstring> #ifndef M_PI_2 #define M_PI_2 1.57079632679489661923 diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp index f9ea3fa1..25117e4d 100644 --- a/src/utils/sha256.cpp +++ b/src/utils/sha256.cpp @@ -264,10 +264,10 @@ std::string SHA256Hash(const char *src, int len) // Convert it to hex const char* hxc = "0123456789abcdef"; std::string hash; - for (int i = 0; i < SHA256_DIGEST_SIZE; i++) + for (unsigned char i : bytehash) { - hash += hxc[bytehash[i] / 16]; - hash += hxc[bytehash[i] % 16]; + hash += hxc[i / 16]; + hash += hxc[i % 16]; } return hash; } diff --git a/src/utils/string.cpp b/src/utils/string.cpp index fdc5eb59..028bd7c2 100644 --- a/src/utils/string.cpp +++ b/src/utils/string.cpp @@ -40,9 +40,9 @@ std::string toLower(std::string s) bool isNumeric(const std::string &s) { - for (unsigned i = 0; i < s.size(); ++i) + for (char i : s) { - if (!isdigit(s[i])) + if (!isdigit(i)) { return false; } diff --git a/src/utils/stringfilter.cpp b/src/utils/stringfilter.cpp index 8c417ed0..381a0c43 100644 --- a/src/utils/stringfilter.cpp +++ b/src/utils/stringfilter.cpp @@ -80,14 +80,13 @@ bool StringFilter::filterContent(const std::string &text) const std::string upperCaseText = text; std::transform(text.begin(), text.end(), upperCaseText.begin(), - (int(*)(int))std::toupper); + (int(*)(int))std::toupper); - for (auto i = mSlangs.begin(); i != mSlangs.end(); ++i) + for (auto upperCaseSlang : mSlangs) { // We look for slangs into the sentence. - std::string upperCaseSlang = *i; std::transform(upperCaseSlang.begin(), upperCaseSlang.end(), - upperCaseSlang.begin(), (int(*)(int))std::toupper); + upperCaseSlang.begin(), (int(*)(int))std::toupper); if (upperCaseText.compare(upperCaseSlang)) { isContentClean = false; diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp index 3d1e0e6d..7da2d45c 100644 --- a/src/utils/timer.cpp +++ b/src/utils/timer.cpp @@ -20,7 +20,7 @@ #include "timer.h" -#include <time.h> +#include <ctime> #include <sys/time.h> #ifdef _WIN32 diff --git a/src/utils/timer.h b/src/utils/timer.h index 2fb9e7b1..a505338d 100644 --- a/src/utils/timer.h +++ b/src/utils/timer.h @@ -25,7 +25,7 @@ #ifdef _MSC_VER typedef __uint64 uint64_t // when using MSVC use its internal type #else - #include <stdint.h> // on other compilers use the C99 official header + #include <cstdint> // on other compilers use the C++11 official header #endif namespace utils diff --git a/src/utils/tokencollector.h b/src/utils/tokencollector.h index 64977d26..8c4c72ca 100644 --- a/src/utils/tokencollector.h +++ b/src/utils/tokencollector.h @@ -21,10 +21,10 @@ #ifndef TOKENCOLLECTOR_H #define TOKENCOLLECTOR_H -#include <stdint.h> +#include <cstdint> #include <string> #include <list> -#include <time.h> +#include <ctime> /** * Base class containing the generic implementation of TokenCollector. |