company logo

TextFile :: writeFormatted - Write formatted text

The function writes text passed in sFormatString to the file. placeholders in the format string (%s) will be replaced by variables passed as parameter or parameter list.

The function supports indenting according to indentSize ind indent()/unindent() calls. Indent settings will be processed after replacement.

Moreover, the function supports line numbers by providing the current line number in lineNumber.

The function requires formatted text processing. Any other kind of text processing will cause an exception.

Implementation overview

Implementation details

  1. Write formatted line
    TextFile  :: writeFormatted ( odaba::String &sFormatString )

    The function writes data passed in sFormatString to the file inserting requested indents. No text replacement is done for the format string.

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

  2. to list
  3. Write formatstring replacing placeholder
    TextFile  :: writeFormatted ( odaba::String &sFormatString, odaba::String &sString )

    The function replaces the first placeholder (%s) in sFormatString by the value passed in sString before writing text to file. Indent settings will be processed after replacement.

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

    • sString - String value
  4. to list
  5. Write formatstring replacing placeholders
    TextFile  :: writeFormatted ( odaba::String &sFormatString, odaba::StringList &sParmList )

    The function replaces the placeholders (%s) in sFormatString by values passed in sParmList before writing text to file. In case sParmList contains more values as place holders in sFormatString, additional values are ignored. In case of more placeholders than values in sParmList, placeholders remain in string.

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

  6. to list