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.

135 lines
6.2 KiB

  1. // ITSORT.H: IITSortKey, IITSortKeyConfig, and related definitions.
  2. #ifndef __ITSORT_H__
  3. #define __ITSORT_H__
  4. #include <comdef.h>
  5. // Some standard definitions for sort key types. In general, key types (and
  6. // their #defines) are specific to a particular implementation of a sort object.
  7. // However, in the interest of making it easier to call a variety of sort object
  8. // implementations, we define some standard key type definitions that can be
  9. // used across different implementations.
  10. // New sort objects should feel free to add arbitrary key formats, which could
  11. // include a variety of custom binary formats tailored to specific applications
  12. // (e.g. a binary key that provides indirection to a dictionary of strings).
  13. // Note that the format of the key type must always allow its length to be
  14. // determined without any other data than the key itself, as follows:
  15. // 1) length is constant for the key type (e.g. DWORD is always 4 bytes)
  16. // 2) key includes length information (e.g. a WORD prefix indicating
  17. // how many memory units (bytes, words, etc.) the key contains
  18. // 3) key must contain an explicit terminator (e.g. null terminated strings).
  19. #define IITSK_KEYTYPE_WORD ((DWORD) 18) // Binary word
  20. #define IITSK_KEYTYPE_DWORD ((DWORD) 19) // Binary dword
  21. #define IITSK_KEYTYPE_ANSI_SZ ((DWORD) 30) // NULL-term. MBCS string
  22. #define IITSK_KEYTYPE_UNICODE_SZ ((DWORD) 31) // NULL-term. Unicode string
  23. // Valid parameters that can be returned by IITSortKey::Compare in *pgrfReason.
  24. #define IITSK_COMPREASON_UNKNOWN ((DWORD) 0x80000000)
  25. // Valid parameters that can be passed to IITSortKey::IsRelated.
  26. #define IITSK_KEYRELATION_PREFIX ((DWORD) 0)
  27. #define IITSK_KEYRELATION_INFIX ((DWORD) 1)
  28. #define IITSK_KEYRELATION_SUFFIX ((DWORD) 2)
  29. DECLARE_INTERFACE_(IITSortKey, IUnknown)
  30. {
  31. // Returns in *pcbSize the size of the key in bytes (including any
  32. // length information).
  33. STDMETHOD(GetSize)(LPCVOID lpcvKey, DWORD *pcbSize) PURE;
  34. // On exit, *plResult is set according to strcmp conventions:
  35. // < 0, = 0, > 0, depending on whether lpcvKey1 is less than, equal to, or
  36. // greater than lpcvKey2. If pgrfReason is not NULL, *pgrfReason may be
  37. // filled in on exit with one or more bit flags giving more information about
  38. // the result of the comparison if the result was affected by something other
  39. // than raw lexical comparison (e.g. special character mappings). If
  40. // *pgrfReason contains 0 on exit, that means the comparison result
  41. // was purely lexical; if *pgrfReason contains IITSK_COMPREASON_UNKNOWN,
  42. // then the sort object implementation wasn't able to provide additional
  43. // information about the comparison result.
  44. STDMETHOD(Compare)(LPCVOID lpcvKey1, LPCVOID lpcvKey2,
  45. LONG *plResult, DWORD *pgrfReason) PURE;
  46. // Returns S_OK if lpcvKey1 is related to lpcvKey2 according to
  47. // dwKeyRelation; else S_FALSE. If the value specified for dwKeyRelation
  48. // is not supported, E_INVALIDARG will be returned. If pgrfReason is not
  49. // NULL, *pgrfReason will be filled in just as it would be by
  50. // IITSortKey::Compare.
  51. STDMETHOD(IsRelated)(LPCVOID lpcvKey1, LPCVOID lpcvKey2,
  52. DWORD dwKeyRelation, DWORD *pgrfReason) PURE;
  53. // Converts a key of one type into a key of another type. This is intended
  54. // mainly for converting an uncompressed key into a compressed key,
  55. // but a sort object is free to provide whatever conversion combinations
  56. // it wants to. *pcbSizeOut should contain the size of the buffer pointed
  57. // to by lpvKeyOut. The caller can obtain a guaranteed adequate buffer size
  58. // through *pcbSizeOut by passing 0 on entry.
  59. //
  60. // The following errors are returned:
  61. // E_INVALIDARG: the specified conversion is not supported, i.e.
  62. // one or both of the REFGUID params is invalid.
  63. // E_FAIL: the buffer pointed to by lpvKeyOut was too small
  64. // to hold the converted key.
  65. STDMETHOD(Convert)(DWORD dwKeyTypeIn, LPCVOID lpcvKeyIn,
  66. DWORD dwKeyTypeOut, LPVOID lpvKeyOut,
  67. DWORD *pcbSizeOut) PURE;
  68. };
  69. typedef IITSortKey *PIITSKY;
  70. // Sort flags that can be passed to IITSortKeyConfig::SetControlInfo.
  71. #define IITSKC_SORT_STRINGSORT 0x00001000 /* use string sort method */
  72. #define IITSKC_NORM_IGNORECASE 0x00000001 /* ignore case */
  73. #define IITSKC_NORM_IGNORENONSPACE 0x00000002 /* ignore nonspacing chars */
  74. #define IITSKC_NORM_IGNORESYMBOLS 0x00000004 /* ignore symbols */
  75. #define IITSKC_NORM_IGNOREKANATYPE 0x00010000 /* ignore kanatype */
  76. #define IITSKC_NORM_IGNOREWIDTH 0x00020000 /* ignore width */
  77. // External data types that can be passed to
  78. // IITSortKeyConfig::LoadExternalSortData.
  79. #define IITWBC_EXTDATA_SORTTABLE ((DWORD) 2)
  80. DECLARE_INTERFACE_(IITSortKeyConfig, IUnknown)
  81. {
  82. // Sets/gets locale info that will affect the comparison results
  83. // returned from all subsequent calls to IITSortKey::Compare.
  84. // Returns S_OK if locale described by params is supported
  85. // by the sort object; E_INVALIDARG otherwise.
  86. STDMETHOD(SetLocaleInfo)(DWORD dwCodePageID, LCID lcid) PURE;
  87. STDMETHOD(GetLocaleInfo)(DWORD *pdwCodePageID, LCID *plcid) PURE;
  88. // Sets/gets the sort key type that the sort object will expect
  89. // to see in the following method calls that take keys as params:
  90. // IITSortKey::GetSize, Compare, IsRelated
  91. // Returns S_OK if the sort key type is understood by the
  92. // sort object; E_INVALIDARG otherwise.
  93. STDMETHOD(SetKeyType)(DWORD dwKeyType) PURE;
  94. STDMETHOD(GetKeyType)(DWORD *pdwKeyType) PURE;
  95. // Sets/gets data that controls how sort key comparisons are made.
  96. // This method currently accepts only the following set of flags
  97. // in grfSortFlags:
  98. //
  99. // In the future, additional information may be passed in through
  100. // dwReserved.
  101. STDMETHOD(SetControlInfo)(DWORD grfSortFlags, DWORD dwReserved) PURE;
  102. STDMETHOD(GetControlInfo)(DWORD *pgrfSortFlags, DWORD *pdwReserved) PURE;
  103. // Will load external sort data, such as tables containing the relative
  104. // sort order of specific characters for a textual key type, from the
  105. // specified stream. The format of the data is entirely implementation
  106. // specific, with the value passed in dwExtDataType providing a hint.
  107. STDMETHOD(LoadExternalSortData)(IStream *pStream, DWORD dwExtDataType) PURE;
  108. };
  109. typedef IITSortKeyConfig *PIITSKYC;
  110. #endif // __ITSORT_H__