//=========================================================================== // $Name: arts++-1-1-a12 $ // $Id: ArtsBitString.hh,v 1.1.1.1 2002/11/16 00:46:40 rkoga Exp $ //=========================================================================== // Copyright Notice // // By accessing this software, arts++, you are duly informed // of and agree to be bound by the conditions described below in this // notice: // // This software product, arts++, is developed by Daniel W. McRobb, and // copyrighted(C) 1998 by the University of California, San Diego // (UCSD), with all rights reserved. UCSD administers the CAIDA grant, // NCR-9711092, under which part of this code was developed. // // There is no charge for arts++ software. You can redistribute it // and/or modify it under the terms of the GNU Lesser General Public // License, Version 2.1, February 1999, which is incorporated by // reference herein. // // arts++ is distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE or that the use // of it will not infringe on any third party's intellectual // property rights. // // You should have received a copy of the GNU Lesser General Public // License along with arts++. Copies can also be obtained from: // // http://www.gnu.org/copyleft/lesser.html // // or by writing to: // // Free Software Foundation, Inc. // 59 Temple Place, Suite 330 // Boston, MA 02111-1307 // USA // // Or contact: // // info@caida.org //=========================================================================== #ifndef _ARTSBITSTRING_HH_ #define _ARTSBITSTRING_HH_ extern "C" { #include "caida_t.h" } //--------------------------------------------------------------------------- // class ArtsBitString //--------------------------------------------------------------------------- // This class abstracts a bit string and permits simple bit // manipulations. //--------------------------------------------------------------------------- class ArtsBitString { public: //------------------------------------------------------------------------- // ArtsBitString(uint32_t numBits) //......................................................................... // constructor //------------------------------------------------------------------------- ArtsBitString(uint32_t numBits); //------------------------------------------------------------------------- // ~ArtsBitString() //......................................................................... // destructor //------------------------------------------------------------------------- ~ArtsBitString(); //------------------------------------------------------------------------- // bool Test(uint32_t position) const //......................................................................... // Check if bit at position is set. Returns true if it's set, else // returns false. //------------------------------------------------------------------------- bool Test(uint32_t position) const; //------------------------------------------------------------------------- // void Set(uint32_t position) //......................................................................... // Sets the bit at position. //------------------------------------------------------------------------- void Set(uint32_t position); //------------------------------------------------------------------------- // void Unset(uint32_t position) //......................................................................... // Unsets the bit at position. //------------------------------------------------------------------------- void Unset(uint32_t position); //------------------------------------------------------------------------- // void Toggle(uint32_t position) //......................................................................... // Toggles the bit at position. //------------------------------------------------------------------------- void Toggle(uint32_t position); //------------------------------------------------------------------------- // void SetAll() //......................................................................... // Sets all bits. //------------------------------------------------------------------------- void SetAll(); //------------------------------------------------------------------------- // void UnsetAll() //......................................................................... // Unsets all bits. //------------------------------------------------------------------------- void UnsetAll(); private: uint32_t _numBits; uint32_t _numBytes; uint8_t *_bits; uint32_t _BitByte(uint32_t position) const; uint8_t _BitMask(uint32_t position) const; }; #endif // _ARTSBITSTRING_HH_