ne***@wp.pl wrote:
do You have boost in 1.33 version ?
Yes, it is 1.33
BTW.: I tested it on some topics
and would say it's /somehow/ usable -
if[f] raw-strings will be in the
language.
In the frame of a current project, I tried to read
cartesian coordinates and their molecule descriptors
from a simple text file ((just for fun - to test
boost::regex):
[sample text file]
...
36.01645 33.35185 214.75779 OXYGEN 1518 1
36.98106 32.87680 214.22500 CARBON 1518 1
37.78489 32.48092 213.78100 CARBON 1518 1
...
[100_000's of lines to follow]
After the file has been slurped into a std::string,
the following snippet will extract the above data:
...
std::string::co nst_iterator start, end; // iterators on the buffer
start = file.str().begi n(), end = file.str().end( );
match_flag_type flags = match_default; // match_continuou s;
regex atm("^"
" [\\t\\ ]* ([\\d.]+) [\\t\\ ]+ ([\\d.]+) [\\t\\ ]+ ([\\d.]+) "
" [\\t\\ ]+ ([\\w.]+) "
" [\\t\\ ]* (\\d*) [\\t\\ ]* (\\d*) "
"$",
regex::mod_x);
// - - - - - now read all atoms from string buffer - - - - - //
smatch coord;
while( regex_search(st art, end, coord, atm) ) {
std::cout << coord[1] << '\t' << coord[2] << '\t' << coord[3] << '\t'
<< coord[4] << '\t'
<< coord[5] << '\t' << coord[6] << '\t' << std::endl;
// update search position:
start += coord[0].length()+1; // important: advance behind current match
flags |= match_prev_avai l; // update flags
}
...
This may look awkward for now, but after seeing the /raw string/
in C++, this might be quite usable ...
Regards
M.