////////////////////////////////////////////////////////////////////// // // spellinglist.cpp // // Jeff Ondich 6/25/96 // Last modified 11/1/00 // // Implementation for a simple spelling list class. // ////////////////////////////////////////////////////////////////////// #include #include #include "spellinglist.h" ////////////////////////////////////////////////////////////////////// // // SpellingList::SpellingList // // Initializes spelling list to contain the words in the // indicated file. Assumes that all words are in the // form needed for spell checking--lower case, punctuation // already removed, etc. // ////////////////////////////////////////////////////////////////////// SpellingList::SpellingList( const string& fileName ) { mNWords = 0; // Open the file. ifstream listFile( fileName.c_str() ); if( ! listFile.is_open() ) { cout << "Can't open \"" << fileName << "\"" << endl; cout << "Perhaps it does not exist." << endl; exit( 1 ); } // Process the words. string word; while( listFile >> word ) { AddWord( word ); } // Clean up. listFile.close(); } ////////////////////////////////////////////////////////////////////// // // AddWord // // If the list is already full, AddWord does nothing. Otherwise, // it adds the word to the list. // ////////////////////////////////////////////////////////////////////// void SpellingList::AddWord( const string& theWord ) { cout << "AddWord stub: " << theWord << endl; } ////////////////////////////////////////////////////////////////////// // // IsIn // // Returns true if theWord is in the spelling list, and // false if not. // ////////////////////////////////////////////////////////////////////// bool SpellingList::IsIn( const string& theWord ) const { cout << "IsIn stub: " << theWord << endl; return( false ); } ////////////////////////////////////////////////////////////////////// // // IsFull // // Returns true if the spelling list is full, and false otherwise. // ////////////////////////////////////////////////////////////////////// bool SpellingList::IsFull() const { return( mNWords >= kMaxWords ); } ////////////////////////////////////////////////////////////////////// // // Print // // Prints the spelling list. Print is intended for use during // debugging, and would be seldom used by programs (who wants to // print out a 100,000-word spelling list?). // ////////////////////////////////////////////////////////////////////// void SpellingList::Print() const { cout << "Spelling list" << endl; cout << "=============" << endl << endl; for( int i=0; i < mNWords; i++ ) cout << mWords[ i ] << endl; cout << "=============" << endl << endl; }