diff options
| -rw-r--r-- | include/compat.h | 11 | ||||
| -rw-r--r-- | include/configreader.h | 1 | ||||
| -rw-r--r-- | include/extension.h | 1 | ||||
| -rw-r--r-- | include/inspircd.h | 2 | ||||
| -rw-r--r-- | include/modules/hash.h | 2 | ||||
| -rw-r--r-- | include/stringutils.h | 61 | ||||
| -rw-r--r-- | include/token_list.h | 72 | ||||
| -rw-r--r-- | src/coremods/core_dns.cpp | 1 | ||||
| -rw-r--r-- | src/modules/extra/m_ssl_gnutls.cpp | 1 | ||||
| -rw-r--r-- | src/modules/extra/m_ssl_mbedtls.cpp | 1 | ||||
| -rw-r--r-- | src/modules/extra/m_ssl_openssl.cpp | 1 | ||||
| -rw-r--r-- | src/modules/m_httpd_acl.cpp | 1 | ||||
| -rw-r--r-- | src/modules/m_passforward.cpp | 1 | ||||
| -rw-r--r-- | src/stringutils.cpp | 1 | ||||
| -rw-r--r-- | src/xline.cpp | 1 |
15 files changed, 95 insertions, 63 deletions
diff --git a/include/compat.h b/include/compat.h index 4c61a1fc6..8bf0461fd 100644 --- a/include/compat.h +++ b/include/compat.h @@ -32,6 +32,17 @@ # define ATTR_NOT_NULL(...) #endif +/** @def INSP_FORMAT(FORMAT, ...) + * Formats a string with format string checking. + */ +#if defined __cpp_if_constexpr && defined __cpp_return_type_deduction +# include <fmt/compile.h> +# define INSP_FORMAT(FORMAT, ...) fmt::format(FMT_COMPILE(FORMAT), __VA_ARGS__) +#else +# include <fmt/core.h> +# define INSP_FORMAT(FORMAT, ...) fmt::format(FMT_STRING(FORMAT), __VA_ARGS__) +#endif + /** * Windows is very different to UNIX so we have to wrap certain features in * order to build on Windows correctly. diff --git a/include/configreader.h b/include/configreader.h index da712713b..fe92ee312 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -31,7 +31,6 @@ #pragma once #include "inspircd.h" -#include "stringutils.h" /** Represents the position within a file. */ class CoreExport FilePosition final diff --git a/include/extension.h b/include/extension.h index d852eaf9c..2c05b6c7d 100644 --- a/include/extension.h +++ b/include/extension.h @@ -19,6 +19,7 @@ #pragma once +#include "stringutils.h" #include "utility/string.h" /** Base class for types that extend an extensible. */ diff --git a/include/inspircd.h b/include/inspircd.h index 8f16a521c..43a1d86f0 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -79,7 +79,7 @@ CoreExport extern InspIRCd* ServerInstance; #include "numeric.h" #include "uid.h" #include "server.h" -#include "stringutils.h" +#include "token_list.h" #include "users.h" #include "channels.h" #include "timer.h" diff --git a/include/modules/hash.h b/include/modules/hash.h index 5b8dfe625..ae8a161c5 100644 --- a/include/modules/hash.h +++ b/include/modules/hash.h @@ -24,6 +24,8 @@ #pragma once +#include "stringutils.h" + class HashProvider : public DataProvider { diff --git a/include/stringutils.h b/include/stringutils.h index 30710306e..90b3eef1c 100644 --- a/include/stringutils.h +++ b/include/stringutils.h @@ -27,17 +27,6 @@ #pragma once -/** @def INSP_FORMAT(FORMAT, ...) - * Formats a string with format string checking. - */ -#if defined __cpp_if_constexpr && defined __cpp_return_type_deduction -# include <fmt/compile.h> -# define INSP_FORMAT(FORMAT, ...) fmt::format(FMT_COMPILE(FORMAT), __VA_ARGS__) -#else -# include <fmt/core.h> -# define INSP_FORMAT(FORMAT, ...) fmt::format(FMT_STRING(FORMAT), __VA_ARGS__) -#endif - namespace Base64 { /** The default table used when handling Base64-encoded strings. */ @@ -165,53 +154,3 @@ namespace Template */ CoreExport std::string Replace(const std::string& str, const VariableMap& vars); } - -/** Encapsulates a list of tokens in the format "* -FOO -BAR".*/ -class CoreExport TokenList final -{ -private: - /** Whether this list includes all tokens by default. */ - bool permissive = false; - - /** Either the tokens to exclude if in permissive mode or the tokens to include if in strict mode. */ - insp::flat_set<std::string, irc::insensitive_swo> tokens; - -public: - /** Creates a new empty token list. */ - TokenList() = default; - - /** Creates a new token list from a list of tokens. */ - TokenList(const std::string& tokenlist); - - /** Adds a space-delimited list of tokens to the token list. - * @param tokenlist The list of space-delimited tokens to add. - */ - void AddList(const std::string& tokenlist); - - /** Adds a single token to the token list. - * @param token The token to add. - */ - void Add(const std::string& token); - - /** Removes all tokens from the token list. */ - void Clear(); - - /** Determines whether the specified token exists in the token list. - * @param token The token to search for. - */ - bool Contains(const std::string& token) const; - - /** Removes the specified token from the token list. - * @param token The token to remove. - */ - void Remove(const std::string& token); - - /** Retrieves a string which represents the contents of this token list. */ - std::string ToString() const; - - /** Determines whether the specified token list contains the same tokens as this instance. - * @param other The tokenlist to compare against. - * @return True if the token lists are equal; otherwise, false. - */ - bool operator==(const TokenList& other) const; -}; diff --git a/include/token_list.h b/include/token_list.h new file mode 100644 index 000000000..6b6a1e0f6 --- /dev/null +++ b/include/token_list.h @@ -0,0 +1,72 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2017, 2021-2022 Sadie Powell <sadie@witchery.services> + * + * This file is part of InspIRCd. InspIRCd 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 <http://www.gnu.org/licenses/>. + */ + + +#pragma once + +#include "compat.h" + +/** Encapsulates a list of tokens in the format "* -FOO -BAR".*/ +class CoreExport TokenList final +{ +private: + /** Whether this list includes all tokens by default. */ + bool permissive = false; + + /** Either the tokens to exclude if in permissive mode or the tokens to include if in strict mode. */ + insp::flat_set<std::string, irc::insensitive_swo> tokens; + +public: + /** Creates a new empty token list. */ + TokenList() = default; + + /** Creates a new token list from a list of tokens. */ + TokenList(const std::string& tokenlist); + + /** Adds a space-delimited list of tokens to the token list. + * @param tokenlist The list of space-delimited tokens to add. + */ + void AddList(const std::string& tokenlist); + + /** Adds a single token to the token list. + * @param token The token to add. + */ + void Add(const std::string& token); + + /** Removes all tokens from the token list. */ + void Clear(); + + /** Determines whether the specified token exists in the token list. + * @param token The token to search for. + */ + bool Contains(const std::string& token) const; + + /** Removes the specified token from the token list. + * @param token The token to remove. + */ + void Remove(const std::string& token); + + /** Retrieves a string which represents the contents of this token list. */ + std::string ToString() const; + + /** Determines whether the specified token list contains the same tokens as this instance. + * @param other The tokenlist to compare against. + * @return True if the token lists are equal; otherwise, false. + */ + bool operator==(const TokenList& other) const; +}; diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp index 6114c2adb..fd254fb68 100644 --- a/src/coremods/core_dns.cpp +++ b/src/coremods/core_dns.cpp @@ -23,6 +23,7 @@ #include "inspircd.h" #include "modules/dns.h" #include "modules/stats.h" +#include "stringutils.h" #include <fstream> diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 1a0c3a152..c663b656b 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -41,6 +41,7 @@ #include "inspircd.h" #include "modules/ssl.h" +#include "stringutils.h" #include "timeutils.h" #include "utility/string.h" diff --git a/src/modules/extra/m_ssl_mbedtls.cpp b/src/modules/extra/m_ssl_mbedtls.cpp index 54af321fb..04fc427eb 100644 --- a/src/modules/extra/m_ssl_mbedtls.cpp +++ b/src/modules/extra/m_ssl_mbedtls.cpp @@ -28,6 +28,7 @@ #include "inspircd.h" #include "modules/ssl.h" +#include "stringutils.h" #include "timeutils.h" #include "utility/string.h" diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 6f6b27868..948c1a3e9 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -43,6 +43,7 @@ #include "inspircd.h" #include "iohook.h" #include "modules/ssl.h" +#include "stringutils.h" #include "timeutils.h" #include "utility/string.h" diff --git a/src/modules/m_httpd_acl.cpp b/src/modules/m_httpd_acl.cpp index c7fc68d45..989e3dac4 100644 --- a/src/modules/m_httpd_acl.cpp +++ b/src/modules/m_httpd_acl.cpp @@ -25,6 +25,7 @@ #include "inspircd.h" #include "modules/httpd.h" +#include "stringutils.h" #include "utility/string.h" class HTTPACL final diff --git a/src/modules/m_passforward.cpp b/src/modules/m_passforward.cpp index 842e4573e..7e49ed9e6 100644 --- a/src/modules/m_passforward.cpp +++ b/src/modules/m_passforward.cpp @@ -25,6 +25,7 @@ #include "inspircd.h" #include "modules/account.h" +#include "stringutils.h" class ModulePassForward final : public Module diff --git a/src/stringutils.cpp b/src/stringutils.cpp index 9fc22f3ee..7162a104e 100644 --- a/src/stringutils.cpp +++ b/src/stringutils.cpp @@ -26,6 +26,7 @@ #include <fmt/format.cc> #include "inspircd.h" +#include "stringutils.h" #include "utility/string.h" std::string Percent::Encode(const void* data, size_t length, const char* table, bool upper) diff --git a/src/xline.cpp b/src/xline.cpp index 43e7f1479..44a54197b 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -28,6 +28,7 @@ #include "inspircd.h" #include "modules/stats.h" +#include "stringutils.h" #include "timeutils.h" #include "xline.h" |
