On Mon, Nov 14, 2005 at 08:12:18AM -0800, Robert Ramey wrote:
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.
Did it arrive with the wrapping all screwed up like that? If so, sorry. Anyhow the question was if factoring that all out into lexical_cast<> (or something similar but located inside the serialization library) makes any sense. -t