view anagram/support/bitmap.h @ 21:1c9dac05d040

Add lint-style FALLTHROUGH annotations to fallthrough cases. (in the parse engine and thus the output code) Document this, because the old output causes warnings with gcc10.
author David A. Holland
date Mon, 13 Jun 2022 00:04:38 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993-2000 Parsifal Software. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * bitmap.h
 */

#ifndef BITMAP_H
#define BITMAP_H

#include <string.h>
#include "port.h"

#include "data.h" // sigh... XXX   (for n_chars)
#include "pointer.h"


class Bitmap {
protected:
  unsigned nChars;
  unsigned int nBits;

  ArrayPointer<unsigned char> map;

public:
  Bitmap(int n) : nChars((n+7)/8), nBits(n), map(new unsigned char[nChars]) {
    memset(map, 0, nChars);
  }
  virtual ~Bitmap() {}
  virtual int setBit(int x);
  virtual int getBit(int x);
  virtual int list(int *x);
  virtual Bitmap &setRange(unsigned first, unsigned last);
  Bitmap &operator |= (const Bitmap &b);
  Bitmap &operator &= (const Bitmap &b);
  Bitmap &operator -= (const Bitmap &b);
  Bitmap &operator ~ ();
};

class CharBitmap : public Bitmap {
public:
  CharBitmap() : Bitmap(n_chars) {}
  CharBitmap(const Bitmap &b) : Bitmap(b) {}
  virtual int setBit(int x);
  virtual int getBit(int x);
  virtual int list(int *x);
#ifdef _MSC_VER
  virtual Bitmap &setRange(unsigned first, unsigned last);
#else
  virtual CharBitmap &setRange(unsigned first, unsigned last);
#endif
  void blurCase();
  void blurCase(int);
};


#endif /* BITMAP_H */