ADTF  3.18.2
cMacroResolver

Class for resolving macros inside a string. More...

Public Member Functions

 cMacroResolver ()
 Constructor that initializes an empty cMacroResolver object.
 
virtual ~cMacroResolver ()
 Destructor.
 
tResult SetValues (const cStringMap &mapValues)
 Set string map to be used for macro replacement. More...
 
tResult SetValue (const cString &strKey, const cString &strValue)
 Set specific macro value. More...
 
cString GetValue (const cString &strKey) const
 Get specific macro value. More...
 
cString Resolve (const cString &strSource) const
 Resolve macros. More...
 

Protected Attributes

cStringMap m_mapValues
 Internally used string map.
 

Detailed Description

Class for resolving macros inside a string.

This class implements basic macro resolving functionality.

Macros can be defined as "$(MACRO)" or $MACRO$.



This implementation tries to resolve environment variables while the Macro is not one of the above mentioned or within your user specific setttings (SetValues or SetValue).

Definition at line 29 of file macroresolver.h.

Member Function Documentation

◆ GetValue()

cString GetValue ( const cString strKey) const

Get specific macro value.

Parameters
strKey[in] Name of macro value.
Returns
Returns a string containing the macro value.

◆ Resolve()

cString Resolve ( const cString strSource) const

Resolve macros.

This method resolves all macros inside a string. Macros can be specified as or $name$. The $ can be escaped by a double $ ($$). If a macro cannot be resolved, the macro string is removed. See class description for a list of standard macros.

Note
While Windows XP environment variables are not case sensitive, linux environment variables are. Variables added with
cMacroResolver::SetValue and cMacroResolver SetValues are case sensitive, too.
Parameters
strSource[in] String map containing all macro values.
Returns
Returns a string with all macros replaced.

◆ SetValue()

tResult SetValue ( const cString strKey,
const cString strValue 
)

Set specific macro value.

Note
strKey and strValue will be handled as case sensitive by cMacroResolver::Resolve
Parameters
strKey[in] Name of macro value.
strValue[in] Value of macro.
Returns
Always returns ERR_NOERROR

◆ SetValues()

tResult SetValues ( const cStringMap mapValues)

Set string map to be used for macro replacement.

This method defines a list of macro values to be used for macro replacement. In addition to these values, system or user environment variables are used as macro values.

Parameters
mapValues[in] String map containing all macro values.
Returns
Always returns ERR_NOERROR