~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/lib/std/shl/obj/BitSet.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2011-03-16 21:31:18 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110316213118-gk4k3ez3e5d2huna
Tags: 2.0.0-1
* QA upload.
* New upstream release
* Debian source format is 3.0 (quilt)
* Fix debhelper-but-no-misc-depends
* Fix ancient-standards-version
* Fix package-contains-linda-override
* debhelper compatibility is 7
* Fix dh-clean-k-is-deprecated

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ---------------------------------------------------------------------------
2
 
// - BitSet.hpp                                                              -
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.                  -
7
 
// -                                                                         -
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
 
// ---------------------------------------------------------------------------
16
 
 
17
 
#ifndef  AFNIX_BITSET_HPP
18
 
#define  AFNIX_BITSET_HPP
19
 
 
20
 
#ifndef  AFNIX_STRING_HPP
21
 
#include "String.hpp"
22
 
#endif
23
 
 
24
 
namespace afnix {
25
 
 
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
30
 
 
31
 
  class BitSet : public virtual Object {
32
 
  private:
33
 
    /// the bitset size
34
 
    long    d_size;
35
 
    /// the array of bytes
36
 
    t_byte* p_byte;
37
 
 
38
 
  public:
39
 
    /// create a default bitset
40
 
    BitSet (void);
41
 
 
42
 
    /// create a bitset with a size
43
 
    /// @param size the bitset size
44
 
    BitSet (const long size);
45
 
 
46
 
    /// copy constructor for this bitset
47
 
    /// @param that the bitset to copy 
48
 
    BitSet (const BitSet& that);
49
 
 
50
 
    /// destroy this bitset
51
 
    ~BitSet (void);
52
 
 
53
 
    /// @return the class name
54
 
    String repr (void) const;
55
 
 
56
 
    /// assign a bitset to this one
57
 
    /// @param that the bitset to assign
58
 
    BitSet& operator = (const BitSet& that);
59
 
 
60
 
    /// @return true if two bitset are equals
61
 
    bool operator == (const BitSet& bset) const;
62
 
 
63
 
    /// @return the bitset size
64
 
    long length (void) const;
65
 
 
66
 
    /// get a bit at a certain position
67
 
    /// @param pos the bit position
68
 
    bool get (const long pos) const;
69
 
 
70
 
    /// mark a bit at a certain position
71
 
    /// @param pos the bit position
72
 
    void mark (const long pos);
73
 
 
74
 
    /// clear a bit at a certain position
75
 
    /// @param pos the bit position
76
 
    void clear (const long pos);
77
 
 
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);
82
 
 
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);
87
 
 
88
 
    /// reserve a new size for this bitset
89
 
    /// @param size the new size to reserve
90
 
    void reserve (const long size);
91
 
 
92
 
  public:
93
 
    /// create a new object in a generic way
94
 
    /// @param argv the argument vector
95
 
    static Object* mknew (Vector* argv);
96
 
 
97
 
    /// @return true if the given quark is defined
98
 
    bool isquark (const long quark, const bool hflg) const;
99
 
 
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,
106
 
                   Vector* argv);
107
 
  };
108
 
}
109
 
 
110
 
#endif