14 Nov
2005
14 Nov
'05
4:12 p.m.
troy d. straszheim wrote:
void load(double & t) { if(is.fail()) boost::throw_exception(archive_exception(archive_exception::stream_error)); char c = is.peek(); while (c == ' ' || c == '\t' || c == '\n') // munch leading whitespace { is.get(); c = is.peek(); } if (c == 'n') // nan { t = NAN; // you can get one of those with 0.0/0.0, robert... if (is.get() != 'n' || is.get() != 'a' || is.get() != 'n') boost::throw_exception(archive_exception(archive_exception::stream_error)); return; if (c == 'i') // positive inf { //etc, etc
note that text streams automatically skip white space, so this could be shortened considerably. Robert Ramey