Yate: MatchingItemList Class Reference

Yate

Public Member Functions | Static Public Member Functions | List of all members
MatchingItemList Class Reference

A list of matching items. More...

`#include <yateclass.h>`

Inheritance diagram for MatchingItemList:

## 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 MatchingItemBase * | at (unsigned int index) const
int | indexOf (const String &name) const
const MatchingItemBase * | find (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 MatchingItemBase * | copy () const
virtual const MatchingItemList * | itemList () const
Public Member Functions inherited from MatchingItemBase
| MatchingItemBase (const char *name, bool negated=false)
const String & | name () const
bool | negated () const
bool | matchString (const String &str, MatchingParams *params=0) const
bool | matchListParam (const NamedList &list, MatchingParams *params=0) const
virtual const MatchingItemString * | itemString () const
virtual const MatchingItemRegexp * | itemRegexp () const
virtual const MatchingItemRandom * | itemRandom () const
virtual const MatchingItemCustom * | itemCustom () const
virtual String & | dump (String &buf, const MatchingItemDump *dump=0, const String &indent=String::empty(), const String &origIndent=String::empty(), unsigned int depth=0) const
virtual String & | dumpValue (String &buf, const MatchingItemDump *dump=0, const String &indent=String::empty(), const String &origIndent=String::empty(), unsigned int depth=0) const
virtual GenObject * | dumpXml (const MatchingItemDump *dump=0, unsigned int depth=0) const
virtual const String & | toString () const
Public Member Functions inherited from GenObject
| GenObject ()
virtual | ~GenObject ()
virtual bool | alive () const
virtual void | destruct ()
virtual const String & | traceId () const
virtual void * | getObject (const String &name) const
NamedCounter * | getObjCounter () const
NamedCounter * | setObjCounter (NamedCounter *counter)

## Static Public Member Functions
static MatchingItemBase * | optimize (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 NamedCounter * | getObjCounter (const String &name, bool create=true)
static ObjList & | getObjCounters ()

## 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

  name | Item name
  matchAll | True to match all items (logical AND), false to match any item (logical OR)
  negated | True 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

  item | Item to append, pointer will be consumed
  overAlloc | Optional 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

  list | Items 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

  index | Index 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

  item | Item to set, pointer will be consumed
  pos | Item position. Append if negative or past list length
  ins | Set it to true to insert, false to replace or append
  overAlloc | Optional 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

  name | Item 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

  name | Item 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

  item | Item to insert, pointer will be consumed
  pos | Item position. Append if past list length
  overAlloc | Optional 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

  list | List 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

  list | List to search for parameter match
  params | Optional 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

  str | String to match
  params | Optional 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

  item | Item to set, pointer will be consumed
  pos | Item position. Append if past list length
  overAlloc | Optional 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:

- yateclass.h