Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.4 KiB

  1. // ENGSTEM.H: Definition of CITEngStemmer object implementation.
  2. #ifndef __ENGSTEM_H__
  3. #define __ENGSTEM_H__
  4. #include "verinfo.h"
  5. #define VERSION_ENGSTEMMER (MAKELONG(MAKEWORD(0, rapFile), MAKEWORD(rmmFile, rmjFile)))
  6. // Group of flags that indicate what data has been persisted to the
  7. // stemmer's stream.
  8. #define ITSTDBRK_PERSISTED_STEMCTL 0x00000001
  9. // Stemmer control structure that contains information that can
  10. // vary how words are stemmed.
  11. typedef struct _stemctl
  12. {
  13. DWORD dwCodePageID;
  14. LCID lcid;
  15. DWORD grfStemFlags;
  16. } STEMCTL;
  17. class CITEngStemmer :
  18. public IStemmer,
  19. public IStemmerConfig,
  20. public IPersistStreamInit,
  21. public CComObjectRootEx<CComMultiThreadModel>,
  22. public CComCoClass<CITEngStemmer,&CLSID_ITEngStemmer>
  23. {
  24. public:
  25. CITEngStemmer();
  26. virtual ~CITEngStemmer();
  27. BEGIN_COM_MAP(CITEngStemmer)
  28. COM_INTERFACE_ENTRY(IStemmer)
  29. COM_INTERFACE_ENTRY(IStemmerConfig)
  30. COM_INTERFACE_ENTRY(IPersistStreamInit)
  31. END_COM_MAP()
  32. DECLARE_REGISTRY(CLSID_ITEngStemmer, "ITIR.EngStemmer.4", "ITIR.EngStemmer", 0, THREADFLAGS_BOTH )
  33. // IStemmer methods
  34. STDMETHOD(Init)(ULONG ulMaxTokenSize, BOOL *pfLicense);
  35. STDMETHOD(GetLicenseToUse)(WCHAR const **ppwcsLicense);
  36. STDMETHOD(StemWord)(WCHAR const *pwcInBuf, ULONG cwc, IStemSink *pStemSink);
  37. // IStemmerConfig methods
  38. STDMETHOD(SetLocaleInfo)(DWORD dwCodePageID, LCID lcid);
  39. STDMETHOD(GetLocaleInfo)(DWORD *pdwCodePageID, LCID *plcid);
  40. STDMETHOD(SetControlInfo)(DWORD grfBreakFlags, DWORD dwReserved);
  41. STDMETHOD(GetControlInfo)(DWORD *pgrfBreakFlags, DWORD *pdwReserved);
  42. STDMETHOD(LoadExternalStemmerData)(IStream *pStream, DWORD dwExtDataType);
  43. // IPersistStreamInit methods
  44. STDMETHOD(GetClassID)(CLSID *pclsid);
  45. STDMETHOD(IsDirty)(void);
  46. STDMETHOD(Load)(IStream *pStream);
  47. STDMETHOD(Save)(IStream *pStream, BOOL fClearDirty);
  48. STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSizeMax);
  49. STDMETHOD(InitNew)(void);
  50. private:
  51. // Private methods
  52. void ClearMembers(void);
  53. void InitStemCtl(void);
  54. void Close(void);
  55. HRESULT ReallocBuffer(HGLOBAL *phmemBuf, DWORD *cbBufCur, DWORD cbBufNew);
  56. // Private data members
  57. BOOL m_fInitialized;
  58. BOOL m_fDirty;
  59. DWORD m_grfPersistedItems;
  60. STEMCTL m_stemctl;
  61. HGLOBAL m_hmem1;
  62. HGLOBAL m_hmem2;
  63. DWORD m_cbBuf1Cur;
  64. DWORD m_cbBuf2Cur;
  65. _ThreadModel::AutoCriticalSection m_cs; // Critical section obj.
  66. };
  67. // Initial size of Ansi string buffers.
  68. #define cbAnsiBufInit 256
  69. #endif // __ENGSTEM_H__