Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

A Spell Checking Engine

, 5 Feb 2001
A free spell checking engine for use in your C++ applications. Includes the current US English dictionary
/*

  Copyright:		2000
  Author:			Matthew T Gullett
  Email:			gullettm@yahoo.com
  Name:				CFPSDictionary
  Part of:			Spell Checking Engine 
  Requires:			

  DESCRIPTION
  ----------------------------------------------------------
  This class is designed to implement dictionary support for
  the spell checking engine.


  INFO:
  ----------------------------------------------------------
  This class is provided -as is-.  No warranty as to the
  function or performance of this class is provided either 
  written or implied.  
  
  You may freely use this code and modify it as necessary,
  as long as this header is unmodified and credit is given
  to the author in the application(s) in which it is
  incorporated.

*/

#if !defined(AFX_FPSDICTIONARY_H__54D2A5E8_8E69_4533_937F_2AFFD0EF1E41__INCLUDED_)
#define AFX_FPSDICTIONARY_H__54D2A5E8_8E69_4533_937F_2AFFD0EF1E41__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define CFPSDictionary_ERROR_INVLD_HDR				FPSSPELLCHECK_ERROR_CUSTOM+1
#define	CFPSDictionary_ERROR_DIC_OPEN_FAILED		FPSSPELLCHECK_ERROR_CUSTOM+2
#define CFPSDictionary_ERROR_DIC_ALREADY_OPEN		FPSSPELLCHECK_ERROR_CUSTOM+3
#define CFPSDictionary_ERROR_WORD_OPEN_FAILED		FPSSPELLCHECK_ERROR_CUSTOM+4
#define CFPSDictionary_ERROR_WORD_TOOLONG			FPSSPELLCHECK_ERROR_CUSTOM+5
#define CFPSDictionary_ERROR_NOMATCH				FPSSPELLCHECK_ERROR_CUSTOM+6
#define CFPSDictionary_ERROR_NOT_OPEN				FPSSPELLCHECK_ERROR_CUSTOM+7


class CFPSDictionary  
{
public:
	virtual int CreateNew();
	virtual void SetWords(LPCSTR lpszWords);
	virtual CString GetWords();
	CFPSDictionary();
	virtual ~CFPSDictionary();

	virtual int Close();
	virtual int Save(LPCSTR lpszDicFile);
	virtual int Open(LPCSTR lpszDicFile);
	virtual BOOL IsWordInDictionary(LPCSTR lpszWord);
	virtual BOOL FindMatches(LPCSTR lpszWord, CStringList& Matches);
	virtual long GetWordCount() {return (m_lRecordCount+m_ExtraWords.GetCount());}
	virtual int BuildFromWordList(LPCSTR lpszWordFile, LPCSTR lpszDicFile);
	virtual int AddWord(LPCSTR lpszWord);
	virtual int RemoveWord(LPCSTR lpszWord);

protected:
	virtual void CacheWordLocations();
	virtual BOOL IsInOrder();
	virtual void PrepareHeader(FPSDICHEADER& Header);
	virtual BOOL IsValidHeader(FPSDICHEADER& Header);
	virtual BOOL FindWord (LPCSTR lpszWord, int iMin, int iMax);
	virtual void RemoveExtraWords();

	FPSDICWORD*	m_pWords;
	CTypedPtrList<CPtrList, FPSDICWORD*>	m_ExtraWords;
	long		m_lRecordCount;

	FPSDICHEADER m_FileHeader;

	CString m_strFileName;

	int m_iRecords[255];
private:
	char GetUpperChar(char cInput);
};

#endif // !defined(AFX_FPSDICTIONARY_H__54D2A5E8_8E69_4533_937F_2AFFD0EF1E41__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Matt Gullett
Web Developer
United States United States
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 6 Feb 2001
Article Copyright 2001 by Matt Gullett
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid