summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-08-27 12:28:27 -0400
committerAdam <Adam@anope.org>2016-08-27 12:28:27 -0400
commitc4ebf02bce968e4846a0be72dfa7b104f21f5166 (patch)
tree2b38b5c06b0136411f7f7ca236fa08108ba84301 /include
parent26e158addf18ff61b99dc70a407b22682e6a421d (diff)
Optionally allow using Boost.Locale for hashcomp
Diffstat (limited to 'include')
-rw-r--r--include/anope.h41
-rw-r--r--include/channels.h2
-rw-r--r--include/config.h1
-rw-r--r--include/hashcomp.h14
-rw-r--r--include/modules/chanserv.h2
-rw-r--r--include/modules/nickserv.h4
-rw-r--r--include/sysconf.h.cmake1
-rw-r--r--include/users.h6
8 files changed, 48 insertions, 23 deletions
diff --git a/include/anope.h b/include/anope.h
index d5e935891..c298d5d86 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -315,33 +315,40 @@ namespace Anope
inline const string operator+(const char *_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
inline const string operator+(const std::string &_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
+ struct hash
+ {
+ size_t operator()(const string &s) const;
+ };
+
+ struct compare
+ {
+ bool operator()(const string &s1, const string &s2) const;
+ };
+
struct hash_ci
{
- inline size_t operator()(const string &s) const
- {
- return std::hash<std::string>()(s.lower().str());
- }
+ size_t operator()(const string &s) const;
};
- struct hash_cs
+ struct compare_ci
{
- inline size_t operator()(const string &s) const
- {
- return std::hash<std::string>()(s.str());
- }
+ bool operator()(const string &s1, const string &s2) const;
};
- struct compare
+ struct hash_locale
{
- inline bool operator()(const string &s1, const string &s2) const
- {
- return s1.equals_ci(s2);
- }
+ size_t operator()(const string &s) const;
+ };
+
+ struct compare_locale
+ {
+ bool operator()(const string &s1, const string &s2) const;
};
- template<typename T> class map : public std::map<string, T, ci::less> { };
- template<typename T> class multimap : public std::multimap<string, T, ci::less> { };
- template<typename T> class hash_map : public std::unordered_map<string, T, hash_ci, compare> { };
+ template<typename T> using map = std::map<string, T, ci::less>;
+ template<typename T> using multimap = std::multimap<string, T, ci::less>;
+ template<typename T> using hash_map = std::unordered_map<string, T, hash_ci, compare_ci>;
+ template<typename T> using locale_hash_map = std::unordered_map<string, T, hash_locale, compare_locale>;
static const char *const compiled = __TIME__ " " __DATE__;
diff --git a/include/channels.h b/include/channels.h
index bfe2fc0d2..5888f84e3 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -24,7 +24,7 @@
#include "modes.h"
#include "serialize.h"
-typedef Anope::hash_map<Channel *> channel_map;
+using channel_map = Anope::locale_hash_map<Channel *>;
extern CoreExport channel_map ChannelList;
diff --git a/include/config.h b/include/config.h
index 6d73e03ad..7ca8caaf4 100644
--- a/include/config.h
+++ b/include/config.h
@@ -142,6 +142,7 @@ namespace Configuration
std::vector<Usermode> Usermodes;
std::vector<Channelmode> Channelmodes;
unsigned char CaseMapUpper[256] = { 0 }, CaseMapLower[256] = { 0 };
+ std::locale *locale = nullptr;
/* module configuration blocks */
std::map<Anope::string, Block *> modules;
diff --git a/include/hashcomp.h b/include/hashcomp.h
index 470c054fd..d246bfd2b 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -152,3 +152,17 @@ inline bool operator!=(const std::string &leftval, const ci::string &rightval)
return !(leftval.c_str() == rightval);
}
+namespace Anope {
+namespace locale {
+
+#ifdef Boost_FOUND
+
+extern std::locale generate(const std::string &);
+extern int compare(const std::string &, const std::string &);
+extern long hash(const std::string &);
+
+#endif
+
+}
+}
+
diff --git a/include/modules/chanserv.h b/include/modules/chanserv.h
index 8029782bb..8c5687cc2 100644
--- a/include/modules/chanserv.h
+++ b/include/modules/chanserv.h
@@ -96,7 +96,7 @@ namespace ChanServ
};
class Channel;
- using registered_channel_map = Anope::hash_map<Channel *>;
+ using registered_channel_map = Anope::locale_hash_map<Channel *>;
class Level : public Serialize::Object
{
diff --git a/include/modules/nickserv.h b/include/modules/nickserv.h
index 047c2cf18..43e2a21ce 100644
--- a/include/modules/nickserv.h
+++ b/include/modules/nickserv.h
@@ -29,8 +29,8 @@ namespace NickServ
class Account;
class IdentifyRequestListener;
- typedef Anope::hash_map<Nick *> nickalias_map;
- typedef Anope::hash_map<Account *> nickcore_map;
+ using nickalias_map = Anope::locale_hash_map<Nick *>;
+ using nickcore_map = Anope::locale_hash_map<Account *>;
class NickServService : public Service
{
diff --git a/include/sysconf.h.cmake b/include/sysconf.h.cmake
index 8157bc0be..2d2ede9de 100644
--- a/include/sysconf.h.cmake
+++ b/include/sysconf.h.cmake
@@ -24,4 +24,5 @@
#cmakedefine DEFUMASK @DEFUMASK@
#cmakedefine HAVE_UMASK 1
#cmakedefine GETTEXT_FOUND 1
+#cmakedefine Boost_FOUND 1
diff --git a/include/users.h b/include/users.h
index 046f41e8e..dacb7045e 100644
--- a/include/users.h
+++ b/include/users.h
@@ -27,9 +27,11 @@
#include "commands.h"
#include "sockets.h"
-typedef Anope::hash_map<User *> user_map;
+using user_map = Anope::locale_hash_map<User *>;
+using uid_map = std::unordered_map<Anope::string, User *, Anope::hash, Anope::compare>;
-extern CoreExport user_map UserListByNick, UserListByUID;
+extern CoreExport user_map UserListByNick;
+extern CoreExport uid_map UserListByUID;
extern CoreExport int OperCount;