|
Boost : |
From: Sean Huang (huangsean_at_[hidden])
Date: 2005-09-28 09:36:53
I ran across the implementation of XML_name. It is a functor used to
validate each single character in an XML name. The initialization of a
stack-based look-up table everytime the functor is called puzzles me (see
excerpt below).
void operator()(CharType t) const{
unsigned char lookup_table[] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0, // -.
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0, // 0-9
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // A-
1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1, // -Z _
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // a-
1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0, // -z
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
if((unsigned)t > 127)
return;
if(0 == lookup_table[(unsigned)t])
boost::throw_exception(
xml_archive_exception(
xml_archive_exception::xml_archive_tag_name_error
)
);
}
Is there any reason why it was done this way? For threading issues?
Thanks,
Sean
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk