// Copyright 2000 // College of Computer Science // Northeastern University Boston MA 02115 // This software may be used for educational purposes as long as this copyright // notice is retained at the top of all files // Should this software be modified, the words "Modified from Original" must be // included as a comment below this notice // All publication rights are retained. This software or its documentation may // not be published in any media either in whole or in part. /////////////////////////////////////////////////////////////////////////////// // StringList.h simple string list class based on Array template class /////////////////////////////////////////////////////////////////////////////// #ifndef STRINGLIST_H_ #define STRINGLIST_H_ #include "IOTools.h" // StringList is a general class for collecting lists of strings class StringList : public Array { public: StringList(int size = 1) : Array(size) { }; // Reading reads zero or more strings and appends them to the list // Reading returns the count of strings read int Reading(const string& prompt) { int count = 0; string response; while (ReadingString(prompt, response)) { Append(response); count++; } return count; }; // Print prints all strings in the list void Print(ostream& os = cout, const string& prefix = "") const { int i; int size = ValidSize(); for (i = 0; i < size; i++) os << prefix << FastAccess(i) << endl; }; // Clear marks all data as invalid // The data is not actually physically erased void Clear() { ValidateNone(); }; }; // StringList #endif // STRINGLIST_H_