diff options
Diffstat (limited to 'include/hashcomp.h')
-rw-r--r-- | include/hashcomp.h | 92 |
1 files changed, 31 insertions, 61 deletions
diff --git a/include/hashcomp.h b/include/hashcomp.h index 4b0a2cc49..d666f2667 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -1,24 +1,28 @@ /* + * Anope IRC Services * - * (C) 2002-2011 InspIRCd Development Team - * (C) 2009-2017 Anope Team <team@anope.org> + * Copyright (C) 2002-2011 InspIRCd Development Team + * Copyright (C) 2008-2017 Anope Team <team@anope.org> * - * Please read COPYING and README for further details. + * This file is part of Anope. Anope is free software; you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software + * Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see see <http://www.gnu.org/licenses/>. */ -#ifndef HASHCOMP_H -#define HASHCOMP_H +#pragma once #include <string> #include <locale> - -#if defined _LIBCPP_VERSION || defined _WIN32 #include <unordered_map> -#define TR1NS std -#else -#include <tr1/unordered_map> -#define TR1NS std::tr1 -#endif #include "services.h" @@ -26,56 +30,8 @@ namespace Anope { class string; - /* Casemap in use by Anope. ci::string's comparation functions use this (and thus Anope::string) */ - extern std::locale casemap; - - extern void CaseMapRebuild(); extern unsigned char tolower(unsigned char); extern unsigned char toupper(unsigned char); - - /* ASCII case insensitive ctype. */ - template<typename char_type> - class ascii_ctype : public std::ctype<char_type> - { - public: - char_type do_toupper(char_type c) const anope_override - { - if (c >= 'a' && c <= 'z') - return c - 32; - else - return c; - } - - char_type do_tolower(char_type c) const anope_override - { - if (c >= 'A' && c <= 'Z') - return c + 32; - else - return c; - } - }; - - /* rfc1459 case insensitive ctype, { = [, } = ], and | = \ */ - template<typename char_type> - class rfc1459_ctype : public ascii_ctype<char_type> - { - public: - char_type do_toupper(char_type c) const anope_override - { - if (c == '{' || c == '}' || c == '|') - return c - 32; - else - return ascii_ctype<char_type>::do_toupper(c); - } - - char_type do_tolower(char_type c) const anope_override - { - if (c == '[' || c == ']' || c == '\\') - return c + 32; - else - return ascii_ctype<char_type>::do_tolower(c); - } - }; } /** The ci namespace contains a number of helper classes relevant to case insensitive strings. @@ -196,4 +152,18 @@ inline bool operator!=(const std::string &leftval, const ci::string &rightval) return !(leftval.c_str() == rightval); } -#endif // HASHCOMP_H +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 &); +extern std::string transform(const std::string &); + +#endif + +} +} + |