Yate
MatchingItemList Class Reference

A list of matching items. More...

#include <yateclass.h>

Inheritance diagram for MatchingItemList:
MatchingItemBase GenObject

Public Member Functions

 MatchingItemList (const char *name, bool matchAll=true, bool negated=false)
 
bool matchAll () const
 
unsigned int length () const
 
unsigned int count () const
 
const MatchingItemBaseat (unsigned int index) const
 
int indexOf (const String &name) const
 
const MatchingItemBasefind (const String &name) const
 
bool change (MatchingItemBase *item, int pos=-1, bool ins=false, unsigned int overAlloc=1)
 
bool append (MatchingItemBase *item, unsigned int overAlloc=1)
 
void append (ObjList &list)
 
bool set (MatchingItemBase *item, unsigned int pos, unsigned int overAlloc=1)
 
bool insert (MatchingItemBase *item, unsigned int pos=0, unsigned int overAlloc=1)
 
virtual bool runMatchString (const String &str, MatchingParams *params=0) const
 
virtual bool runMatchListParam (const NamedList &list, MatchingParams *params=0) const
 
virtual MatchingItemBasecopy () const
 
virtual const MatchingItemListitemList () const
 
- Public Member Functions inherited from MatchingItemBase
 MatchingItemBase (const char *name, bool negated=false)
 
const Stringname () const
 
bool negated () const
 
bool matchString (const String &str, MatchingParams *params=0) const
 
bool matchListParam (const NamedList &list, MatchingParams *params=0) const
 
virtual const MatchingItemStringitemString () const
 
virtual const MatchingItemRegexpitemRegexp () const
 
virtual const MatchingItemRandomitemRandom () const
 
virtual const MatchingItemCustomitemCustom () const
 
virtual Stringdump (String &buf, const MatchingItemDump *dump=0, const String &indent=String::empty(), const String &origIndent=String::empty(), unsigned int depth=0) const
 
virtual StringdumpValue (String &buf, const MatchingItemDump *dump=0, const String &indent=String::empty(), const String &origIndent=String::empty(), unsigned int depth=0) const
 
virtual GenObjectdumpXml (const MatchingItemDump *dump=0, unsigned int depth=0) const
 
virtual const StringtoString () const
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual bool alive () const
 
virtual void destruct ()
 
virtual const StringtraceId () const
 
virtual void * getObject (const String &name) const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 

Static Public Member Functions

static MatchingItemBaseoptimize (MatchingItemList *list)
 
- Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
 
static bool getObjCounting ()
 
static void setObjCounting (bool enable)
 
static NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 

Detailed Description

A list of matching items.

List of matching items

Constructor & Destructor Documentation

◆ MatchingItemList()

MatchingItemList ( const char * name,
bool matchAll = true,
bool negated = false )
inline

Constructor

Parameters
nameItem name
matchAllTrue to match all items (logical AND), false to match any item (logical OR)
negatedTrue if matching is negated (return the opposite of match in public methods), false otherwise

Member Function Documentation

◆ append() [1/2]

bool append ( MatchingItemBase * item,
unsigned int overAlloc = 1 )
inline

Append an item to the list

Parameters
itemItem to append, pointer will be consumed
overAllocOptional number of items to over allocate This parameter is ignored if there is enough space in the list set append the item
Returns
True on success, false on failure (memory allocation error or NULL pointer given)

◆ append() [2/2]

void append ( ObjList & list)
inline

Append a list of items to the list

Parameters
listItems list

References ObjList::count(), ObjList::remove(), and ObjList::skipNull().

◆ at()

const MatchingItemBase * at ( unsigned int index) const
inline

Retrieve a pointer to item at given index

Parameters
indexIndex to retrieve
Returns
MatchingItemBase pointer, NULL if not set or index is out of bounds

◆ change()

bool change ( MatchingItemBase * item,
int pos = -1,
bool ins = false,
unsigned int overAlloc = 1 )

Change list (append,insert,replace,remove) Item is removed if given pointer is NULL, position is valid and 'ins' is false

Parameters
itemItem to set, pointer will be consumed
posItem position. Append if negative or past list length
insSet it to true to insert, false to replace or append
overAllocOptional number of items to over allocate This parameter is ignored if there is enough space in the list set append the item
Returns
True on success, false on failure (memory allocation error or NULL pointer given)

◆ copy()

virtual MatchingItemBase * copy ( ) const
virtual

Copy this item

Returns
MatchingItemBase pointer

Reimplemented from MatchingItemBase.

◆ count()

unsigned int count ( ) const
inline

Retrieve the number of non empty items in list

Returns
The number of non empty items in list

◆ find()

const MatchingItemBase * find ( const String & name) const
inline

Find an item by name

Parameters
nameItem name
Returns
MatchingItemBase pointer, NULL if not found

◆ indexOf()

int indexOf ( const String & name) const
inline

Retrieve the index of an item found by name

Parameters
nameItem name
Returns
Index of found item, negative if not found

◆ insert()

bool insert ( MatchingItemBase * item,
unsigned int pos = 0,
unsigned int overAlloc = 1 )
inline

Insert an item at list start

Parameters
itemItem to insert, pointer will be consumed
posItem position. Append if past list length
overAllocOptional number of items to over allocate This parameter is ignored if there is enough space in the list set append the item
Returns
True on success, false on failure (memory allocation error or NULL pointer given)

◆ itemList()

virtual const MatchingItemList * itemList ( ) const
inlinevirtual

Check if this item is a MatchingItemList one

Returns
MatchingItemList pointer

Reimplemented from MatchingItemBase.

◆ length()

unsigned int length ( ) const
inline

Retrieve the list length

Returns
List length

◆ matchAll()

bool matchAll ( ) const
inline

Check if all items must match

Returns
True if all items must match (logical AND), false if any item matches (logical OR)

◆ optimize()

static MatchingItemBase * optimize ( MatchingItemList * list)
static

Optimize a MatchingItemList Delete list if empty or there is only one item in it, return the first item in it any

Parameters
listList to optimize
Returns
MatchingItemBase pointer, may be the list itself if not optimized May be NULL if list is empty

◆ runMatchListParam()

virtual bool runMatchListParam ( const NamedList & list,
MatchingParams * params = 0 ) const
virtual

NamedList parameter match

Parameters
listList to search for parameter match
paramsOptional parameters used during match
Returns
True if matches, false otherwise

Reimplemented from MatchingItemBase.

◆ runMatchString()

virtual bool runMatchString ( const String & str,
MatchingParams * params = 0 ) const
virtual

String match

Parameters
strString to match
paramsOptional parameters used during match
Returns
True if matched, false otherwise

Reimplemented from MatchingItemBase.

◆ set()

bool set ( MatchingItemBase * item,
unsigned int pos,
unsigned int overAlloc = 1 )
inline

Set an item at given position Item is removed if given pointer is NULL

Parameters
itemItem to set, pointer will be consumed
posItem position. Append if past list length
overAllocOptional number of items to over allocate This parameter is ignored if there is enough space in the list set append the item
Returns
True on success, false on failure (memory allocation error or NULL pointer given)

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