Anope IRC Services  Version 2.0
Public Member Functions | Private Attributes
NumberList Class Reference

#include <lists.h>

Inheritance diagram for NumberList:
Inheritance graph

Public Member Functions

 NumberList (const Anope::string &list, bool descending)
virtual ~NumberList ()
void Process ()
virtual void HandleNumber (unsigned number)
virtual bool InvalidRange (const Anope::string &list)

Private Attributes

bool is_valid
std::set< unsigned > numbers
bool desc

Detailed Description

A class to process numbered lists (passed to most DEL/LIST/VIEW commands). The function HandleNumber is called for every number in the list. Note that if descending is true it gets called in descending order. This is so deleting the index passed to the function from an array will not cause the other indexes passed to the function to be incorrect. This keeps us from having to have an 'in use' flag on everything.

Definition at line 26 of file lists.h.

Constructor & Destructor Documentation

◆ NumberList()

NumberList::NumberList ( const Anope::string list,
bool  descending 

Processes a numbered list

listThe list
descendingTrue to make HandleNumber get called with numbers in descending order

Definition at line 31 of file misc.cpp.

References Anope::string::empty(), Anope::string::find(), sepstream::GetToken(), InvalidRange(), is_valid, Anope::string::npos, numbers, and Anope::string::substr().

Referenced by CommandOSSXLineBase::ProcessList(), and CommandOSAKill::ProcessList().

◆ ~NumberList()

NumberList::~NumberList ( )

Destructor, does nothing

Definition at line 94 of file misc.cpp.

Member Function Documentation

◆ HandleNumber()

void NumberList::HandleNumber ( unsigned  number)

Called with a number from the list

numberThe number

Reimplemented in BadwordsDelCallback, ExceptionDelCallback, MemoListCallback, AkillDelCallback, SXLineDelCallback, and MemoDelCallback.

Definition at line 115 of file misc.cpp.

Referenced by Process().

◆ InvalidRange()

bool NumberList::InvalidRange ( const Anope::string list)

Called when there is an error with the numbered list Return false to immediatly stop processing the list and return This is all done before we start calling HandleNumber, so no numbers will have been processed yet

listThe list
false to stop processing

Definition at line 119 of file misc.cpp.

Referenced by NumberList().

◆ Process()

void NumberList::Process ( )

Should be called after the constructors are done running. This calls the callbacks.

Definition at line 98 of file misc.cpp.

References desc, HandleNumber(), is_valid, and numbers.

Referenced by CommandOSAKill::DoDel(), CommandOSException::DoDel(), CommandBSBadwords::DoDelete(), CommandMSDel::Execute(), CommandMSRead::Execute(), and CommandOSSXLineBase::OnDel().

Field Documentation

◆ desc

bool NumberList::desc

Definition at line 33 of file lists.h.

Referenced by Process().

◆ is_valid

bool NumberList::is_valid

Definition at line 29 of file lists.h.

Referenced by NumberList(), and Process().

◆ numbers

std::set<unsigned> NumberList::numbers

Definition at line 31 of file lists.h.

Referenced by NumberList(), and Process().

The documentation for this class was generated from the following files: