restinio::sendfile_t Class Reference

Send file write operation description. More...

`#include <sendfile.hpp>`

## Public Member Functions

bool | is_valid () const noexcept
| Check if file is valid. More...
const file_meta_t & | meta () const
| Get file meta data. More...
auto | offset () const noexcept
| Get offset of data to write. More...
auto | size () const noexcept
| Get size of data to write. More...
auto | chunk_size () const noexcept
auto | timelimit () const noexcept
file_descriptor_t | file_descriptor () const noexcept
| Get the file descriptor of a given sendfile operation. More...
Copy semantics.
Not allowed.
| sendfile_t (const sendfile_t &)=delete
sendfile_t & | operator= (const sendfile_t &)=delete
Move semantics.
After move sf prameter becomes invalid.
| sendfile_t (sendfile_t &&sf) noexcept
sendfile_t & | operator= (sendfile_t &&sf) noexcept
Set file offset and size.
Tries to set offset parameter to offset_value and size to size value. If sendfile_t object is invalid then exception is thrown. If offset_value is a valid offset within current file then ofsett is set to new value. The size might be shrinked so to represent at most the length of file from a given offset.
sendfile_t & | offset_and_size (file_offset_t offset_value, file_size_t size_value=std::numeric_limits< file_size_t >::max()) &
sendfile_t && | offset_and_size (file_offset_t offset_value, file_size_t size_value=std::numeric_limits< file_size_t >::max()) &&
Set prefered chunk size to use in write operation.
Set the maximum possible size of the portion of data to be send at a single write file operation (from file to socket).
sendfile_t & | chunk_size (sendfile_chunk_size_guarded_value_t chunk) &
sendfile_t && | chunk_size (sendfile_chunk_size_guarded_value_t chunk) &&
| Set prefered chunk size to use in write operation. More...
Set timelimit on write operation..
Set the maximum dureation of this sendfile operation (the whole thing, not just a single iteration).
sendfile_t & | timelimit (std::chrono::steady_clock::duration timelimit_value) &
sendfile_t && | timelimit (std::chrono::steady_clock::duration timelimit_value) &&

## Private Member Functions

| sendfile_t (file_descriptor_holder_t fdh, file_meta_t meta, sendfile_chunk_size_guarded_value_t chunk) noexcept
void | check_file_is_valid () const
| Check if stored file descriptor is valid, and throws if it is not. More...

## Private Attributes

file_descriptor_holder_t | m_file_descriptor
| Native file descriptor. More...
file_meta_t | m_meta
| File meta data. More...
file_offset_t | m_offset
| Data offset within the file. More...
file_size_t | m_size
| The size of data portion in file. More...
file_size_t | m_chunk_size
| A prefered chunk size for a single write call. More...
std::chrono::steady_clock::duration | m_timelimit { std::chrono::steady_clock::duration::zero() }
| Timelimit for writing all the given data. More...

## Friends

sendfile_t | sendfile (file_descriptor_holder_t, file_meta_t, file_size_t) noexcept
void | swap (sendfile_t &left, sendfile_t &right) noexcept
file_descriptor_holder_t | takeaway_file_descriptor (sendfile_t &target)
| Take away the file description form sendfile object. More...

## Detailed Description

Send file write operation description.

Class gives a fluen-interface for setting various parameters for performing send file operation.

Since
  v.0.4.3

Definition at line 225 of file sendfile.hpp.

## Constructor & Destructor Documentation

## sendfile_t() [1/3]

restinio::sendfile_t::sendfile_t | ( | file_descriptor_holder_t | fdh,
|  | file_meta_t | meta,
|  | sendfile_chunk_size_guarded_value_t | chunk
| ) |  |

inlineprivatenoexcept

Parameters

  fdh | File descriptor.
  meta | File meta data.
  chunk | Send chunk size.

Definition at line 232 of file sendfile.hpp.

## sendfile_t() [2/3]

restinio::sendfile_t::sendfile_t | ( | const sendfile_t & |  | ) |

delete

## sendfile_t() [3/3]

restinio::sendfile_t::sendfile_t | ( | sendfile_t && | sf | ) |

inlinenoexcept

Definition at line 272 of file sendfile.hpp.

## Member Function Documentation

## check_file_is_valid()

void restinio::sendfile_t::check_file_is_valid | ( |  | ) | const

inlineprivate

Check if stored file descriptor is valid, and throws if it is not.

Definition at line 428 of file sendfile.hpp.

## chunk_size() [1/3]

auto restinio::sendfile_t::chunk_size | ( |  | ) | const

inlinenoexcept

Definition at line 352 of file sendfile.hpp.

## chunk_size() [2/3]

sendfile_t & restinio::sendfile_t::chunk_size | ( | sendfile_chunk_size_guarded_value_t | chunk | ) | &

inline

Definition at line 360 of file sendfile.hpp.

## chunk_size() [3/3]

