roar
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | Static Private Attributes | List of all members
Roar::Detail::RangeFileBodyImpl Class Reference

Support range requests for get requests including multipart/byterange. More...

#include <range_file_body.hpp>

Collaboration diagram for Roar::Detail::RangeFileBodyImpl:

Classes

struct  Sequence
 

Public Member Functions

 RangeFileBodyImpl ()
 
 ~RangeFileBodyImpl ()=default
 
 RangeFileBodyImpl (RangeFileBodyImpl const &)=delete
 
 RangeFileBodyImpl (RangeFileBodyImpl &&)=default
 
RangeFileBodyImploperator= (RangeFileBodyImpl const &)=delete
 
RangeFileBodyImploperator= (RangeFileBodyImpl &&)=default
 
std::fstream & file ()
 
std::uint64_t size () const
 
std::uint64_t remaining () const
 
bool isMultipart () const
 
std::pair< std::uint64_t, std::uint64_t > firstRange ()
 
std::uint64_t fileSize ()
 
bool isOpen () const
 
void close ()
 
void open (std::filesystem::path const &filename, std::ios_base::openmode mode, std::error_code &ec)
 Opens the file.
 
void setReadRanges (Ranges const &ranges, std::string_view contentType)
 Set the Read Range.
 
std::size_t read (char *buf, std::size_t amount)
 Reads some of the multipart data into the buffer.
 
std::streamsize write (char const *buf, std::streamsize amount, bool &error)
 Writes the given buffer to the file.
 
void reset (std::fstream &&file)
 Resets the file stream with a new stream.
 
void reset ()
 Resets the fstream state and goes back to the start.
 
std::string boundary () const
 

Private Attributes

std::fstream file_ {}
 
std::vector< Sequencesequences_
 
std::string splitter_
 
std::uint64_t totalSize_
 
std::uint64_t consumed_
 

Static Private Attributes

static constexpr unsigned SplitterLength = 16
 

Detailed Description

Support range requests for get requests including multipart/byterange.

Constructor & Destructor Documentation

◆ RangeFileBodyImpl() [1/3]

Roar::Detail::RangeFileBodyImpl::RangeFileBodyImpl ( )
inline

◆ ~RangeFileBodyImpl()

Roar::Detail::RangeFileBodyImpl::~RangeFileBodyImpl ( )
default

◆ RangeFileBodyImpl() [2/3]

Roar::Detail::RangeFileBodyImpl::RangeFileBodyImpl ( RangeFileBodyImpl const &  )
delete

◆ RangeFileBodyImpl() [3/3]

Roar::Detail::RangeFileBodyImpl::RangeFileBodyImpl ( RangeFileBodyImpl &&  )
default

Member Function Documentation

◆ boundary()

std::string Roar::Detail::RangeFileBodyImpl::boundary ( ) const
inline

◆ close()

void Roar::Detail::RangeFileBodyImpl::close ( )
inline

◆ file()

std::fstream & Roar::Detail::RangeFileBodyImpl::file ( )
inline

◆ fileSize()

std::uint64_t Roar::Detail::RangeFileBodyImpl::fileSize ( )
inline

◆ firstRange()

std::pair< std::uint64_t, std::uint64_t > Roar::Detail::RangeFileBodyImpl::firstRange ( )
inline

◆ isMultipart()

bool Roar::Detail::RangeFileBodyImpl::isMultipart ( ) const
inline

◆ isOpen()

bool Roar::Detail::RangeFileBodyImpl::isOpen ( ) const
inline

◆ open()

void Roar::Detail::RangeFileBodyImpl::open ( std::filesystem::path const &  filename,
std::ios_base::openmode  mode,
std::error_code &  ec 
)
inline

Opens the file.

Parameters
filename
mode
ec

◆ operator=() [1/2]

RangeFileBodyImpl & Roar::Detail::RangeFileBodyImpl::operator= ( RangeFileBodyImpl &&  )
default

◆ operator=() [2/2]

RangeFileBodyImpl & Roar::Detail::RangeFileBodyImpl::operator= ( RangeFileBodyImpl const &  )
delete

◆ read()

std::size_t Roar::Detail::RangeFileBodyImpl::read ( char buf,
std::size_t  amount 
)
inline

Reads some of the multipart data into the buffer.

Parameters
buf
amount
Returns
std::size_t

◆ remaining()

std::uint64_t Roar::Detail::RangeFileBodyImpl::remaining ( ) const
inline

◆ reset() [1/2]

void Roar::Detail::RangeFileBodyImpl::reset ( )
inline

Resets the fstream state and goes back to the start.

◆ reset() [2/2]

void Roar::Detail::RangeFileBodyImpl::reset ( std::fstream &&  file)
inline

Resets the file stream with a new stream.

Parameters
fileA fresh fstream.

◆ setReadRanges()

void Roar::Detail::RangeFileBodyImpl::setReadRanges ( Ranges const &  ranges,
std::string_view  contentType 
)
inline

Set the Read Range.

Parameters
start
end

◆ size()

std::uint64_t Roar::Detail::RangeFileBodyImpl::size ( ) const
inline

◆ write()

std::streamsize Roar::Detail::RangeFileBodyImpl::write ( char const *  buf,
std::streamsize  amount,
bool &  error 
)
inline

Writes the given buffer to the file.

Parameters
buf
amount
error
Returns
std::size_t

Member Data Documentation

◆ consumed_

std::uint64_t Roar::Detail::RangeFileBodyImpl::consumed_
private

◆ file_

std::fstream Roar::Detail::RangeFileBodyImpl::file_ {}
private

◆ sequences_

std::vector<Sequence> Roar::Detail::RangeFileBodyImpl::sequences_
private

◆ splitter_

std::string Roar::Detail::RangeFileBodyImpl::splitter_
private

◆ SplitterLength

constexpr unsigned Roar::Detail::RangeFileBodyImpl::SplitterLength = 16
staticconstexprprivate

◆ totalSize_

std::uint64_t Roar::Detail::RangeFileBodyImpl::totalSize_
private

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