This site's content was compiled from 1993 to 2006. Beyond that, Google is your friend.

INPUT class library

Maintainer

Kane Marshall

Description

This class library provides safe command line input routines.

Categories

Versions

Links

Features

Description of class INPUT

The routines of class INPUT that get information from the command line ensure that the text entered is in the correct format, otherwise a 'follow_up_prompt' will repeatedly be displayed until an acceptable string is entered. The 'follow_up_prompt' can be set with the procedure 'set_follow_up_prompt'. A default 'follow_up_prompt' setting will always be used.

Procedure 'get_non_empty_string' ensures a string of at least one non whitespace character is entered. An example of its use is:

local
     in: INPUT
do
     !! in
     in.put_string ("Enter your name: ")
     in.get_non_empty_string

Procedure 'get_formatted_string' ensures a string satisfies the rules provided by a FORMAT_TEST object (described next).

Description of class FORMAT_TEST

FORMAT_TEST is a supporting class of INPUT of which the deferred feature 'is_correct_format' ensures that an entered string is of the correct format. Each descendant of FORMAT_TEST has to define a 'default_follow_up_prompt'.

One such descendant of FORMAT_TEST is OPTIONS, which ensures the string entered is a printable representation ('out') of one of a selection of specified objects. An example of its use is:

local
     in: INPUT
     rules: FORMAT_TEST
do
     !! in
     !OPTIONS! rules.make (<<0, 1, "more", 'm'>>)
     in.put_string ("How many siblings do you have (0, 1 or more)?")
     in.get_formatted_string (rules)

The example class DDMMYYY_TEST ensures that a string entered is in dd/mm/yyyy format.

The deferred generic class RANGE ensures that the string entered is of a correct format and also within a specified range of two values `lower' and `upper'. Example descendants of this class are INTEGER_RANGE and DATE_RANGE, whose names are self explanatory.

Description of class IO_TESTER

IO_TESTER is a root class which tests the features of the INPUT class library. Example output from this running system is stored in file `out.exp'.

Supported compilers

Licensing

Google
 
Web eiffelzone.com