Utilities Package
Version Linux2023.0
|
For displaying on-line help and other text messages in console applications. More...
#include <utilities.h>
Public Member Functions | |
TextItems () | |
TextItems (const string fileName) | |
void | displayItem (const string title) const |
For displaying on-line help and other text messages in console applications.
The Textitems class provides a convenient mechanism for holding, in memory, any number of "text items" and displaying any one of these text items as required by the program. A "text item" consists of one or more lines of text and all text items are loaded in from a textfile, which must have the format specified below. One obvious use for this class would be for handling on-line help, but any text item, consisting of any number of lines, that needs to be displayed one or more times by a program may be considered a candiate to become a "text item".
Any textfile containing text items must contain at least one text item. Any such file and each text item in it must be formatted according to the following rules:
========================================
----------------------------------------
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Scobey::TextItems::TextItems | ( | ) |
Default constructor. @pre None @post The list of text items has been initialized and is empty. However, the program is then terminated after displaying the following 6-line message:
Error: File name must be supplied when declaring a TextItems object, as in (for example): TextItems myTextItems("my_text_item_file.dat"); Program is now terminating. Press Enter to continue ...
Scobey::TextItems::TextItems | ( | const string | fileName | ) |
Constructor which gets its list of text items from a textfile. @pre <em>fileName</em> has been initialized. @post - Case 1 (typical): If <em>fileName</em> contains the name (or the full pathname) of a properly-formatted file of text items, all text items in that file have been read into memory and the constructed object contains this list of text items. - Case 2 (error): If <em>fileName</em> contains the name of an empty file, the program displays this 3-line message:
Error: Input file of text items is empty. Program is now terminating. Press Enter to continue ...
Error: Input file of text items does not exist. Program is now terminating. Press Enter to continue ...The program thus terminates if a validly-named file is empty, or if the name of a valid file is not supplied, either initially, or during the one additional permitted attempt.
void Scobey::TextItems::displayItem | ( | const string | title | ) | const |
Displays a text item on the standard output. @pre <em>title</em> has been initialized. @post - Case 1 (typical): The text item identified by <em>title</em> has been displayed. - Case 2 (error): If the text item designated by <em>title</em> cannot be found, the following 2-line message is displayed:
Error: Text item <<title>> not found. Press Enter to continue ...