| |
|
|
Formated I/O
Formatted Input
The ObjexxFCL formatted input capability allows formatted reads to be performed using C++ streams, as in:
int i, j; stream >> bite(3,i) >> skip(1) >> bite(2,j) >> skip;
|
A numeric first argument to bite is the number of characters to read the variable into. Variables of a known width, such as char or Fstring, can be read with a one-argument bite function, as in bite(name). Character strings are read into the variables as is: no BLANK=ZERO or nP Fortran-like read capability is available at this time.
A numeric argument to skip is the number of characters to skip over. A trailing skip reads the rest of the line and the line terminator.
Formatted Output
The ObjexxFCL formatted output capability provides the core Fortran formatted write capability with C++ streams, as in:
int i, j; double x, y;
Fstring name(20);
std::string address;
...
stream << I(3,i) << space(1) << I(2,j) << '\n';
stream << F(9,3,x) << G(15,6,y) << '\n';
stream << A(15,name) << '\n';
stream << A(30,address) << '\n';
|
The floating point output functions have the form F(w,d,v), E(w,d,v), and G(w,d,v) where w is the field width, d is the number of digits, and v stands for the variable.
Formatting similar to Fortran list-directed writes are provided by some additional functions. List-directed write formatting is not standardized so two classes of functions are provided. The SS functions provide single-space separated, minimal width output (akin to GCC g77 list-directed output) and the SW functions provide a standard-width format with each field's width and precision based on its data type.
Organization
The formatted i/o functions and classes are contained within a nested ObjexxFCL::fmt namespace to provide control over scoping and name conflicts.
Sources using the formatted i/o support must include the format.hh header file.
|
|
|
|