Chapter 3. Option Handling in Sulfur

Table of Contents
Overview
Option Objects: The Basics
Option Objects: Specific Types
Configuration File Support

Overview

In Sulfur, an option is a user-configurable parameter which may affect the operation of a plug-in. Essentially, an option is any parameter which you might reasonably expect to place in a configuration file, on an "options" dialog, or on the command line. Since any reasonably complex program is likely to have tens or hundreds of such user-alterable values, Sulfur provides facilities for dealing with them in a flexible and easy to use manner.

Every option is named and has a type, which determines the basic kind of value it represents. Some of the types supported by Sulfur include boolean, integer, string, filename, and choice from a list. Depending on the type, an option may accept values that fall only in a certain range, or from a certain set of valid choices.

In addition to the basic information just described, options also carry both short and long descriptions (which can be used in the presentation of help screens) and they also have a set of flags as well as information used in command-line processing.

Every plug-in has a list of options. When a plug-in object is instantiated, Sulfur gathers options from the plug-in class and all its superclasses, and initializes the option values to the supplied defaults. Sulfur also provides facilities to automatically load option values from textual configuration files, so that user-selected values are propagated to each plug-in without any special handling by your application.