Reads data from a single line in an input stream.
- Author
- Creighton, T. D.
Description
These routines read ASCII data from the I/O stream *stream
until a newline or the end-of-input is reached. (The line can be of arbitrary length; the data is temporarily stored in a linked list of buffers.) Once read, a LAL vector structure **vector
is created and the data stored in it. The routine passes back a pointer to the new structure. For the numerical routines, the strict
parameter determines whether the routine will do strict error checking based on the contents of the input stream (see below).
The basic routine in this module is LALCHARReadVector()
, which simply stores bytes read from *stream
until the next newline character '
'
, null character '\0'
, or the end of the input as determined by the feof()
function. The vector includes the newline (if present), and also an explicit '\0'
at the end, if one was not already present. This routine should not be used to read a binary data stream, which are not logically divided into `‘lines’'. Unless it aborts due to invalid arguments or failed memory allocation, LALCHARReadVector()
will always return successfully regardless of the contents of the input stream; *vector
will created containing at least a single '\0'
terminator, if nothing else.
The other routines in this module use LALCHARReadVector()
to read a line, and then parse it into numerical datatypes using the corresponding routine in the StringConvert.c. Conversion stops when the routine encounters a character that cannot be parsed as part of a number. If strict
is 0, the routine will fail only due to invalid arguments or memory allocation failure, not from a poorly-formatted input stream; if no numbers are read, *vector
will remain NULL
, but no error will be reported. (In this mode, the calling routine should always test the output before trying to dereference it, in order to avoid segmentation violations.) If strict
is nonzero, the routine will report an error if the input stream was poorly formatted, either an ELEN
error if no numbers were read, or EFMT
if a character was encountered that was neither part of a parseable number nor whitespace.
Note that strict=0
allows an input stream to contain blank lines or comments. A comment begins with any character that cannot occur in a valid number, which will cause the numerical parser to skip the rest of the line. The usual comment delimiters are '#'
and ''
, but any character except '+'
'-'
, 'e'
, 'E'
, '.'
, digits, and whitespace will work.
|
void | LALCHARReadVector (LALStatus *status, CHARVector **vector, FILE *stream) |
|
void | LALI2ReadVector (LALStatus *status, INT2Vector **vector, FILE *stream, BOOLEAN strict) |
|
void | LALI4ReadVector (LALStatus *status, INT4Vector **vector, FILE *stream, BOOLEAN strict) |
|
void | LALI8ReadVector (LALStatus *status, INT8Vector **vector, FILE *stream, BOOLEAN strict) |
|
void | LALU2ReadVector (LALStatus *status, UINT2Vector **vector, FILE *stream, BOOLEAN strict) |
|
void | LALU4ReadVector (LALStatus *status, UINT4Vector **vector, FILE *stream, BOOLEAN strict) |
|
void | LALU8ReadVector (LALStatus *status, UINT8Vector **vector, FILE *stream, BOOLEAN strict) |
|
void | LALSReadVector (LALStatus *status, REAL4Vector **vector, FILE *stream, BOOLEAN strict) |
|
void | LALDReadVector (LALStatus *status, REAL8Vector **vector, FILE *stream, BOOLEAN strict) |
|
◆ LALCHARReadVector()
◆ LALI2ReadVector()
◆ LALI4ReadVector()
◆ LALI8ReadVector()
◆ LALU2ReadVector()
◆ LALU4ReadVector()
◆ LALU8ReadVector()
◆ LALSReadVector()
◆ LALDReadVector()