sendfile_t && restinio::sendfile_t::chunk_size | ( | sendfile_chunk_size_guarded_value_t | chunk | ) | &&

inline

Set prefered chunk size to use in write operation.

Definition at line 370 of file sendfile.hpp.

## file_descriptor()

file_descriptor_t restinio::sendfile_t::file_descriptor | ( |  | ) | const

inlinenoexcept

Get the file descriptor of a given sendfile operation.

Definition at line 401 of file sendfile.hpp.

## is_valid()

bool restinio::sendfile_t::is_valid | ( |  | ) | const

inlinenoexcept

Check if file is valid.

Definition at line 294 of file sendfile.hpp.

## meta()

const file_meta_t & restinio::sendfile_t::meta | ( |  | ) | const

inline

Get file meta data.

Definition at line 297 of file sendfile.hpp.

## offset()

auto restinio::sendfile_t::offset | ( |  | ) | const

inlinenoexcept

Get offset of data to write.

Definition at line 303 of file sendfile.hpp.

## offset_and_size() [1/2]

sendfile_t & restinio::sendfile_t::offset_and_size | ( | file_offset_t | offset_value,
|  | file_size_t | size_value = `std::numeric_limits< file_size_t >::max()`
| ) |  | &

inline

Definition at line 319 of file sendfile.hpp.

## offset_and_size() [2/2]

sendfile_t && restinio::sendfile_t::offset_and_size | ( | file_offset_t | offset_value,
|  | file_size_t | size_value = `std::numeric_limits< file_size_t >::max()`
| ) |  | &&

inline

Definition at line 344 of file sendfile.hpp.

## operator=() [1/2]

sendfile_t & restinio::sendfile_t::operator= | ( | const sendfile_t & |  | ) |

delete

## operator=() [2/2]

sendfile_t & restinio::sendfile_t::operator= | ( | sendfile_t && | sf | ) |

inlinenoexcept

Definition at line 281 of file sendfile.hpp.

## size()

auto restinio::sendfile_t::size | ( |  | ) | const

inlinenoexcept

Get size of data to write.

Definition at line 306 of file sendfile.hpp.

## timelimit() [1/3]

auto restinio::sendfile_t::timelimit | ( |  | ) | const

inlinenoexcept

Definition at line 376 of file sendfile.hpp.

## timelimit() [2/3]

sendfile_t & restinio::sendfile_t::timelimit | ( | std::chrono::steady_clock::duration | timelimit_value | ) | &

inline

Definition at line 384 of file sendfile.hpp.

## timelimit() [3/3]

sendfile_t && restinio::sendfile_t::timelimit | ( | std::chrono::steady_clock::duration | timelimit_value | ) | &&

inline

Definition at line 393 of file sendfile.hpp.

## Friends And Related Function Documentation

## sendfile

sendfile_t sendfile | ( | file_descriptor_holder_t | fd,
|  | file_meta_t | meta,
|  | file_size_t | chunk_size = `sendfile_default_chunk_size`
| ) |  |

friend

Parameters

  fd | Native file descriptor.
  meta | File meta data.
  chunk_size | The max size of a data to be send on a single iteration.

Definition at line 468 of file sendfile.hpp.

## swap

void swap | ( | sendfile_t & | left,
|  | sendfile_t & | right
| ) |  |

friend

Definition at line 249 of file sendfile.hpp.

## takeaway_file_descriptor

file_descriptor_holder_t takeaway_file_descriptor | ( | sendfile_t & | target | ) |

friend

Take away the file description form sendfile object.

This helper function takes the file description from sendfile object. After it the sendfile object will hold invalid file descriptor and will not try to close the file in the constructor.

The take of the file description can be necessary, for example, on Windows platform where an instance of Asio's random_access_handle is used for file's content transmision. That instance also closes the file in the destructor.

Since
  v.0.4.9

Definition at line 420 of file sendfile.hpp.

## Member Data Documentation

## m_chunk_size

file_size_t restinio::sendfile_t::m_chunk_size

private

A prefered chunk size for a single write call.

Definition at line 448 of file sendfile.hpp.

## m_file_descriptor

file_descriptor_holder_t restinio::sendfile_t::m_file_descriptor

private

Native file descriptor.

Definition at line 437 of file sendfile.hpp.

## m_meta

file_meta_t restinio::sendfile_t::m_meta

private

File meta data.

Definition at line 440 of file sendfile.hpp.

## m_offset

file_offset_t restinio::sendfile_t::m_offset

private

Data offset within the file.

Definition at line 443 of file sendfile.hpp.

## m_size

file_size_t restinio::sendfile_t::m_size

private

The size of data portion in file.

Definition at line 445 of file sendfile.hpp.

## m_timelimit

std::chrono::steady_clock::duration restinio::sendfile_t::m_timelimit { std::chrono::steady_clock::duration::zero() }

private

Timelimit for writing all the given data.

Zero value stands for default write operation timeout.

Definition at line 454 of file sendfile.hpp.

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

- restinio/sendfile.hpp