📄 dictionary.h
字号:
// Dictionary.h: interface for the Dictionary classes.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DICTIONARY_H__B9D80D57_E7CF_4D7E_91D9_6C79A83DFE0C__INCLUDED_)
#define AFX_DICTIONARY_H__B9D80D57_E7CF_4D7E_91D9_6C79A83DFE0C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
enum WordMatch
{
eMatchPerfect, // Word is a perfect match
eMatchCapitalisedFirst, // Word matches except first character, which is capitalised (could be valid if at start of sentence)
eMatchMixedCase, // Word match found, but incorrect case
eMatchNone, // No match found
eMatchInternalError // Something went wrong!
};
class CNode
{
public:
// Construction / destruction
CNode(char c = '\0');
virtual ~CNode();
// Word operations
void InsertWord(LPCSTR szWord);
void IsWordListed(LPCSTR szWord, bool bMatchCase, WordMatch & match, bool bIsFirstNode, CNode ** ppFinalNode = NULL);
void GetPatternMatchingWords(LPCSTR szWord, CStringArray & straSuggestions, CString strWordSoFar = "");
void GetWordCount(int & nCount);
// Serialisation
void Serialise(CArchive & ar);
public:
char m_Character;
CNode * m_pAlternative; // "Left" node, i.e. if this is not the right character
CNode * m_pNext; // "Right" node, i.e. if this is the right character
};
class CDictionary
{
public:
CDictionary();
virtual ~CDictionary();
// Word operations
void InsertWord(LPCSTR szWord);
bool RemoveWord(LPCSTR szWord);
WordMatch IsWordListed(LPCSTR szWord);
int GetSuggestions(LPCSTR szWord, CStringArray & straSuggestions, bool bCaseSuggestionsOnly);
int PatternMatchWord(LPCSTR szWord, CStringArray & straSuggestions);
int GetWordCount();
// File operations
bool LoadDictionary(const CString & strFilename);
bool SaveDictionary(const CString & strFilename);
bool CreateFromList(const CString & strFilename, bool bAppend = false);
static WordMatch GetBestMatch(WordMatch match1, WordMatch match2) { return min(match1, match2); };
private:
void SortSuggestions(CStringArray & straSuggestions);
void RemoveDuplicates(CStringArray & straSuggestions);
CNode * m_pRootNode;
};
#endif // !defined(AFX_DICTIONARY_H__B9D80D57_E7CF_4D7E_91D9_6C79A83DFE0C__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -