userver: engine::io::BufferedReader Class Reference
Loading...
Searching...
No Matches
engine::io::BufferedReader Class Referencefinal

#include <userver/engine/io/buffered.hpp>

Detailed Description

Wrapper for buffered input.

Definition at line 31 of file buffered.hpp.

Public Member Functions

 BufferedReader (ReadableBasePtr source)
 Creates a buffered reader with default buffer size.
 
 BufferedReader (ReadableBasePtr source, size_t buffer_size)
 Creates a buffered reader with specified initial buffer size.
 
 BufferedReader (BufferedReader &&) noexcept
 
BufferedReaderoperator= (BufferedReader &&) noexcept
 
bool IsValid () const
 Whether the underlying source is valid.
 
std::string ReadSome (size_t max_bytes, Deadline deadline={})
 Reads some bytes from the input stream.
 
std::string ReadAll (size_t num_bytes, Deadline deadline={})
 Reads the exact number of bytes from the input stream.
 
std::string ReadLine (Deadline deadline={})
 Reads a line from the input, skipping empty lines.
 
std::string ReadUntil (char terminator, Deadline deadline={})
 Reads the stream until the specified character of EOF is encountered.
 
std::string ReadUntil (utils::function_ref< bool(int) const > pred, Deadline deadline={})
 Reads the stream until the predicate returns true.
 
int Getc (Deadline deadline={})
 Reads one byte from the stream or reports an EOF (-1).
 
int Peek (Deadline deadline={})
 Returns the first byte of the buffer or EOF (-1).
 
void Discard (size_t num_bytes, Deadline deadline={})
 Discards the specified number of bytes from the buffer.
 

Member Function Documentation

◆ ReadAll()

std::string engine::io::BufferedReader::ReadAll ( size_t num_bytes,
Deadline deadline = {} )

Reads the exact number of bytes from the input stream.

Note
May return less bytes than requested in case of EOF.

◆ ReadLine()

std::string engine::io::BufferedReader::ReadLine ( Deadline deadline = {})

Reads a line from the input, skipping empty lines.

Note
Does not return line terminators.

◆ ReadUntil()

std::string engine::io::BufferedReader::ReadUntil ( utils::function_ref< bool(int) const > pred,
Deadline deadline = {} )

Reads the stream until the predicate returns true.

Parameters
predpredicate that will be called for each byte read and EOF.

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