pt_ifstream
and pt_ofstream
are derived from the standard stream classes ifstream
and ofstream
, respectively. They are defined in the header file pt_fstream.h.
They add the following features: First, certain special "filenames" are recognized. If the filename used in the constructor or an open
call is cin>,
cout>,
cerr>,
or clog>
(the angle brackets must be part of the string), then the corresponding standard stream of the same name is used for input (pt_ifstream
) or output (pt_ofstream
). In addition, C standard I/O fans can specify stdin>,
stdout>,
or stderr>
as well. Second, the Ptolemy expandPathName
is applied to the filename before it is opened, permitting it to start with ~user
or $VAR.
Finally, if a failure occurs when the file is opened, Error::abortRun
is called with an appropriate error message, including the Unix error condition. Otherwise these classes are identical to the standard ifstream and ofstream classes and can be used as replacements.