home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 6.ddi / MWHC.006 / H0 < prev    next >
Encoding:
Text File  |  1992-06-07  |  2.0 KB  |  67 lines

  1. #ifndef    __RWBITREF_H__
  2. #define    __RWBITREF_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * A reference to a bit in a bit vector.
  7.  *
  8.  * $Header:   E:/vcs/rw/bitref.h_v   1.2   18 Feb 1992 09:54:04   KEFFER  $
  9.  *
  10.  ****************************************************************************
  11.  *
  12.  * Rogue Wave 
  13.  * P.O. Box 2328
  14.  * Corvallis, OR 97339
  15.  * Voice: (503) 754-3010    FAX: (503) 757-6650
  16.  *
  17.  * Copyright (C) 1989, 1990, 1991. This software is subject to copyright 
  18.  * protection under the laws of the United States and other countries.
  19.  *
  20.  ***************************************************************************
  21.  *
  22.  * $Log:   E:/vcs/rw/bitref.h_v  $
  23.  * 
  24.  *    Rev 1.2   18 Feb 1992 09:54:04   KEFFER
  25.  * 
  26.  *    Rev 1.1   28 Oct 1991 09:08:06   keffer
  27.  * Changed inclusions to <rw/xxx.h>
  28.  * 
  29.  *    Rev 1.0   28 Jul 1991 08:12:08   keffer
  30.  * Tools.h++ V4.0.5 PVCS baseline version
  31.  *
  32.  */
  33.  
  34. /*
  35.  * Although this class has a public constructor, it is not intended
  36.  * to be used by itself, but rather as an lvalue to the BitVec 
  37.  * and GBitVec(sz) classes.  Do not "construct" a RWBitRef directly.
  38.  * The constructor must be public to accomodate GBitVec(sz) whose name
  39.  * is not known in advance, hence it can't be made a friendly class.
  40.  */
  41.  
  42. #include "rw/tooldefs.h"
  43. #include "rw/mempool.h"
  44.  
  45. class RWExport RWBitVec;
  46.  
  47. class RWExport RWBitRef : public RWMemoryPool {
  48.   RWByte*    pt;    // Pointer to the referenced byte
  49.   RWByte    msk;    // Mask for the bit within the byte
  50.   RWBitRef(const RWBitRef& br) { pt=br.pt; msk=br.msk; }
  51. public:
  52.   RWBitRef(RWByte* p, int j)
  53.     { pt = (j>>3) + p;   msk = 1 << (7&j); }
  54.   friend    RWBitVec;
  55.   operator    RWBoolean() const    { return ((*pt & msk) != 0); }
  56.   RWBoolean    operator=(RWBoolean i)
  57.     { if(i) *pt |= msk;
  58.     else    *pt &= ~msk;
  59.     return i; }
  60.   void        operator&=(RWBoolean i) {if (!i) *pt &= ~msk;}
  61.   void        operator|=(RWBoolean i) {if  (i) *pt |=  msk;}
  62.   void        operator^=(RWBoolean i) {if  (i) *pt ^=  msk;}
  63. };
  64.  
  65. pragma pop_align_members();
  66. #endif /* __RWBITREF_H__ */
  67.