#ifndef BALSTRING_H #define BALSTRING_H // balstring.h Interface file for BALString class /******************************************************************************* // MODULE NAME: BALString // INTERFACE FILE: balstring.h // IMPLEMENTATION FILE: balstring.cpp // // PURPOSE: To provide a BALString class useful for an implementation of the BAL // program which allows the user to specify a field width for a string, store // a default value for the string, store a supplied value for the string, reset // either the string stored in the object or the width of the field, and print // out a string with the appropriate width that contains either the current // contents of the object or the default value for the object // // FUNCTIONS: Name Purpose // BALString Constructor w/specified field width // BALString Parameterless constructor // isDefault Indicate whether the object contains the default // isEmpty Test whether the object contains no value // valueIs Report on the string currently stored in the // object // Print Print out, with appropriate width, the contents // of the object // Default Print out, with appropriate width, the default // contents of the object // Store Store a new string value into the object // SetSize Change the field width // ResetValue Change the string to the default string // ResetSize Change the field width to the default size // Reset Change field width & string to defaults // // AUTHOR: Amy Langill *2B Date 3/22/1999 *******************************************************************************/ #include // for strings & string functions using namespace std; const string DEFAULT_STRING="???"; // For assigning and checking defaults const int DEFAULT_STR_SIZE=20; // const char STR_STRING_FILLER=' '; // class BALString { public: // Constructors BALString(int width); // w/specified field width BALString(); // parameterless // Observers bool isDefault(); // Does the object contain the default value? bool isEmpty(); // Does the object contain no value? string valueIs(); // What is currently stored in the BALString? string Print(); // Print out the BALString with the appropriate width string Default(); // Print the default for the object w/the field width // Transformers void Store(string newValue); // Store a new string into the object void SetSize(int newSize); // Change the field width of the object void ResetValue(); // Change the string to the default string void ResetSize(); // Change the field width to the default size void Reset(); // Reset the string & width to default values private: // Data members string value; int fieldSize; // Not to be called by the client void BALString::PrintBlank(string& printMe,int size); // for printing fns }; #endif