Nvwa  1.1
Classes | Public Types | Public Member Functions | List of all members
nvwa::file_line_reader Class Reference

Class to allow iteration over all lines of a text file. More...

#include <file_line_reader.h>

Classes

class  iterator
 Iterator that contains the line content. More...
 

Public Types

enum  strip_type { strip_delimiter, no_strip_delimiter }
 Enumeration of whether the delimiter should be stripped. More...
 

Public Member Functions

 file_line_reader (FILE *stream, char delimiter='\n', strip_type strip=strip_delimiter)
 Constructor. More...
 
 ~file_line_reader ()
 Destructor. More...
 
bool read (char *&output, size_t &size, size_t &capacity)
 Reads content from the file stream. More...
 

Detailed Description

Class to allow iteration over all lines of a text file.

Member Enumeration Documentation

◆ strip_type

Enumeration of whether the delimiter should be stripped.

Enumerator
strip_delimiter 

The delimiter should be stripped.

no_strip_delimiter 

The delimiter should be retained.

Constructor & Destructor Documentation

◆ file_line_reader()

nvwa::file_line_reader::file_line_reader ( FILE *  stream,
char  delimiter = '\n',
strip_type  strip = strip_delimiter 
)
explicit

Constructor.

Parameters
streamthe file stream to read from
delimiterthe delimiter between text `lines' (default to LF)
stripenumerator about whether to strip the delimiter

◆ ~file_line_reader()

nvwa::file_line_reader::~file_line_reader ( )

Destructor.

Member Function Documentation

◆ read()

bool nvwa::file_line_reader::read ( char *&  output,
size_t &  size,
size_t &  capacity 
)

Reads content from the file stream.

If necessary, the receiving buffer will be expanded so that it is big enough to contain all the line content.

Parameters
[in,out]outputinitial receiving buffer
[out]sizesize of the line
[in,out]capacitycapacity of the initial receiving buffer on entering the function; it can be increased when necessary
Returns
true if line content is returned; false otherwise

The documentation for this class was generated from the following files: