189 lines
3.7 KiB
C++
189 lines
3.7 KiB
C++
//+--------------------------------------------------------------------------
|
|
//
|
|
// Microsoft Windows
|
|
// Copyright (C) Microsoft Corporation, 1996 - 1997.
|
|
//
|
|
// File: bitflag.hxx
|
|
//
|
|
// Contents: Lightweight class for test/set/clear bit flags.
|
|
//
|
|
// Classes: CBitFlag
|
|
//
|
|
// History: 2-17-1997 DavidMun Created
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
#ifndef __BITFLAG_HXX_
|
|
#define __BITFLAG_HXX_
|
|
|
|
|
|
#define CBITFLAG_FLAGWORD DWORD
|
|
|
|
//+--------------------------------------------------------------------------
|
|
//
|
|
// Class: CBitFlag
|
|
//
|
|
// Purpose: Lightweight class for test/set/clear bit flags.
|
|
//
|
|
// History: 2-17-1997 DavidMun Created
|
|
//
|
|
// Notes: Designed for use as a base class.
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
class CBitFlag
|
|
{
|
|
public:
|
|
|
|
CBitFlag();
|
|
|
|
protected:
|
|
BOOL
|
|
_IsFlagSet(
|
|
CBITFLAG_FLAGWORD fl) const;
|
|
|
|
VOID
|
|
_SetFlag(
|
|
CBITFLAG_FLAGWORD fl);
|
|
|
|
VOID
|
|
_ClearFlag(
|
|
CBITFLAG_FLAGWORD fl);
|
|
|
|
VOID
|
|
_SetMask(
|
|
CBITFLAG_FLAGWORD flSet,
|
|
CBITFLAG_FLAGWORD flMask);
|
|
|
|
CBITFLAG_FLAGWORD
|
|
_QueryMask(
|
|
CBITFLAG_FLAGWORD flMask);
|
|
|
|
CBITFLAG_FLAGWORD _flFlags;
|
|
};
|
|
|
|
|
|
|
|
//+--------------------------------------------------------------------------
|
|
//
|
|
// Member: CBitFlag::CBitFlag
|
|
//
|
|
// Synopsis: ctor
|
|
//
|
|
// History: 2-17-1997 DavidMun Created
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
inline
|
|
CBitFlag::CBitFlag():
|
|
_flFlags(0)
|
|
{
|
|
}
|
|
|
|
|
|
|
|
|
|
//+--------------------------------------------------------------------------
|
|
//
|
|
// Member: CBitFlag::_IsFlagSet
|
|
//
|
|
// Synopsis: Return TRUE if one or more bits in [fl] are set.
|
|
//
|
|
// History: 2-17-1997 DavidMun Created
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
inline BOOL
|
|
CBitFlag::_IsFlagSet(
|
|
CBITFLAG_FLAGWORD fl) const
|
|
{
|
|
return (_flFlags & fl) ? TRUE : FALSE;
|
|
}
|
|
|
|
|
|
|
|
|
|
//+--------------------------------------------------------------------------
|
|
//
|
|
// Member: CBitFlag::_SetFlag
|
|
//
|
|
// Synopsis: Turn on flag bit(s) [fl].
|
|
//
|
|
// History: 2-17-1997 DavidMun Created
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
inline VOID
|
|
CBitFlag::_SetFlag(
|
|
CBITFLAG_FLAGWORD fl)
|
|
{
|
|
_flFlags |= fl;
|
|
}
|
|
|
|
|
|
|
|
|
|
//+--------------------------------------------------------------------------
|
|
//
|
|
// Member: CBitFlag::_ClearFlag
|
|
//
|
|
// Synopsis: Clear flag bit(s) [fl].
|
|
//
|
|
// History: 2-17-1997 DavidMun Created
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
inline VOID
|
|
CBitFlag::_ClearFlag(
|
|
CBITFLAG_FLAGWORD fl)
|
|
{
|
|
_flFlags &= ~fl;
|
|
}
|
|
|
|
|
|
|
|
//+--------------------------------------------------------------------------
|
|
//
|
|
// Member: CBitFlag::_SetMask
|
|
//
|
|
// Synopsis: Set
|
|
//
|
|
// History: 12-04-1997 JonN Created
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
inline VOID
|
|
CBitFlag::_SetMask(
|
|
CBITFLAG_FLAGWORD flSet,
|
|
CBITFLAG_FLAGWORD flMask)
|
|
|
|
{
|
|
_flFlags = (_flFlags & ~flMask) | flSet;
|
|
}
|
|
|
|
|
|
|
|
//+--------------------------------------------------------------------------
|
|
//
|
|
// Member: CBitFlag::_QueryMask
|
|
//
|
|
// Synopsis: Set
|
|
//
|
|
// History: 12-04-1997 JonN Created
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
inline CBITFLAG_FLAGWORD
|
|
CBitFlag::_QueryMask(
|
|
CBITFLAG_FLAGWORD flMask)
|
|
|
|
{
|
|
return (_flFlags & flMask);
|
|
}
|
|
|
|
|
|
|
|
#endif // __BITFLAG_HXX_
|
|
|