Boost logo

Boost Testing :

From: Eric Niebler (eric_at_[hidden])
Date: 2006-01-09 13:12:27


Jim Douglas wrote:
>
> I think this is what you need - taken from ctype.h:
>
> /* _Ctype code bits */
> #define _XB 0x400 /* extra blank */
> #define _XA 0x200 /* extra alphabetic */
> #define _XS 0x100 /* extra space */
> #define _BB 0x80 /* BEL, BS, etc. */
> #define _CN 0x40 /* CR, FF, HT, NL, VT */
> #define _DI 0x20 /* '0'-'9' */
> #define _LO 0x10 /* 'a'-'z' */
> #define _PU 0x08 /* punctuation */
> #define _SP 0x04 /* space */
> #define _UP 0x02 /* 'A'-'Z' */
> #define _XD 0x01 /* '0'-'9', 'A'-'F', 'a'-'f' */
>
> It seems to use a variable of type short i.e. 16 bits.

Yes, this looks like it. The comment at the top suggests that there is a
_Ctype() function that I can use these masks with. Is that correct?

> There is also a set of ANSI & POSIX 1003.1 functions isalpha(),
> iswalpha() etc. that work with narrow and wide characters. Are they of
> any use?

Not really. I want the ability to bitor a bunch of these masks together
and evaluate them all at once. _Ctype(ch, _SP|_UP|...) is likely to be
faster than isspace(ch) || isupper(ch) || ..., and it generalizes better.

The only thing I need to know now (besides the name of the isctype()
function, if it isn't _Ctype()) is how these masks combine into the
standard ctype categories. Guessing ...

alnum == _LO | _UP | _XA | _DI
alpha == _LO | _UP | _XA
blank == _SP | _XB // ??
cntrl == _BB // ??
digit == _DI
graph == _LO | _UP | _XA | _DI | _PU
lower == _LO
print == _LO | _UP | _XA | _DI | _PU | _SP | _XB // ??
punct == _PU
space == _SP | _XB | _CN
upper == _UP
xdigit == _XD

Thanks for all your help, by the way. Feel free to reply to me
personally, because this is no longer an issue for boost-testing.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost-testing list run by mbergal at meta-comm.com