# class NamedList | A named string container class. More...
Full name | `TelEngine::NamedList`
Definition | `#include <yateclass.h>`
Inherits | TelEngine::String [public ]
Inherited by | DataFormat, Message
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- explicit NamedList (const char* name)
- NamedList (const NamedList& original)
- NamedList (const char* name, const NamedList& original, const String& prefix)
- NamedList& operator= (const NamedList& value)
- virtual void* getObject (const String& name) const
- inline unsigned int length () const
- inline unsigned int count () const
- inline void clearParams ()
- NamedList& addParam (NamedString* param)
- NamedList& addParam (const char* name, const char* value, bool emptyOK = true)
- NamedList& setParam (NamedString* param)
- NamedList& setParam (const char* name, const char* value)
- NamedList& clearParam (const String& name, char childSep = 0)
- NamedList& clearParam (NamedString* param)
- NamedList& copyParam (const NamedList& original, const String& name, char childSep = 0)
- NamedList& copyParams (const NamedList& original)
- NamedList& copyParams (const NamedList& original, ObjList* list, char childSep = 0)
- NamedList& copyParams (const NamedList& original, const String& list, char childSep = 0)
- NamedList& copySubParams (const NamedList& original, const String& prefix, bool skipPrefix = true)
- bool hasSubParams (const char* prefix) const
- 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 String& operator[] (const String& name) const
- const char* getValue (const String& name, const char* defvalue = 0) const
- int getIntValue (const String& name, int defvalue = 0, int minvalue = INT_MIN, int maxvalue = INT_MAX, bool clamp = true) 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
- void dump (String& str, const char* separator, char quote = 0, bool force = false) const

#### Public Static Methods

- static const NamedList& empty ()

## Detailed Description

This class holds a named list of named strings

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

Creates a new named list.

Parameters:

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

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

Copy constructor

Parameters:

original | Named list we are copying

NamedList (const char* name, const NamedList& original, const String& prefix) | ### NamedList

Creates a named list with subparameters of another list.

Parameters:

name | Name of the list - must not be NULL or empty
original | Named list to copy parameters from
prefix | Prefix to match and remove from parameter names

NamedList& operator= (const NamedList& value) | ### operator=

Assignment operator

Parameters:

value | New name and parameters to assign

Returns: Reference to this NamedList

Reimplemented from String.

void* getObject (const String& name) | ### getObject

[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.

inline unsigned int length () | ### length

[const]

Get the number of parameters

Returns: Count of named strings

Reimplemented from String.

inline unsigned int count () | ### count

[const]

Get the number of non-null parameters

Returns: Count of existing named strings

inline void clearParams () | ### clearParams

Clear all parameters

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

Add a named string to the parameter list.

Parameters:

param | Parameter to add

Returns: Reference to this NamedList

NamedList& addParam (const char* name, const char* value, bool emptyOK = true) | ### addParam

Add a named string to the parameter list.

Parameters:

name | Name of the new string
value | Value of the new string
emptyOK | True to always add parameter, false to skip empty values

Returns: Reference to this NamedList

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

Set a named string in the parameter list.

Parameters:

param | Parameter to set or add

Returns: Reference to this NamedList

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

Set a named string in the parameter list.

Parameters:

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

Returns: Reference to this NamedList

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

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

Returns: Reference to this NamedList

NamedList& clearParam (NamedString* param) | ### clearParam

Remove a specific parameter

Parameters:

param | Pointer to parameter to remove

Returns: Reference to this NamedList

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

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

Returns: Reference to this NamedList

NamedList& copyParams (const NamedList& original) | ### copyParams

Copy all parameters from another NamedList, does not clear list first

Parameters:

original | NamedList to copy the parameters from

Returns: Reference to this NamedList

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

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

Returns: Reference to this NamedList

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

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

Returns: Reference to this NamedList

NamedList& copySubParams (const NamedList& original, const String& prefix, bool skipPrefix = true) | ### copySubParams

Copy subparameters from another list

Parameters:

original | Named list to copy parameters from
prefix | Prefix to match in parameter names, must not be NULL
skipPrefix | Skip over the prefix when building new parameter name

Returns: Reference to this NamedList

bool hasSubParams (const char* prefix) | ### hasSubParams

[const]

Check if we have a parameter that starts with prefix

Parameters:

prefix | Prefix to match in parameter name, must not be NULL

Returns: True if a parameter starts with prefix

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

[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) | ### getIndex

[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) | ### getParam

[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) | ### getParam

[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 String& operator[] (const String& name) | ### operator[]

[const]

Parameter access operator

Parameters:

name | Name of the parameter to return

Returns: String value of the parameter, String::empty() if missing

Reimplemented from String.

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

[const]

Retrieve 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, int minvalue = INT_MIN, int maxvalue = INT_MAX, bool clamp = true) | ### getIntValue

[const]

Retrieve the numeric value of a parameter.

Parameters:

name | Name of parameter to locate
defvalue | Default value to return if not found
minvalue | Minimum value allowed for the parameter
maxvalue | Maximum value allowed for the parameter
clamp | Control the out of bound values: true to adjust to the nearest bound, false to return the default value

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

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

[const]

Retrieve 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) | ### getDoubleValue

[const]

Retrieve 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) | ### getBoolValue

[const]

Retrieve 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) | ### replaceParams

[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

void dump (String& str, const char* separator, char quote = 0, bool force = false) | ### dump

[const]

Dumps the name and all parameters to a string in a human readable format. No escaping takes place so this method should be used for debugging only

Parameters:

str | String to which the name and parameters are appended
separator | Separator string to use before each parameter
quote | String quoting character, usually single or double quote
force | True to insert the separator even in an empty string

const NamedList& empty () | ### empty

[static]

A static empty named list

Returns: Reference to a static empty named list

Reimplemented from String.

Generated by: paulc on bussard on Fri Dec 21 16:28:34 2012, using kdoc 2.0a54.