Loading...
Searching...
No Matches
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.
const file_meta_t & | meta () const
| Get file meta data.
auto | offset () const noexcept
| Get offset of data to write.
auto | size () const noexcept
| Get size of data to write.
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.
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.
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.

## Private Attributes

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

## 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.

## 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
| ) |  |

inline private noexcept

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 | ) |

inline noexcept

Definition at line 272 of file sendfile.hpp.

## Member Function Documentation

## check_file_is_valid()

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

inline private

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

Definition at line 429 of file sendfile.hpp.

## chunk_size() [1/3]

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

inline noexcept

Definition at line 353 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 361 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 371 of file sendfile.hpp.

## file_descriptor()

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

inline noexcept

Get the file descriptor of a given sendfile operation.

Definition at line 402 of file sendfile.hpp.

## is_valid()

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

inline noexcept

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

inline noexcept

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 345 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 | ) |

inline noexcept

Definition at line 281 of file sendfile.hpp.

## size()

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

inline noexcept

Get size of data to write.

Definition at line 306 of file sendfile.hpp.

## timelimit() [1/3]

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

inline noexcept

Definition at line 377 of file sendfile.hpp.

## timelimit() [2/3]

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

inline

Definition at line 385 of file sendfile.hpp.

## timelimit() [3/3]

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

inline

Definition at line 394 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 469 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 421 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 449 of file sendfile.hpp.

## m_file_descriptor

file_descriptor_holder_t restinio::sendfile_t::m_file_descriptor

private

Native file descriptor.

Definition at line 438 of file sendfile.hpp.

## m_meta

file_meta_t restinio::sendfile_t::m_meta

private

File meta data.

Definition at line 441 of file sendfile.hpp.

## m_offset

file_offset_t restinio::sendfile_t::m_offset

private

Data offset within the file.

Definition at line 444 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 446 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 455 of file sendfile.hpp.

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

- restinio/sendfile.hpp