company logo

Application :: initializeOptions - Initialize option settings

Options are provided from different sources. Besides options set in the system environment (set command), options can be set in an application calling Option::assign(). In order to configure applications, options are defined in a configuration or ini-file.

In order to attach a configuration to an application, this function can be called. Options are referred to usually by passing an option path (e.g. target.DATABASE), which typically refers to a section name and an option defined within the section (traditional ini-files are divided in sections introduced by [section_name]). One section or top option (option on the top level in a hierarchical configuration file) can be defined as default section, which need not be named in the option path when referring to an option value.

Option hierarchies are created for the process (application) and for each thread started within the process. Thus, initializeOptions() can be called with different configuration files in different threads.

Implementation details

Application  :: initializeOptions ( odaba::String &sIniFile, odaba::String &sApplicationName )

The configuration file passed in sIniFile will be set as configuration file for the application. Options not yet defined in the option hierarchy are read from the configuration file ones, and stored in the internal option hierarchy.

The function throws an exception, when the file name passed is not valid.

  • sIniFile - Path to ini-file location

    The path may contain any type of folder separator ('/' or '\'). Folder separators will be converted according to the conventions of the target system.

    In order to pass no ini-file, an empty string ( String() ) has to be passed.

  • sApplicationName - Application name

    The name of the application is, usually, also the section name for application options in the configuration or ini-file.

    In order to pass no application name, an empty string ( String() ) has to be passed.