]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/token_list.h
Use IsCTCP in blockcolor for ignoring CTCPs.
[user/henk/code/inspircd.git] / include / token_list.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2017 Sadie Powell <sadie@witchery.services>
5  *
6  * This file is part of InspIRCd.  InspIRCd is free software: you can
7  * redistribute it and/or modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation, version 2.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19
20 #pragma once
21
22 #include "compat.h"
23
24 class CoreExport TokenList
25 {
26  private:
27         /** Whether this list includes all tokens by default. */
28         bool permissive;
29
30         /** Either the tokens to exclude if in permissive mode or the tokens to include if in strict mode. */
31         insp::flat_set<std::string, irc::insensitive_swo> tokens;
32
33  public:
34         /** Adds a space-delimited list of tokens to the token list.
35          * @param tokenlist The list of space-delimited tokens to add.
36          */
37         void AddList(const std::string& tokenlist);
38
39         /** Adds a single token to the token list.
40          * @param token The token to add.
41          */
42         void Add(const std::string& token);
43
44         /** Removes all tokens from the token list. */
45         void Clear();
46
47         /** Determines whether the specified token exists in the token list.
48          * @param token The token to search for.
49          */
50         bool Contains(const std::string& token) const;
51
52         /** Removes the specified token from the token list.
53          * @param token The token to remove.
54          */
55         void Remove(const std::string& token);
56
57         /** Retrieves a string which represents the contents of this token list. */
58         std::string ToString() const;
59
60         /** Determines whether the specified token list contains the same tokens as this instance.
61          * @param other The tokenlist to compare against.
62          * @return True if the token lists are equal; otherwise, false.
63          */
64         bool operator==(const TokenList& other) const;
65 };