delpi  0.0.1
DElta-complete LP solver
Loading...
Searching...
No Matches
delpi::BufferLineSource Class Reference

A class that provides a source for lines of text buffered in memory. More...

#include <BufferLineSource.h>

Inheritance diagram for delpi::BufferLineSource:
delpi::MappedFileSource

Public Member Functions

bool nextLine (std::string_view &out)
 Retrieve the next line from the buffer.

Protected Member Functions

void initialize (const char *data, std::size_t length)
 Force a reinitialization of the object, setting cur_ and end_ to the new values.

Private Attributes

const char * cur_
 Pointer to the current position in the buffer.
const char * end_
 Pointer to the end of the buffer.

Detailed Description

A class that provides a source for lines of text buffered in memory.

It keeps track of the current position in the buffer and allows retrieving lines one by one. The buffer is represented as a contiguous block of memory, and the class provides methods to access the lines without copying the data, using std::string_view. The class also stores a name for the source, which can be used for error reporting or debugging purposes.

Note
The buffer is not owned by the BufferLineSource, and it is the caller's responsibility to ensure that the buffer remains valid for the lifetime of the BufferLineSource object.

Definition at line 25 of file BufferLineSource.h.

Member Function Documentation

◆ initialize()

void delpi::BufferLineSource::initialize ( const char * data,
std::size_t length )
protected

Force a reinitialization of the object, setting cur_ and end_ to the new values.

Parameters
datanew buffer of data
lengthlength of the new buffer

Definition at line 28 of file BufferLineSource.cpp.

◆ nextLine()

bool delpi::BufferLineSource::nextLine ( std::string_view & out)

Retrieve the next line from the buffer.

A line terminates with an '\n' or the end of the buffer. Moreover, if an '\r' character precedes the '\n' character, it is removed from the returned view.

Parameters
outview of a line in the buffer, stripped of any newline characters
Returns
true if there is still some buffer left to read
false if the end of the buffer has been reached

Definition at line 16 of file BufferLineSource.cpp.


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