RESTinio
|
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... | |
Send file write operation description.
Class gives a fluen-interface for setting various parameters for performing send file operation.
Definition at line 225 of file sendfile.hpp.
|
inlineprivatenoexcept |
fdh | File descriptor. |
meta | File meta data. |
chunk | Send chunk size. |
Definition at line 232 of file sendfile.hpp.
|
delete |
|
inlinenoexcept |
Definition at line 272 of file sendfile.hpp.
|
inlineprivate |
Check if stored file descriptor is valid, and throws if it is not.
Definition at line 428 of file sendfile.hpp.
|
inlinenoexcept |
Definition at line 352 of file sendfile.hpp.
|
inline |
Definition at line 360 of file sendfile.hpp.
|
inline |
Set prefered chunk size to use in write operation.
Definition at line 370 of file sendfile.hpp.
|
inlinenoexcept |
Get the file descriptor of a given sendfile operation.
Definition at line 401 of file sendfile.hpp.
|
inlinenoexcept |
Check if file is valid.
Definition at line 294 of file sendfile.hpp.
|
inline |
Get file meta data.
Definition at line 297 of file sendfile.hpp.
|
inlinenoexcept |
Get offset of data to write.
Definition at line 303 of file sendfile.hpp.
|
inline |
Definition at line 319 of file sendfile.hpp.
|
inline |
Definition at line 344 of file sendfile.hpp.
|
delete |
|
inlinenoexcept |
Definition at line 281 of file sendfile.hpp.
|
inlinenoexcept |
Get size of data to write.
Definition at line 306 of file sendfile.hpp.
|
inlinenoexcept |
Definition at line 376 of file sendfile.hpp.
|
inline |
Definition at line 384 of file sendfile.hpp.
|
inline |
Definition at line 393 of file sendfile.hpp.
|
friend |
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.
|
friend |
Definition at line 249 of file sendfile.hpp.
|
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.
Definition at line 420 of file sendfile.hpp.
|
private |
A prefered chunk size for a single write call.
Definition at line 448 of file sendfile.hpp.
|
private |
Native file descriptor.
Definition at line 437 of file sendfile.hpp.
|
private |
File meta data.
Definition at line 440 of file sendfile.hpp.
|
private |
Data offset within the file.
Definition at line 443 of file sendfile.hpp.
|
private |
The size of data portion in file.
Definition at line 445 of file sendfile.hpp.
|
private |
Timelimit for writing all the given data.
Zero value stands for default write operation timeout.
Definition at line 454 of file sendfile.hpp.