InspIRCd  3.0
modechange.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2017-2018 Sadie Powell <[email protected]>
5  * Copyright (C) 2014, 2018 Attila Molnar <[email protected]>
6  *
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.
10  *
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
14  * details.
15  *
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/>.
18  */
19 
20 
21 #pragma once
22 
23 namespace Modes
24 {
25  struct Change;
26  class ChangeList;
27 }
28 
32 {
33  bool adding;
34  ModeHandler* mh;
35  std::string param;
36 
42  Change(ModeHandler* handler, bool add, const std::string& parameter)
43  : adding(add)
44  , mh(handler)
45  , param(parameter)
46  {
47  }
48 };
49 
53 {
54  public:
55  typedef std::vector<Change> List;
56 
60  void push(const Modes::Change& change)
61  {
62  items.push_back(change);
63  }
64 
69  void push(List::const_iterator first, List::const_iterator last)
70  {
71  items.insert(items.end(), first, last);
72  }
73 
79  void push(ModeHandler* mh, bool adding, const std::string& param = std::string())
80  {
81  items.push_back(Change(mh, adding, param));
82  }
83 
88  void push_add(ModeHandler* mh, const std::string& param = std::string())
89  {
90  push(mh, true, param);
91  }
92 
97  void push_remove(ModeHandler* mh, const std::string& param = std::string())
98  {
99  push(mh, false, param);
100  }
101 
104  void clear() { items.clear(); }
105 
109  bool empty() const { return items.empty(); }
110 
114  List::size_type size() const { return items.size(); }
115 
119  const List& getlist() const { return items; }
120 
124  List& getlist() { return items; }
125 
126  private:
127  List items;
128 };
Modes::ChangeList::getlist
const List & getlist() const
Definition: modechange.h:119
Modes::ChangeList
Definition: modechange.h:52
Modes::ChangeList::push
void push(List::const_iterator first, List::const_iterator last)
Definition: modechange.h:69
Modes::ChangeList::push
void push(ModeHandler *mh, bool adding, const std::string &param=std::string())
Definition: modechange.h:79
Modes::Change
Definition: modechange.h:31
Modes::ChangeList::push_add
void push_add(ModeHandler *mh, const std::string &param=std::string())
Definition: modechange.h:88
Modes::ChangeList::empty
bool empty() const
Definition: modechange.h:109
Modes::ChangeList::push
void push(const Modes::Change &change)
Definition: modechange.h:60
Modes::ChangeList::size
List::size_type size() const
Definition: modechange.h:114
Modes::ChangeList::getlist
List & getlist()
Definition: modechange.h:124
Modes::Change::Change
Change(ModeHandler *handler, bool add, const std::string &parameter)
Definition: modechange.h:42
Modes::ChangeList::clear
void clear()
Definition: modechange.h:104
Modes::ChangeList::push_remove
void push_remove(ModeHandler *mh, const std::string &param=std::string())
Definition: modechange.h:97
ModeHandler
Definition: mode.h:99