# NamedList Class Reference

A named string container class. More...

`#include <yateclass.h>`

Inheritance diagram for NamedList:

List of all members.

## Public Member Functions

| NamedList (const char *name)
| NamedList (const NamedList &original)
virtual void * | getObject (const String &name) const
unsigned int | length () const
unsigned int | count () const
NamedList & | addParam (NamedString *param)
NamedList & | addParam (const char *name, const char *value)
NamedList & | setParam (NamedString *param)
NamedList & | setParam (const char *name, const char *value)
NamedList & | clearParam (const String &name, char childSep=0)
NamedList & | copyParam (const NamedList &original, const String &name, char childSep=0)
NamedList & | copyParams (const NamedList &original, ObjList *list, char childSep=0)
NamedList & | copyParams (const NamedList &original, const String &list, char childSep=0)
int | getIndex (const NamedString *param) const
int | getIndex (const String &name) const
NamedString * | getParam (const String &name) const
NamedString * | getParam (unsigned int index) const
const char * | getValue (const String &name, const char *defvalue=0) const
int | getIntValue (const String &name, int defvalue=0) const
int | getIntValue (const String &name, const TokenDict *tokens, int defvalue=0) const
double | getDoubleValue (const String &name, double defvalue=0.0) const
bool | getBoolValue (const String &name, bool defvalue=false) const
int | replaceParams (String &str, bool sqlEsc=false, char extraEsc=0) const

## Detailed Description

A named string container class.

This class holds a named list of named strings

## Constructor & Destructor Documentation

NamedList | ( | const char * | name | ) |

Creates a new named list.

Parameters:

  | name | Name of the list - must not be NULL or empty

NamedList | ( | const NamedList & | original | ) |

Copy constructor

Parameters:

  | original | Named list we are copying

## Member Function Documentation

virtual void* getObject | ( | const String & | name | ) | const`[virtual]`

Get a pointer to a derived class given that class name

Parameters:

  | name | Name of the class we are asking for

Returns:
  Pointer to the requested class or NULL if this object doesn't implement it

Reimplemented from String.

Reimplemented in Message.

unsigned int length | ( |  | ) | const`[inline]`

Get the number of parameters

Returns:
  Count of named strings

Reimplemented from String.

unsigned int count | ( |  | ) | const`[inline]`

Get the number of non-null parameters

Returns:
  Count of existing named strings

NamedList& addParam | ( | NamedString * | param | ) |

Add a named string to the parameter list.

Parameters:

  | param | Parameter to add

NamedList& addParam | ( | const char * | name,
|  | const char * | value |
| ) |  |  |

Add a named string to the parameter list.

Parameters:

  | name | Name of the new string
  | value | Value of the new string

NamedList& setParam | ( | NamedString * | param | ) |

Set a named string in the parameter list.

Parameters:

  | param | Parameter to set or add

NamedList& setParam | ( | const char * | name,
|  | const char * | value |
| ) |  |  |

Set a named string in the parameter list.

Parameters:

  | name | Name of the string
  | value | Value of the string

NamedList& clearParam | ( | const String & | name,
|  | char | childSep = `0` |
| ) |  |  |

Clears all instances of a named string in the parameter list.

Parameters:

  | name | Name of the string to remove
  | childSep | If set clears all child parameters in format name+childSep+anything

NamedList& copyParam | ( | const NamedList & | original,
|  | const String & | name,
|  | char | childSep = `0` |
| ) |  |  |

Copy a parameter from another NamedList, clears it if not present there

Parameters:

  | original | NamedList to copy the parameter from
  | name | Name of the string to copy or clear
  | childSep | If set copies all child parameters in format name+childSep+anything

NamedList& copyParams | ( | const NamedList & | original,
|  | ObjList * | list,
|  | char | childSep = `0` |
| ) |  |  |

Copy multiple parameters from another NamedList, clears them if not present there

Parameters:

  | original | NamedList to copy the parameters from
  | list | List of objects (usually String) whose name (blanks stripped) is used as parameters names
  | childSep | If set copies all child parameters in format name+childSep+anything

NamedList& copyParams | ( | const NamedList & | original,
|  | const String & | list,
|  | char | childSep = `0` |
| ) |  |  |

Copy multiple parameters from another NamedList, clears it if not present there

Parameters:

  | original | NamedList to copy the parameter from
  | list | Comma separated list of parameters to copy or clear
  | childSep | If set copies all child parameters in format name+childSep+anything

int getIndex | ( | const NamedString * | param | ) | const

Get the index of a named string in the parameter list.

Parameters:

  | param | Pointer to the parameter to locate

Returns:
  Index of the named string or -1 if not found

int getIndex | ( | const String & | name | ) | const

Get the index of first matching named string in the parameter list.

Parameters:

  | name | Name of parameter to locate

Returns:
  Index of the first matching named string or -1 if not found

NamedString* getParam | ( | const String & | name | ) | const

Locate a named string in the parameter list.

Parameters:

  | name | Name of parameter to locate

Returns:
  A pointer to the named string or NULL.

NamedString* getParam | ( | unsigned int | index | ) | const

Locate a named string in the parameter list.

Parameters:

  | index | Index of the parameter to locate

Returns:
  A pointer to the named string or NULL.

const char* getValue | ( | const String & | name,
|  | const char * | defvalue = `0` |
| ) |  |  | const

Retrive the value of a named parameter.

Parameters:

  | name | Name of parameter to locate
  | defvalue | Default value to return if not found

Returns:
  The string contained in the named parameter or the default

int getIntValue | ( | const String & | name,
|  | int | defvalue = `0` |
| ) |  |  | const

Retrive the numeric value of a parameter.

Parameters:

  | name | Name of parameter to locate
  | defvalue | Default value to return if not found

Returns:
  The number contained in the named parameter or the default

int getIntValue | ( | const String & | name,
|  | const TokenDict * | tokens,
|  | int | defvalue = `0` |
| ) |  |  | const

Retrive the numeric value of a parameter trying first a table lookup.

Parameters:

  | name | Name of parameter to locate
  | tokens | A pointer to an array of tokens to try to lookup
  | defvalue | Default value to return if not found

Returns:
  The number contained in the named parameter or the default

double getDoubleValue | ( | const String & | name,
|  | double | defvalue = `0.0` |
| ) |  |  | const

Retrive the floating point value of a parameter.

Parameters:

  | name | Name of parameter to locate
  | defvalue | Default value to return if not found

Returns:
  The number contained in the named parameter or the default

bool getBoolValue | ( | const String & | name,
|  | bool | defvalue = `false` |
| ) |  |  | const

Retrive the boolean value of a parameter.

Parameters:

  | name | Name of parameter to locate
  | defvalue | Default value to return if not found

Returns:
  The boolean value contained in the named parameter or the default

int replaceParams | ( | String & | str,
|  | bool | sqlEsc = `false`,
|  | char | extraEsc = `0` |
| ) |  |  | const

Replaces all ${paramname} in a String with the corresponding parameters

Parameters:

  | str | String in which the replacements will be made
  | sqlEsc | True to apply SQL escaping to parameter values
  | extraEsc | Character to escape other than the SQL default ones

Returns:
  Number of replacements made, -1 if an error occured

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

- yateclass.h