Merge remote-tracking branch 'origin/master' into varargs-log-error-functions
This commit is contained in:
@ -9,8 +9,8 @@ reading or writing to files with error checking or translation of
|
||||
strings into specific types of numbers with checking for validity. This
|
||||
reduces redundant implementations and encourages consistent behavior.
|
||||
|
||||
I/O with status check
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
I/O with status check and similar functions
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The the first two functions are wrappers around the corresponding C
|
||||
library calls ``fgets()`` or ``fread()``. They will check if there
|
||||
@ -19,6 +19,14 @@ In that case, the functions will stop with an error message, indicating
|
||||
the name of the problematic file, if possible unless the *error* argument
|
||||
is a NULL pointer.
|
||||
|
||||
The :cpp:func:`fgets_trunc` function will work similar for ``fgets()``
|
||||
but it will read in a whole line (i.e. until the end of line or end
|
||||
of file), but store only as many characters as will fit into the buffer
|
||||
including a final newline character and the terminating NULL byte.
|
||||
If the line in the file is longer it will thus be truncated in the buffer.
|
||||
This function is used by :cpp:func:`read_lines_from_file` to read individual
|
||||
lines but make certain they follow the size constraints.
|
||||
|
||||
The :cpp:func:`read_lines_from_file` function will read the requested
|
||||
number of lines of a maximum length into a buffer and will return 0
|
||||
if successful or 1 if not. It also guarantees that all lines are
|
||||
@ -33,6 +41,9 @@ NULL character.
|
||||
.. doxygenfunction:: sfread
|
||||
:project: progguide
|
||||
|
||||
.. doxygenfunction:: fgets_trunc
|
||||
:project: progguide
|
||||
|
||||
.. doxygenfunction:: read_lines_from_file
|
||||
:project: progguide
|
||||
|
||||
|
||||
@ -223,6 +223,9 @@ The structure of the data file is important, though many settings and
|
||||
sections are optional or can come in any order. See the examples
|
||||
directory for sample data files for different problems.
|
||||
|
||||
The file will be read line by line, but there is a limit of 254
|
||||
characters per line and characters beyond that limit will be ignored.
|
||||
|
||||
A data file has a header and a body. The header appears first. The
|
||||
first line of the header is always skipped; it typically contains a
|
||||
description of the file. Then lines are read one at a time. Lines
|
||||
|
||||
@ -363,12 +363,14 @@ variable, as discussed below.
|
||||
|
||||
The rules for formatting the file are as follows. Each time a set of
|
||||
per-atom values is read, a non-blank line is searched for in the file.
|
||||
A comment character "#" can be used anywhere on a line; text starting
|
||||
with the comment character is stripped. Blank lines are skipped. The
|
||||
first "word" of a non-blank line, delimited by white-space, is read as
|
||||
the count N of per-atom lines to immediately follow. N can be the
|
||||
total number of atoms in the system, or only a subset. The next N
|
||||
lines have the following format
|
||||
The file is read line by line but only up to 254 characters are used.
|
||||
The rest are ignored. A comment character "#" can be used anywhere
|
||||
on a line and all text following and the "#" character are ignored;
|
||||
text starting with the comment character is stripped. Blank lines
|
||||
are skipped. The first "word" of a non-blank line, delimited by
|
||||
white-space, is read as the count N of per-atom lines to immediately
|
||||
follow. N can be the total number of atoms in the system, or only a
|
||||
subset. The next N lines have the following format
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
|
||||
Reference in New Issue
Block a user