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.

211 lines
5.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990, 1991 **/
  4. /**********************************************************************/
  5. /*
  6. MaskMap.hxx
  7. This file contains the definition for the MASK_MAP class.
  8. A MASK_MAP is a BITFIELD, NLS_STR pair that can be used to
  9. associate bitmasks with strings.
  10. FILE HISTORY:
  11. Johnl 02-Aug-1991 Created
  12. */
  13. #ifndef _MASKMAP_HXX_
  14. #define _MASKMAP_HXX_
  15. #include "bitfield.hxx"
  16. #include "string.hxx"
  17. #include "slist.hxx"
  18. /*************************************************************************
  19. NAME: US_IDS_PAIR
  20. SYNOPSIS: This structure can be used for static initialization
  21. that is compatible with MASK_MAP::Add.
  22. CAVEATS:
  23. NOTES: usBitMask is the initialized bitfield
  24. idsStringID is the ID of the string that will be loaded
  25. with NLS_STR::LoadString
  26. nID is the app defined ID of this pair.
  27. HISTORY:
  28. Johnl 05-Aug-1991 Created
  29. **************************************************************************/
  30. struct US_IDS_PAIRS {
  31. USHORT usBitMask ;
  32. MSGID idsStringID ; // Resource string ID
  33. int nID ;
  34. } ;
  35. /*************************************************************************
  36. NAME: STRING_BITSET_PAIR
  37. SYNOPSIS: This is a container class for the MASK_MAP class.
  38. INTERFACE: QueryString & QueryBitfield, returns the string and
  39. and bitfield components respectively. QueryID returns
  40. the user defined ID associated with the string and bitset.
  41. PARENT: BASE
  42. USES: NLS_STR, BITFIELD
  43. CAVEATS: None
  44. NOTES:
  45. HISTORY:
  46. Johnl 02-Aug-1991 Created
  47. **************************************************************************/
  48. DLL_CLASS STRING_BITSET_PAIR : public BASE
  49. {
  50. public:
  51. STRING_BITSET_PAIR( const NLS_STR & nlsString,
  52. const BITFIELD & bitfieldMask,
  53. int nID ) ;
  54. NLS_STR * QueryString( void )
  55. { return &_nlsString ; }
  56. BITFIELD * QueryBitfield( void )
  57. { return &_bitfieldMask ; }
  58. int QueryID( void )
  59. { return _nID ; }
  60. private:
  61. NLS_STR _nlsString ;
  62. BITFIELD _bitfieldMask ;
  63. int _nID ;
  64. } ;
  65. /*************************************************************************
  66. NAME: MASK_MAP
  67. SYNOPSIS: This class provides a bitfield/string lookup table that
  68. optionally allows a user defined classification (by using
  69. an int ID key value that is used for lookups).
  70. INTERFACE:
  71. Add
  72. Adds an association to the list with the specified
  73. bitfield, string and id.
  74. Add (alternate form)
  75. Adds an array of struct US_IDS_PAIRS, good for static
  76. initialization.
  77. BitsToString, StringToBits
  78. Finds the first matching passed String/Bitfield with the requested
  79. ID and returns the corresponding Bitfield/string.
  80. EnumStrings, EnumBits
  81. Lists all of the strings in the class or all of the bits in
  82. the class (respectively) that have the ID that matches the
  83. passed ID. pfFromBeginning indicates start from the beginning
  84. of the list, it will be set to FALSE automatically. While the
  85. method returns TRUE, there is more data.
  86. IsPresent
  87. Searches for a particular bitfield and returns TRUE if found
  88. QueryBits
  89. Retrieves the nth bitfield and string in this maskmap
  90. PARENT: BASE
  91. USES: BITFIELD, NLS_STR
  92. CAVEATS:
  93. NOTES: As a CODEWORK item, may want to allow a search value of -1 for
  94. the ID which means accept any ID (this might be useful for
  95. BitsToString/StringToBits and the Enum* methods.
  96. HISTORY:
  97. Johnl 02-Aug-1991 Created
  98. Johnl 10-Feb-1992 Added QueryBits, added found at index to
  99. StringToBits and BitsToString
  100. Johnl 02-Feb-1993 Added IsPresent
  101. **************************************************************************/
  102. DECL_SLIST_OF( STRING_BITSET_PAIR, DLL_BASED )
  103. DLL_CLASS MASK_MAP : public BASE
  104. {
  105. public:
  106. MASK_MAP() ;
  107. ~MASK_MAP() ;
  108. APIERR Add( const BITFIELD & bitfieldMask,
  109. const NLS_STR & nlsString,
  110. int nID = 0 ) ;
  111. APIERR Add( US_IDS_PAIRS uidsspairs[], USHORT cCount ) ;
  112. APIERR BitsToString( const BITFIELD & bitfieldKey,
  113. NLS_STR * pnlsString,
  114. int nID = 0,
  115. UINT * puiFoundIndex = NULL ) ;
  116. APIERR StringToBits( const NLS_STR & nlsStringKey,
  117. BITFIELD * pbitfield,
  118. int nID = 0,
  119. UINT * puiFoundIndex = NULL ) ;
  120. APIERR EnumStrings( NLS_STR * pnlsString,
  121. BOOL * pfMoreData,
  122. BOOL * pfFromBeginning,
  123. int nID = 0 ) ;
  124. APIERR EnumBits( BITFIELD* pbitfield,
  125. BOOL * pfMoreData,
  126. BOOL * pfFromBeginning,
  127. int nID = 0 ) ;
  128. APIERR QueryBits( UINT uiIndex,
  129. BITFIELD * pbitfield,
  130. NLS_STR * pnlsString,
  131. int * pnID = NULL ) ;
  132. BOOL IsPresent( BITFIELD * pbitfield ) ;
  133. UINT QueryCount( void )
  134. { return _slbitnlsPairs.QueryNumElem() ; }
  135. private:
  136. SLIST_OF( STRING_BITSET_PAIR ) _slbitnlsPairs ;
  137. ITER_SL_OF(STRING_BITSET_PAIR) _sliterStrings ;
  138. ITER_SL_OF(STRING_BITSET_PAIR) _sliterBits ;
  139. } ;
  140. #endif //_MASKMAP_HXX_