2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
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.
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
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/>.
28 /** A single mode to be changed
37 * @param handler Mode handler
38 * @param add True if this mode is being set, false if removed
39 * @param parameter Mode parameter
41 Change(ModeHandler* handler, bool add, const std::string& parameter)
49 /** A list of mode changes that can be applied on a Channel or User
51 class Modes::ChangeList
54 typedef std::vector<Change> List;
56 /** Add a new mode to be changed to this ChangeList
57 * @param change Mode change to add
59 void push(const Modes::Change& change)
61 items.push_back(change);
64 /** Insert multiple mode changes to the ChangeList
65 * @param first Iterator to the first change to insert
66 * @param last Iterator to the first change to not insert
68 void push(List::const_iterator first, List::const_iterator last)
70 items.insert(items.end(), first, last);
73 /** Add a new mode to be changed to this ChangeList
74 * @param mh Mode handler
75 * @param adding True if this mode is being set, false if removed
76 * @param param Mode parameter
78 void push(ModeHandler* mh, bool adding, const std::string& param = std::string())
80 items.push_back(Change(mh, adding, param));
83 /** Add a new mode to this ChangeList which will be set on the target
84 * @param mh Mode handler
85 * @param param Mode parameter
87 void push_add(ModeHandler* mh, const std::string& param = std::string())
89 push(mh, true, param);
92 /** Add a new mode to this ChangeList which will be unset from the target
93 * @param mh Mode handler
94 * @param param Mode parameter
96 void push_remove(ModeHandler* mh, const std::string& param = std::string())
98 push(mh, false, param);
101 /** Remove all mode changes from this stack
103 void clear() { items.clear(); }
105 /** Checks whether the ChangeList is empty, equivalent to (size() != 0).
106 * @return True if the ChangeList is empty, false otherwise.
108 bool empty() const { return items.empty(); }
110 /** Get number of mode changes in this ChangeList
111 * @return Number of mode changes in this ChangeList
113 List::size_type size() const { return items.size(); }
115 /** Get the list of mode changes in this ChangeList
116 * @return List of modes added to this ChangeList
118 const List& getlist() const { return items; }
120 /** Get the list of mode changes in this ChangeList
121 * @return List of modes added to this ChangeList
123 List& getlist() { return items; }