File: wvstringmask.h

package info (click to toggle)
wvstreams 4.6.1-5
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 6,972 kB
  • sloc: cpp: 64,200; ansic: 4,154; sh: 4,094; makefile: 545; perl: 402
file content (58 lines) | stat: -rw-r--r-- 1,347 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* -*- Mode: C++ -*-
 * Worldvisions Weaver Software:
 *   Copyright (C) 2005 Net Integration Technologies, Inc.
 *
 * Implementation of an efficient lookup for a set characters.
 *
 * It is, however, a little space intensive, but you should statically
 * create them in your functions, and then they won't be so bad.
 */
#ifndef __WVSTRINGMASK_H
#define __WVSTRINGMASK_H

#include "wvstring.h"

/**
 * A class used to provide a masked lookup for characters in a string.
 */
class WvStringMask
{
public:
    /**
     * Create a WvStringMask out of a WvString.  When looked up,
     * characters in 's' will return true.
     */
    WvStringMask(WvStringParm s = WvString::null);
    WvStringMask(char c);

    /**
     * Look up a character.  This will return true if 'c' is in 'set'.
     */
    bool operator[](const char c) const;

    /**
     * Get the first character set into the mask
     */
    const char first() const;

    /**
     * Clear the WvStringMask, so that all lookups return false.
     */
    void zap();

    /**
     * Set a character 'c' to a particular truth value.
     */
    void set(const char c, bool value);

    /**
     * Set all characters in string 's' to a particular truth value.
     */
    void set(WvStringParm s, bool value);

private:
    bool _set[256];
    char _first;
};

#endif // __WVSTRINGMASK_H