userver: dump::Reader Class Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
dump::Reader Class Referenceabstract

#include <userver/dump/operations.hpp>

Detailed Description

A general interface for binary data input.

Definition at line 48 of file operations.hpp.

+ Inheritance diagram for dump::Reader:

Public Member Functions

template<typename T>
Read ()
 Reads binary data.
 
virtual void Finish ()=0
 Must be called once all data has been read.
 

Protected Member Functions

virtual std::string_view ReadRaw (std::size_t max_size)=0
 Reads binary data.
 
virtual void BackUp (std::size_t size)
 Moves the internal cursor back by size bytes so that the next call to ReadRaw returns the same data again.
 

Member Function Documentation

◆ BackUp()

virtual void dump::Reader::BackUp ( std::size_t size)
protectedvirtual

Moves the internal cursor back by size bytes so that the next call to ReadRaw returns the same data again.

Note
If there has been no previous call to ReadRaw, or size is greater than the number of bytes returned from that call, the behavior is undefined.

◆ Finish()

virtual void dump::Reader::Finish ( )
pure virtual

Must be called once all data has been read.

Warning
This method must not be called from within Write/Read
Exceptions
`Error`on read operation failure or if there is leftover data

Implemented in dump::EncryptedReader, dump::FileReader, and dump::MockReader.

◆ Read()

template<typename T>
T dump::Reader::Read ( )

Reads binary data.

Calls ADL-found Read(reader, To<T>)

Exceptions
`Error`and any user-thrown std::exception

Definition at line 124 of file operations.hpp.

◆ ReadRaw()

virtual std::string_view dump::Reader::ReadRaw ( std::size_t max_size)
protectedpure virtual

Reads binary data.

Note
Invalidates the memory returned by the previous call of ReadRaw
Normally, exactly max_size bytes is returned. On end-of-file, the amount of bytes returned can be less than max_size.
Exceptions
`Error`on read operation failure

Friends And Related Symbol Documentation

◆ BackUpReadUnsafe

void BackUpReadUnsafe ( Reader & reader,
std::size_t size )
friend

Moves the internal cursor back by size bytes so that the next call to ReadUnsafeAtMost returns the same data again.

Note
If there has been no previous call to ReadUnsafeAtMost, or the last read operation was performed using something except ReadUnsafeAtMost, or size is greater than the number of bytes returned, then the behavior is undefined.

◆ ReadUnsafeAtMost

std::string_view ReadUnsafeAtMost ( Reader & reader,
std::size_t size )
friend

Reads a std::string_view

Note
Normally, exactly max_size bytes is returned. On end-of-file, the amount of bytes returned can be less than max_size.
Warning
The string_view will be invalidated on the next Read operation

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