libkazv
Kazv::FileStream Class Reference

#include <file-desc.hpp>

Public Types

using DataT = FileContent
 

Public Member Functions

template<class DeriveT >
 FileStream (DeriveT &&o)
 Constructor. More...
 
template<class Callback >
void read (int maxSize, Callback readCallback)
 Read at most maxSize bytes from the stream. More...
 
template<class Callback >
void write (DataT data, Callback writeCallback)
 Write data into the stream. More...
 

Member Typedef Documentation

◆ DataT

Constructor & Destructor Documentation

◆ FileStream()

template<class DeriveT >
Kazv::FileStream::FileStream ( DeriveT &&  o)
inline

Constructor.

Construct a FileStream using o.

o should be of a type that accepts the read and write methods in this class. That is, o.read(int{}, std::function<void(FileOpRetCode, DataT)>{}) and o.write(DataT{}, std::function<void(FileOpRetCode, int)>{}) must both be well-formed.

Member Function Documentation

◆ read()

template<class Callback >
void Kazv::FileStream::read ( int  maxSize,
Callback  readCallback 
)
inline

Read at most maxSize bytes from the stream.

This calls readCallback(FileOpRetCode::Success, data) upon success, where data is a DataT containing the bytes read; calls readCallback(FileOpRetCode::Eof, DataT{}) upon meeting EOF; and calls readCallback(FileOpRetCode::Error, DataT{}) upon other errors.

◆ write()

template<class Callback >
void Kazv::FileStream::write ( DataT  data,
Callback  writeCallback 
)
inline

Write data into the stream.

This calls writeCallback(FileOpRetCode::Success, num) upon success, where num is an integer that contains the number of bytes written. and calls readCallback(FileOpRetCode::Error, 0) upon other errors.


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