Crashpad
|
Reads a file one field or line at a time. More...
#include "util/file/delimited_file_reader.h"
Public Types | |
enum | Result |
The result of a GetDelim() or GetLine() call. More... | |
Public Member Functions | |
DelimitedFileReader (FileReaderInterface *file_reader) | |
Result | GetDelim (char delimiter, std::string *field) |
Reads a single field from the file. More... | |
Result | GetLine (std::string *line) |
Reads a single line from the file. More... | |
Reads a file one field or line at a time.
The file is interpreted as a series of fields separated by delimiter characters. When the delimiter character is the newline character ('\n'
), the file is interpreted as a series of lines.
It is safe to mix GetDelim() and GetLine() calls, if appropriate for the format being interpreted.
This is a replacement for the standard library’s getdelim()
and getline()
functions, adapted to work with FileReaderInterface objects instead of FILE*
streams.
|
strong |
The result of a GetDelim() or GetLine() call.
Enumerator | |
---|---|
kError | An error occurred, and a message was logged. |
kSuccess | A field or line was read from the file. |
kEndOfFile | The end of the file was encountered. |
DelimitedFileReader::Result crashpad::DelimitedFileReader::GetDelim | ( | char | delimiter, |
std::string * | field | ||
) |
Reads a single field from the file.
[in] | delimiter | The delimiter character that terminates the field. It is safe to call this method multiple times while changing the value of this parameter, if appropriate for the format being interpreted. |
[out] | field | The field read from the file. This parameter will include the field’s terminating delimiter character unless the field was at the end of the file and was read without such a character. This parameter will not be empty. |
DelimitedFileReader::Result crashpad::DelimitedFileReader::GetLine | ( | std::string * | line | ) |
Reads a single line from the file.
[out] | line | The line read from the file. This parameter will include the line terminating delimiter character unless the line was at the end of the file and was read without such a character. This parameter will not be empty. |