The MCFClass Project
Functions in OPTUtils.h

Functions

template<class T >
void DfltdSfInpt (istream *iStrm, T &Param, const T Dflt, const char cmntc='#')
 Template function for reading parameters from a istream.
 

Detailed Description

Function Documentation

◆ DfltdSfInpt()

template<class T >
void DfltdSfInpt ( istream *  iStrm,
T &  Param,
const T  Dflt,
const char  cmntc = '#' 
)
inline

Template function for reading parameters from a istream.

The function is "safe" because it works also if the istream is not given, is not be long enough or contains erroneous things.

Given a &istream (possibly NULL), DfltdSfInpt() attempts to read Param out of it, skipping any line that begins with the comment characters (defaulted to '#'), any blank line and any line starting with anything that can not be interpreted as a 'T'. If, for any reason, the read operation fails, then the parameter is given the default value 'Dflt'. Otherwise, all the rest of the line up to the nearest newline ('
') characters is flushed.

Note
lines should not be longer than 1023 characters.