company logo

Value :: format - Get formatted string

The function returns a formatted string, where place holders are replaced by values of the current instance or values evaluated from expressions. The function requires a selected instance. When no instance is selected, the function throws an exception.

The string passed in sFormatString contains the string with place holders. Each place holder (%s) in the string will be replaced by a parameter from the parameter list passed in sParmList. Parameters passed in the parameter list are interpreted in three steps:

  1. The parameter is checked to be an attribute. In this case, the attribute value is replaced in the format string.
  2. The parameter is checked to be an option. In this case, the option value replaces the place holder in the format string.
  3. The passed value replaces the place holder.

Empty parameters in the parameter list will be replaced by "(NULL)".

When there are more parameters than place holders in the text, additional parameters will be ignored. When there are more place holders than parameters, additional place holders remain as "%s" in the result string.

Return value:  String value ( odaba::String & )

Implementation details

odaba::String Value  :: format ( odaba::String &sFormatString, odaba::StringList &sParmList )
  • sFormatString - Format string

    The format string contains text constants and place holders represented by "%s". Place holders are replaced by parameters according to their place holder position (first place holder is replaced by the value of the first parameter etc.)

    The function tries to resolve parameters in the following order:

    • get property value, when parameter is a property name
    • get option value
    • (NULL), when parameter could not be resolved

    All parameter values are automatically converted to strings before replacing the place holder.

  • sParmList - Parameter list

    Parameters passed in a string list. In some cases, parameters containing spaces have to be quoted.