You are reading help file online using chmlib.com
|
ISpLexicon::GetGenerationChange passes back a list of words which have changed between the current and a specified generation.
HRESULT GetGenerationChange(
DWORD dwFlags,
DWORD *pdwGeneration,
SPWORDLIST *pWordList
);
Value | Description |
---|---|
S_OK | Function completed successfully. |
SP_LEX_NOTHING_TO_SYNC | Nothing changed since the passed in generation ID. |
SPERR_LEX_VERY_OUT_OF_SYNC | There are too many changes since the passed in generation ID, so that a change history is not available. It could also be returned after installation/uninstallation of an application lexicon. Use ISpLexicon::GetWords if GetGenerationChange returns SPERR_LEX_VERY_OUT_OF_SYNC to regenerate an entire list of words based on the current generation. |
E_POINTER | pdwGeneration or pWordList is not a valid write pointer. |
E_INVALIDARG | dwFlags is invalid. |
SPERR_UNINITIALIZED | Interface has not been initialized. |
E_OUTOFMEMORY | Exceeded available memory. |
FAILED(hr) | Appropriate error message. |
An application can determine what has been done to a lexicon over a given period of time using ISpLexicon::GetGenerationChange and ISpLexicon::GetGeneration. That is, it can back out of changes it has made due to a user cancel. To do this, before it starts modifying the lexicon, the application would call ISpLexicon::GetGeneration and store the generation ID. Later, when the application wants to see what words in the lexicon it has modified, it would call ISpLexicon::GetGenerationChanges with the stored ID. This can only be done for small changes because, past a certain point, SPERR_LEX_VERY_OUT_OF_SYNC will be returned and the change history will not be available from the original generation.
The following is an example of GetGenerationChange.
for (;;)
{
hr = pISpLexicon->GetGenerationChange(eLEXTYPE_USER, &m_dwGeneration, &spwordlist);
// If, for example, a new application lexicon was added, we'll have
// to rebuild from scratch.
if (hr == SPERR_LEX_VERY_OUT_OF_SYNC)
{
Rebuild(); // Call GetWords
}
else if (FAILED(hr))
{
DealWithOtherErrors();
}
else
{
// Loop thru the changed words, and their new pronunciations
for (SPWORD *pword = spwordlist.pFirstWord;
pword != NULL;
pword = pword->pNextWord)
{
for (SPWORDPRON pwordpron = pword->pFirstWordPron;
pwordpron != NULL;
pwordpron = pwordpron->pNextWordPron)
{
if(pword->eWordType == eWORDTYPE_ADDED)
{
AddPronunciationToEngineDataStructures(
pword->pszWord,
pwordpron->ePartOfSpeech,
pwordpron->pszPronIPA);
}
else // pword->eWordType == eWORDTYPE_DELETED
{
RemovePronunciationFromEngineDataStructures(
pword->pszWord,
pwordpron->ePartOfSpeech,
pwordpron->pszPronIPA);
}
}
}
}
}
You are reading help file online using chmlib.com
|