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.

136 lines
2.5 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1997.
  5. //
  6. // File: bitflag.hxx
  7. //
  8. // Contents: Lightweight class for test/set/clear bit flags.
  9. //
  10. // Classes: CBitFlag
  11. //
  12. // History: 2-17-1997 DavidMun Created
  13. //
  14. //---------------------------------------------------------------------------
  15. #ifndef __BITFLAG_HXX_
  16. #define __BITFLAG_HXX_
  17. //+--------------------------------------------------------------------------
  18. //
  19. // Class: CBitFlag
  20. //
  21. // Purpose: Lightweight class for test/set/clear bit flags.
  22. //
  23. // History: 2-17-1997 DavidMun Created
  24. //
  25. // Notes: Designed for use as a base class.
  26. //
  27. //---------------------------------------------------------------------------
  28. class CBitFlag
  29. {
  30. public:
  31. CBitFlag();
  32. protected:
  33. BOOL
  34. _IsFlagSet(
  35. USHORT fl);
  36. VOID
  37. _SetFlag(
  38. USHORT fl);
  39. VOID
  40. _ClearFlag(
  41. USHORT fl);
  42. USHORT _flFlags;
  43. };
  44. //+--------------------------------------------------------------------------
  45. //
  46. // Member: CBitFlag::CBitFlag
  47. //
  48. // Synopsis: ctor
  49. //
  50. // History: 2-17-1997 DavidMun Created
  51. //
  52. //---------------------------------------------------------------------------
  53. inline
  54. CBitFlag::CBitFlag():
  55. _flFlags(0)
  56. {
  57. }
  58. //+--------------------------------------------------------------------------
  59. //
  60. // Member: CBitFlag::_IsFlagSet
  61. //
  62. // Synopsis: Return TRUE if one or more bits in [fl] are set.
  63. //
  64. // History: 2-17-1997 DavidMun Created
  65. //
  66. //---------------------------------------------------------------------------
  67. inline BOOL
  68. CBitFlag::_IsFlagSet(
  69. USHORT fl)
  70. {
  71. return (_flFlags & fl) ? TRUE : FALSE;
  72. }
  73. //+--------------------------------------------------------------------------
  74. //
  75. // Member: CBitFlag::_SetFlag
  76. //
  77. // Synopsis: Turn on flag bit(s) [fl].
  78. //
  79. // History: 2-17-1997 DavidMun Created
  80. //
  81. //---------------------------------------------------------------------------
  82. inline VOID
  83. CBitFlag::_SetFlag(
  84. USHORT fl)
  85. {
  86. _flFlags |= fl;
  87. }
  88. //+--------------------------------------------------------------------------
  89. //
  90. // Member: CBitFlag::_ClearFlag
  91. //
  92. // Synopsis: Clear flag bit(s) [fl].
  93. //
  94. // History: 2-17-1997 DavidMun Created
  95. //
  96. //---------------------------------------------------------------------------
  97. inline VOID
  98. CBitFlag::_ClearFlag(
  99. USHORT fl)
  100. {
  101. _flFlags &= ~fl;
  102. }
  103. #endif // __BITFLAG_HXX_