typedef unsigned int DBflag; typedef unsigned long DBoffset; typedef DBoffset DBsize; typedef unsigned char DBbyte;
class DBlink
{
protected:
DBbyte link[4]; public:
DBlink(DBoffset = 0, DBflag = 0);
DBlink &operator=(const DBlink &);
DBlink &operator=(DBoffset);
operator DBoffset();
operator const DBbyte *() { return link; }
void set_flag() { link[0] |= 0x80; }
void reset_flag() { link[0] &= 0x7f; }
int test_flag() const { return (link[0] & 0x80) != 0; }
};
typedef DBlink DBsizerec;
const DBoffset DB_NULL = 0;
class DBlinkrec
{
protected:
DBlink l; DBlink r; DBlink d; public:
DBlinkrec():l(DB_NULL), r(DB_NULL), d(DB_NULL) {}
void make_red() { l.set_flag(); }
void make_black() { l.reset_flag(); }
int is_red() const { return l.test_flag(); }
void set_discard() { r.set_flag(); }
void reset_discard() { r.reset_flag(); }
int is_discarded() const { return r.test_flag(); }
void set_flag() { d.set_flag(); }
void reset_flag() { d.reset_flag(); }
int is_flag() const { return d.test_flag(); }
friend class DataBase;
};
class DBpathrec : public DBlinkrec
{
DBoffset offset; public:
DBpathrec():offset(DB_NULL) { }
DBpathrec(DBoffset off, const DBlinkrec &lr):offset(off), DBlinkrec(lr) {}
operator DBoffset() { return offset; }
DBpathrec &operator=(DBoffset off) { offset = off; return *this; }
DBpathrec &operator=(const DBpathrec &pr)
{ offset = pr.offset; (DBlinkrec)*this = (DBlinkrec)pr; return *this; }
friend class DataBase;
};
int main()
{
DBpathrec a(), b();
a = b;}