Yate
Public Member Functions | Static Public Member Functions | Friends
NamedList Class Reference

A named string container class. More...

#include <yateclass.h>

Inheritance diagram for NamedList:
String GenObject CallInfo DataFormat ISDNQ931IE Message SDPMedia SignallingCircuitEvent

List of all members.

Public Member Functions

 NamedList (const char *name)
 NamedList (const NamedList &original)
 NamedList (const char *name, const NamedList &original, const String &prefix)
NamedListoperator= (const NamedList &value)
virtual void * getObject (const String &name) const
unsigned int length () const
unsigned int count () const
void clearParams ()
NamedListaddParam (NamedString *param)
NamedListaddParam (const char *name, const char *value, bool emptyOK=true)
NamedListsetParam (NamedString *param)
NamedListsetParam (const char *name, const char *value)
NamedListclearParam (const String &name, char childSep=0)
NamedListclearParam (NamedString *param)
NamedListcopyParam (const NamedList &original, const String &name, char childSep=0)
NamedListcopyParams (const NamedList &original)
NamedListcopyParams (const NamedList &original, ObjList *list, char childSep=0)
NamedListcopyParams (const NamedList &original, const String &list, char childSep=0)
NamedListcopySubParams (const NamedList &original, const String &prefix, bool skipPrefix=true)
int getIndex (const NamedString *param) const
int getIndex (const String &name) const
NamedStringgetParam (const String &name) const
NamedStringgetParam (unsigned int index) const
const Stringoperator[] (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

Static Public Member Functions

static const NamedListempty ()

Friends

class NamedIterator

Detailed Description

A named string container class.

This class holds a named list of named strings


Constructor & Destructor Documentation

NamedList ( const char *  name) [explicit]

Creates a new named list.

Parameters:
nameName of the list - must not be NULL or empty
NamedList ( const NamedList original)

Copy constructor

Parameters:
originalNamed list we are copying
NamedList ( const char *  name,
const NamedList original,
const String prefix 
)

Creates a named list with subparameters of another list.

Parameters:
nameName of the list - must not be NULL or empty
originalNamed list to copy parameters from
prefixPrefix to match and remove from parameter names

Member Function Documentation

Add a named string to the parameter list.

Parameters:
paramParameter to add
Returns:
Reference to this NamedList

Referenced by ISDNQ931Message::appendIEValue(), and MucRoom::buildMucRoom().

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

Add a named string to the parameter list.

Parameters:
nameName of the new string
valueValue of the new string
emptyOKTrue to always add parameter, false to skip empty values
Returns:
Reference to this NamedList
NamedList& clearParam ( const String name,
char  childSep = 0 
)

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

Parameters:
nameName of the string to remove
childSepIf set clears all child parameters in format name+childSep+anything
Returns:
Reference to this NamedList

Remove a specific parameter

Parameters:
paramPointer to parameter to remove
Returns:
Reference to this NamedList
void clearParams ( ) [inline]

Clear all parameters

Referenced by JGRtpMedia::set().

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

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

Parameters:
originalNamedList to copy the parameter from
nameName of the string to copy or clear
childSepIf set copies all child parameters in format name+childSep+anything
Returns:
Reference to this NamedList
NamedList& copyParams ( const NamedList original)

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

Parameters:
originalNamedList to copy the parameters from
Returns:
Reference to this NamedList
NamedList& copyParams ( const NamedList original,
ObjList list,
char  childSep = 0 
)

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

Parameters:
originalNamedList to copy the parameters from
listList of objects (usually String) whose name (blanks stripped) is used as parameters names
childSepIf 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 
)

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

Parameters:
originalNamedList to copy the parameter from
listComma separated list of parameters to copy or clear
childSepIf 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 
)

Copy subparameters from another list

Parameters:
originalNamed list to copy parameters from
prefixPrefix to match in parameter names, must not be NULL
skipPrefixSkip over the prefix when building new parameter name
Returns:
Reference to this NamedList
unsigned int count ( ) const [inline]

Get the number of non-null parameters

Returns:
Count of existing named strings
void dump ( String str,
const char *  separator,
char  quote = 0,
bool  force = false 
) 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:
strString to which the name and parameters are appended
separatorSeparator string to use before each parameter
quoteString quoting character, usually single or double quote
forceTrue to insert the separator even in an empty string
static const NamedList& empty ( ) [static]

A static empty named list

Returns:
Reference to a static empty named list

Reimplemented from String.

bool getBoolValue ( const String name,
bool  defvalue = false 
) const

Retrieve the boolean value of a parameter.

Parameters:
nameName of parameter to locate
defvalueDefault value to return if not found
Returns:
The boolean value contained in the named parameter or the default
double getDoubleValue ( const String name,
double  defvalue = 0.0 
) const

Retrieve the floating point value of a parameter.

Parameters:
nameName of parameter to locate
defvalueDefault value to return if not found
Returns:
The number contained in the named parameter or the default
int getIndex ( const NamedString param) const

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

Parameters:
paramPointer 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:
nameName of parameter to locate
Returns:
Index of the first matching named string or -1 if not found
int getIntValue ( const String name,
int  defvalue = 0,
int  minvalue = INT_MIN,
int  maxvalue = INT_MAX,
bool  clamp = true 
) const

Retrieve the numeric value of a parameter.

Parameters:
nameName of parameter to locate
defvalueDefault value to return if not found
minvalueMinimum value allowed for the parameter
maxvalueMaximum value allowed for the parameter
clampControl 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 
) const

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

Parameters:
nameName of parameter to locate
tokensA pointer to an array of tokens to try to lookup
defvalueDefault value to return if not found
Returns:
The number contained in the named parameter or the default
virtual void* getObject ( const String name) const [virtual]

Get a pointer to a derived class given that class name

Parameters:
nameName 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.

NamedString* getParam ( const String name) const

Locate a named string in the parameter list.

Parameters:
nameName of parameter to locate
Returns:
A pointer to the named string or NULL.

Referenced by SS7MsgSCCP::canBeUDT().

NamedString* getParam ( unsigned int  index) const

Locate a named string in the parameter list.

Parameters:
indexIndex 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

Retrieve the value of a named parameter.

Parameters:
nameName of parameter to locate
defvalueDefault value to return if not found
Returns:
The string contained in the named parameter or the default

Referenced by ISDNQ931Message::getIEValue().

unsigned int length ( ) const [inline]

Get the number of parameters

Returns:
Count of named strings

Reimplemented from String.

NamedList& operator= ( const NamedList value)

Assignment operator

Parameters:
valueNew name and parameters to assign
Returns:
Reference to this NamedList

Referenced by DataFormat::operator=().

const String& operator[] ( const String name) const

Parameter access operator

Parameters:
nameName of the parameter to return
Returns:
String value of the parameter, String::empty() if missing
int replaceParams ( String str,
bool  sqlEsc = false,
char  extraEsc = 0 
) const

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

Parameters:
strString in which the replacements will be made
sqlEscTrue to apply SQL escaping to parameter values
extraEscCharacter to escape other than the SQL default ones
Returns:
Number of replacements made, -1 if an error occured

Set a named string in the parameter list.

Parameters:
paramParameter to set or add
Returns:
Reference to this NamedList
NamedList& setParam ( const char *  name,
const char *  value 
)

Set a named string in the parameter list.

Parameters:
nameName of the string
valueValue of the string
Returns:
Reference to this NamedList

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