class TextItems
1: // Filename: TXITEMS.H
2: // Purpose: Specification file for the TextItems class.
3: //
4: // This class provides a structure to hold in memory any number of
5: // "items of text", and display any one of them on the screen as needed.
6: // One obvious use would be for on-line help, but *any* text item of any
7: // size is a candidate for storage in the "text items" file and retrieval
8: // from that file for display.
9: //
10: // The items must be read in from a textfile and that textfile must be
11: // formatted in the following way:
12: //
13: // - The first line of a "text item" must be its "title", i.e., the exact
14: // string that will be used to access that particular text item.
15: //
16: // - Every text item is terminated by a line of 80 dashes (hyphens)
17: // which is *not* regarded as part of the item itself.
18: //
19: // - Any line of 80 exclamation marks (!) within a text item
20: // indicates a point where the display must pause and ask the
21: // user to press ENTER to continue.
24: #ifndef TXTITEMS_H
25: #define TXTITEMS_H
28: struct ItemNode;
29: typedef ItemNode* ItemPointer;
30: typedef char MyString80[81];
33: class TextItems
34: {
35: public:
37: TextItems();
38: // Default constructor
39: // Pre: none
40: // Post: The list of text items has been intialized and is empty.
43: TextItems(/* in */ const MyString80 fileName);
44: // Constructor
45: // Pre: "fileName" contains the name (or the full pathname) of
46: // a file of properly formatted text items.
47: // Post: All text items in "fileName" have been read into memory.
48: // "itemList" contains the list of text items.
49: // If the file supplied as the parameter in the declaration
50: // of the object is empty, the program displays this message:
51: // Error: Input file of text items is empty,
52: // Program is now terminating.
53: // If the file doesn't exist, the program displays this message:
54: // Error: Input file of text items does not exist.
55: // Program is now terminating.
56: // In either case, as the messages suggest, the program ends.
59: void DisplayItem(/* in */ const MyString80 title) const;
60: // Displays a text item on the screen.
61: // Pre: A string value has been assigned to "title".
62: // Post: The text item identified by "title" has been displayed.
63: // If the item designated by "title" cannot be found, the
64: // following message is displayed: <<title>> not found.
65: // If the user attempts to display an item and there are
66: // no items (because the TextItems object was declared
67: // without the file parameter) the program displays the
68: // following message and then ends:
69: // Error: No text items available for display.
70: // A filename must be supplied as a constructor
71: // parameter when declaring a TextItems object.
72: // Program is now terminating.
74: private:
76: ItemPointer itemList;
77: };
79: #endif