1
// ---------------------------------------------------------------------------
3
// - standard object library - bit set class definition -
4
// ---------------------------------------------------------------------------
5
// - This program is free software; you can redistribute it and/or modify -
6
// - it provided that this copyright notice is kept intact. -
8
// - This program is distributed in the hope that it will be useful, but -
9
// - without any warranty; without even the implied warranty of -
10
// - merchantability or fitness for a particular purpose. In no event shall -
11
// - the copyright holder be liable for any direct, indirect, incidental or -
12
// - special damages arising in any way out of the use of this software. -
13
// ---------------------------------------------------------------------------
14
// - copyright (c) 1999-2007 amaury darsch -
15
// ---------------------------------------------------------------------------
17
#ifndef AFNIX_BITSET_HPP
18
#define AFNIX_BITSET_HPP
20
#ifndef AFNIX_STRING_HPP
26
/// The BitSet class is a resizable bit set object which can be used
27
/// to mark a particular bit in a defined field. Standard boolean methods
28
/// are provided to manipulate bit sets.
29
/// @author amaury darsch
31
class BitSet : public virtual Object {
35
/// the array of bytes
39
/// create a default bitset
42
/// create a bitset with a size
43
/// @param size the bitset size
44
BitSet (const long size);
46
/// copy constructor for this bitset
47
/// @param that the bitset to copy
48
BitSet (const BitSet& that);
50
/// destroy this bitset
53
/// @return the class name
54
String repr (void) const;
56
/// assign a bitset to this one
57
/// @param that the bitset to assign
58
BitSet& operator = (const BitSet& that);
60
/// @return true if two bitset are equals
61
bool operator == (const BitSet& bset) const;
63
/// @return the bitset size
64
long length (void) const;
66
/// get a bit at a certain position
67
/// @param pos the bit position
68
bool get (const long pos) const;
70
/// mark a bit at a certain position
71
/// @param pos the bit position
72
void mark (const long pos);
74
/// clear a bit at a certain position
75
/// @param pos the bit position
76
void clear (const long pos);
78
/// set a bit at a certain position
79
/// @param pos the bit position
80
/// @param bit the bit value to set
81
void set (const long pos, const bool bit);
83
/// set a byte at a certain index
84
/// @param idx the byte index
85
/// @param val the byte value
86
void set (const long idx, const t_byte val);
88
/// reserve a new size for this bitset
89
/// @param size the new size to reserve
90
void reserve (const long size);
93
/// create a new object in a generic way
94
/// @param argv the argument vector
95
static Object* mknew (Vector* argv);
97
/// @return true if the given quark is defined
98
bool isquark (const long quark, const bool hflg) const;
100
/// apply this object with a set of arguments and a quark
101
/// @param robj the current runnable
102
/// @param nset the current nameset
103
/// @param quark the quark to apply these arguments
104
/// @param args the arguments to apply
105
Object* apply (Runnable* robj, Nameset* nset, const long quark,