* Use enum class instead of enum (except for the enums for the resource IDs, not really necessary there).
* For NCSF specifically, included a function to convert an enum class to its underlying integral type (as this is needed for use with the std::bitset class).
* Cleanup headers so all the ones needed in a file are explicitly included even if they may possibly be included in another header.
* Used forward declarations in a few spots.
* Explicitly namespaced all (u)int*_t uses (this might seem like overkill, but it helps me see when the standard types are being used with a simple search for std::).
* Made sure it all builds with MinGW-w64 as well (both gcc and clang).
* Removed some std::move from DialogBuilder.cpp based on clang's warnings for that.
* Replaced use of std::copy_n on strings in DialogBuilder.cpp with my CopyToString functions that use wcscpy.
* Replaced CHAR_MIN/CHAR_MAX in eqstr.h and ltstr.h with std::numeric_limits<char>::min/max().
| ... | ... |
@@ -8,11 +8,10 @@ |
| 8 | 8 |
|
| 9 | 9 |
#pragma once |
| 10 | 10 |
|
| 11 |
-#include <functional> |
|
| 11 |
+#include <algorithm> |
|
| 12 |
+#include <limits> |
|
| 12 | 13 |
#include <locale> |
| 13 | 14 |
#include <string> |
| 14 |
-#include <algorithm> |
|
| 15 |
-#include <climits> |
|
| 16 | 15 |
|
| 17 | 16 |
struct lt_str |
| 18 | 17 |
{
|
| ... | ... |
@@ -20,16 +19,16 @@ struct lt_str |
| 20 | 19 |
{
|
| 21 | 20 |
const char *tab; |
| 22 | 21 |
lt_char(const char *t) : tab(t) { }
|
| 23 |
- bool operator()(char x, char y) const { return this->tab[x - CHAR_MIN] < this->tab[y - CHAR_MIN]; }
|
|
| 22 |
+ bool operator()(char x, char y) const { return this->tab[x - std::numeric_limits<char>::min()] < this->tab[y - std::numeric_limits<char>::min()]; }
|
|
| 24 | 23 |
}; |
| 25 | 24 |
|
| 26 |
- char tab[CHAR_MAX - CHAR_MIN + 1]; |
|
| 25 |
+ char tab[std::numeric_limits<char>::max() - std::numeric_limits<char>::min() + 1]; |
|
| 27 | 26 |
|
| 28 | 27 |
lt_str(const std::locale &L = std::locale::classic()) |
| 29 | 28 |
{
|
| 30 |
- for (int i = CHAR_MIN; i <= CHAR_MAX; ++i) |
|
| 31 |
- this->tab[i - CHAR_MIN] = static_cast<char>(i); |
|
| 32 |
- std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (CHAR_MAX - CHAR_MIN + 1)); |
|
| 29 |
+ for (int i = std::numeric_limits<char>::min(); i <= std::numeric_limits<char>::max(); ++i) |
|
| 30 |
+ this->tab[i - std::numeric_limits<char>::min()] = static_cast<char>(i); |
|
| 31 |
+ std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (std::numeric_limits<char>::max() - std::numeric_limits<char>::min() + 1)); |
|
| 33 | 32 |
} |
| 34 | 33 |
|
| 35 | 34 |
bool operator()(const std::string &x, const std::string &y) const |
(I never remember to update these and besides, GitHub history can show when they were last modified.)
| ... | ... |
@@ -15,9 +15,9 @@ |
| 15 | 15 |
#include <algorithm> |
| 16 | 16 |
#include <climits> |
| 17 | 17 |
|
| 18 |
-struct lt_str : std::binary_function<std::string, std::string, bool> |
|
| 18 |
+struct lt_str |
|
| 19 | 19 |
{
|
| 20 |
- struct lt_char : std::binary_function<char, char, bool> |
|
| 20 |
+ struct lt_char |
|
| 21 | 21 |
{
|
| 22 | 22 |
const char *tab; |
| 23 | 23 |
lt_char(const char *t) : tab(t) { }
|
| ... | ... |
@@ -1,14 +1,13 @@ |
| 1 | 1 |
/* |
| 2 | 2 |
* Case-insensitive string comparison |
| 3 |
- * Last modification on 2012-03-30 |
|
| 3 |
+ * Last modification on 2014-09-08 |
|
| 4 | 4 |
* |
| 5 | 5 |
* Based on "How to do case-insensitive string comparison" |
| 6 | 6 |
* By Matt Austern |
| 7 | 7 |
* http://lafstern.org/matt/col2_new.pdf |
| 8 | 8 |
*/ |
| 9 | 9 |
|
| 10 |
-#ifndef LTSTR_H |
|
| 11 |
-#define LTSTR_H |
|
| 10 |
+#pragma once |
|
| 12 | 11 |
|
| 13 | 12 |
#include <functional> |
| 14 | 13 |
#include <locale> |
| ... | ... |
@@ -39,5 +38,3 @@ struct lt_str : std::binary_function<std::string, std::string, bool> |
| 39 | 38 |
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), lt_char(this->tab)); |
| 40 | 39 |
} |
| 41 | 40 |
}; |
| 42 |
- |
|
| 43 |
-#endif |
| ... | ... |
@@ -31,7 +31,7 @@ struct lt_str : std::binary_function<std::string, std::string, bool> |
| 31 | 31 |
{
|
| 32 | 32 |
for (int i = CHAR_MIN; i <= CHAR_MAX; ++i) |
| 33 | 33 |
this->tab[i - CHAR_MIN] = static_cast<char>(i); |
| 34 |
- std::use_facet<std::ctype<char> >(L).toupper(this->tab, this->tab + (CHAR_MAX - CHAR_MIN + 1)); |
|
| 34 |
+ std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (CHAR_MAX - CHAR_MIN + 1)); |
|
| 35 | 35 |
} |
| 36 | 36 |
|
| 37 | 37 |
bool operator()(const std::string &x, const std::string &y) const |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,43 @@ |
| 1 |
+/* |
|
| 2 |
+ * Case-insensitive string comparison |
|
| 3 |
+ * Last modification on 2012-03-21 |
|
| 4 |
+ * |
|
| 5 |
+ * Based on "How to do case-insensitive string comparison" |
|
| 6 |
+ * By Matt Austern |
|
| 7 |
+ * http://lafstern.org/matt/col2_new.pdf |
|
| 8 |
+ */ |
|
| 9 |
+ |
|
| 10 |
+#ifndef LTSTR_H |
|
| 11 |
+#define LTSTR_H |
|
| 12 |
+ |
|
| 13 |
+#include <functional> |
|
| 14 |
+#include <locale> |
|
| 15 |
+#include <string> |
|
| 16 |
+#include <algorithm> |
|
| 17 |
+#include <climits> |
|
| 18 |
+ |
|
| 19 |
+struct lt_str : std::binary_function<std::string, std::string, bool> |
|
| 20 |
+{
|
|
| 21 |
+ struct lt_char : std::binary_function<char, char, bool> |
|
| 22 |
+ {
|
|
| 23 |
+ const char *tab; |
|
| 24 |
+ lt_char(const char *t) : tab(t) { }
|
|
| 25 |
+ bool operator()(char x, char y) const { return this->tab[x - CHAR_MIN] < this->tab[y - CHAR_MIN]; }
|
|
| 26 |
+ }; |
|
| 27 |
+ |
|
| 28 |
+ char tab[CHAR_MAX - CHAR_MIN + 1]; |
|
| 29 |
+ |
|
| 30 |
+ lt_str(const std::locale &L = std::locale::classic()) |
|
| 31 |
+ {
|
|
| 32 |
+ for (int i = CHAR_MIN; i <= CHAR_MAX; ++i) |
|
| 33 |
+ this->tab[i - CHAR_MIN] = static_cast<char>(i); |
|
| 34 |
+ std::use_facet<std::ctype<char> >(L).toupper(this->tab, this->tab + (CHAR_MAX - CHAR_MIN + 1)); |
|
| 35 |
+ } |
|
| 36 |
+ |
|
| 37 |
+ bool operator()(const std::string &x, const std::string &y) const |
|
| 38 |
+ {
|
|
| 39 |
+ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), lt_char(this->tab)); |
|
| 40 |
+ } |
|
| 41 |
+}; |
|
| 42 |
+ |
|
| 43 |
+#endif |