Bitcoin Core 30.99.0
P2P Digital Currency
Public Member Functions | Public Attributes | List of all members
util::LineReader Struct Reference

#include <string.h>

Public Member Functions

 LineReader (std::span< const std::byte > buffer, size_t max_line_length)
 
std::optional< std::string > ReadLine ()
 Returns a string from current iterator position up to (but not including) next
and advances iterator to the character following the
on success. More...
 
std::string ReadLength (size_t len)
 Returns string from current iterator position of specified length if possible and advances iterator on success. More...
 
size_t Remaining () const
 Returns remaining size of bytes in buffer. More...
 

Public Attributes

const std::span< conststd::byte >::iterator start
 
const std::span< conststd::byte >::iterator end
 
const size_t max_line_length
 
std::span< conststd::byte >::iterator it
 

Detailed Description

Definition at line 265 of file string.h.

Constructor & Destructor Documentation

◆ LineReader()

util::LineReader::LineReader ( std::span< const std::byte >  buffer,
size_t  max_line_length 
)
explicit

Definition at line 17 of file string.cpp.

Member Function Documentation

◆ ReadLength()

std::string util::LineReader::ReadLength ( size_t  len)

Returns string from current iterator position of specified length if possible and advances iterator on success.

May exceed max_line_length but will not read past end of buffer.

Parameters
[in]lenThe number of bytes to read from the buffer
Returns
a string of the expected length.
Exceptions
astd::runtime_error if there is not enough data in the buffer.

Definition at line 57 of file string.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadLine()

std::optional< std::string > util::LineReader::ReadLine ( )

Returns a string from current iterator position up to (but not including) next
and advances iterator to the character following the
on success.

Will not return a line longer than max_line_length.

Returns
the next string from the buffer. std::nullopt if end of buffer is reached without finding a
.
Exceptions
astd::runtime_error if max_line_length + 1 bytes are read without finding
.

Definition at line 20 of file string.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Remaining()

size_t util::LineReader::Remaining ( ) const

Returns remaining size of bytes in buffer.

Definition at line 66 of file string.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ end

const std::span<conststd::byte>::iterator util::LineReader::end

Definition at line 267 of file string.h.

◆ it

std::span<conststd::byte>::iterator util::LineReader::it

Definition at line 269 of file string.h.

◆ max_line_length

const size_t util::LineReader::max_line_length

Definition at line 268 of file string.h.

◆ start

const std::span<conststd::byte>::iterator util::LineReader::start

Definition at line 266 of file string.h.


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