Fix several warnings that appear in gcc 4.3.2.
[wvstreams.git] / utils / wvstringmask.cc
blob24e095b3de5ced8ff1bd49f7aeeece61129fcdc2
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 2005 Net Integration Technologies, Inc.
5 * Implementation of an efficient lookup for a set characters.
7 * It is, however, a little space intensive, but you should statically
8 * create them in your functions, and then they won't be so bad.
9 */
10 #include "wvstringmask.h"
12 WvStringMask::WvStringMask(WvStringParm s)
14 zap();
15 set(s, true);
18 WvStringMask::WvStringMask(char c)
20 zap();
21 set(c, true);
24 bool WvStringMask::operator[](const char c) const
26 unsigned char uc = c;
27 return _set[uc];
30 const char WvStringMask::first() const
32 return _first;
35 void WvStringMask::zap()
37 memset(_set, 0, sizeof(bool) * sizeof(_set));
38 _first = '\0';
41 void WvStringMask::set(const char c, bool value)
43 if (!_first)
44 _first = c;
46 _set[unsigned(c)] = value;
49 void WvStringMask::set(WvStringParm s, bool value)
51 if (!s.isnull())
53 const char *c = s.cstr();
55 if (!_first)
56 _first = *c;
58 while (*c)
60 _set[unsigned(*c)] = value;
61 ++c;