2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2017-2018 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2014, 2018 Attila Molnar <attilamolnar@hush.com>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 /** A single mode to be changed
38 * @param handler Mode handler
39 * @param add True if this mode is being set, false if removed
40 * @param parameter Mode parameter
42 Change(ModeHandler* handler, bool add, const std::string& parameter)
50 /** A list of mode changes that can be applied on a Channel or User
52 class Modes::ChangeList
55 typedef std::vector<Change> List;
57 /** Add a new mode to be changed to this ChangeList
58 * @param change Mode change to add
60 void push(const Modes::Change& change)
62 items.push_back(change);
65 /** Insert multiple mode changes to the ChangeList
66 * @param first Iterator to the first change to insert
67 * @param last Iterator to the first change to not insert
69 void push(List::const_iterator first, List::const_iterator last)
71 items.insert(items.end(), first, last);
74 /** Add a new mode to be changed to this ChangeList
75 * @param mh Mode handler
76 * @param adding True if this mode is being set, false if removed
77 * @param param Mode parameter
79 void push(ModeHandler* mh, bool adding, const std::string& param = std::string())
81 items.push_back(Change(mh, adding, param));
84 /** Add a new mode to this ChangeList which will be set on the target
85 * @param mh Mode handler
86 * @param param Mode parameter
88 void push_add(ModeHandler* mh, const std::string& param = std::string())
90 push(mh, true, param);
93 /** Add a new mode to this ChangeList which will be unset from the target
94 * @param mh Mode handler
95 * @param param Mode parameter
97 void push_remove(ModeHandler* mh, const std::string& param = std::string())
99 push(mh, false, param);
102 /** Remove all mode changes from this stack
104 void clear() { items.clear(); }
106 /** Checks whether the ChangeList is empty, equivalent to (size() != 0).
107 * @return True if the ChangeList is empty, false otherwise.
109 bool empty() const { return items.empty(); }
111 /** Get number of mode changes in this ChangeList
112 * @return Number of mode changes in this ChangeList
114 List::size_type size() const { return items.size(); }
116 /** Get the list of mode changes in this ChangeList
117 * @return List of modes added to this ChangeList
119 const List& getlist() const { return items; }
121 /** Get the list of mode changes in this ChangeList
122 * @return List of modes added to this ChangeList
124 List& getlist() { return items; }