home *** CD-ROM | disk | FTP | other *** search
- #ifndef __RWBITREF_H__
- #define __RWBITREF_H__
- pragma push_align_members(64);
-
- /*
- * A reference to a bit in a bit vector.
- *
- * $Header: E:/vcs/rw/bitref.h_v 1.2 18 Feb 1992 09:54:04 KEFFER $
- *
- ****************************************************************************
- *
- * Rogue Wave
- * P.O. Box 2328
- * Corvallis, OR 97339
- * Voice: (503) 754-3010 FAX: (503) 757-6650
- *
- * Copyright (C) 1989, 1990, 1991. This software is subject to copyright
- * protection under the laws of the United States and other countries.
- *
- ***************************************************************************
- *
- * $Log: E:/vcs/rw/bitref.h_v $
- *
- * Rev 1.2 18 Feb 1992 09:54:04 KEFFER
- *
- * Rev 1.1 28 Oct 1991 09:08:06 keffer
- * Changed inclusions to <rw/xxx.h>
- *
- * Rev 1.0 28 Jul 1991 08:12:08 keffer
- * Tools.h++ V4.0.5 PVCS baseline version
- *
- */
-
- /*
- * Although this class has a public constructor, it is not intended
- * to be used by itself, but rather as an lvalue to the BitVec
- * and GBitVec(sz) classes. Do not "construct" a RWBitRef directly.
- * The constructor must be public to accomodate GBitVec(sz) whose name
- * is not known in advance, hence it can't be made a friendly class.
- */
-
- #include "rw/tooldefs.h"
- #include "rw/mempool.h"
-
- class RWExport RWBitVec;
-
- class RWExport RWBitRef : public RWMemoryPool {
- RWByte* pt; // Pointer to the referenced byte
- RWByte msk; // Mask for the bit within the byte
- RWBitRef(const RWBitRef& br) { pt=br.pt; msk=br.msk; }
- public:
- RWBitRef(RWByte* p, int j)
- { pt = (j>>3) + p; msk = 1 << (7&j); }
- friend RWBitVec;
- operator RWBoolean() const { return ((*pt & msk) != 0); }
- RWBoolean operator=(RWBoolean i)
- { if(i) *pt |= msk;
- else *pt &= ~msk;
- return i; }
- void operator&=(RWBoolean i) {if (!i) *pt &= ~msk;}
- void operator|=(RWBoolean i) {if (i) *pt |= msk;}
- void operator^=(RWBoolean i) {if (i) *pt ^= msk;}
- };
-
- pragma pop_align_members();
- #endif /* __RWBITREF_H__ */
-