xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
send_packets_element.h
Go to the documentation of this file.
1 #pragma once
5 
6 #include <fstream>
7 #include <functional>
8 #include <vector>
9 #include "../../ustring.h"
10 #include "../ip_address.h"
11 
13 #undef unix
14 
17 namespace xtd {
19  namespace net {
21  namespace sockets {
23  class socket;
25 
38  class core_export_ send_packets_element : public xtd::object {
39  public:
41 
44  using ifstream_ref = std::reference_wrapper<std::ifstream>;
46 
48 
51  send_packets_element() = default;
52 
56  explicit send_packets_element(const std::vector<byte_t>& buffer);
57 
65  send_packets_element(const xtd::ustring& file_path, size_t offset, size_t count, bool end_of_packet);
66 
73  send_packets_element(const std::vector<byte_t>& buffer, size_t offset, size_t count, bool end_of_packet);
74 
81  send_packets_element(const xtd::ustring& file_path, size_t offset, size_t count);
82 
89  send_packets_element(std::ifstream& file_stream, size_t offset, size_t count, bool end_of_packet);
90 
96  send_packets_element(const std::vector<byte_t>& buffer, size_t offset, size_t count);
97 
102  explicit send_packets_element(const xtd::ustring& file_path);
103 
107  explicit send_packets_element(std::ifstream& file_stream);
109 
114 
116 
121  std::vector<byte_t> buffer() const noexcept;
122 
127  size_t count() const noexcept;
128 
132  bool end_of_packet() const noexcept;
133 
138  const xtd::ustring& file_path() const noexcept;
139 
143  std::optional<ifstream_ref> file_stream() const noexcept;
144 
148  size_t offset() const noexcept;
150 
151  private:
152  std::vector<byte_t> buffer_;
153  size_t count_ = 0;
154  bool end_of_packet_ = false;
155  xtd::ustring file_path_;
156  std::ifstream* file_stream_ = nullptr;
157  size_t offset_ = 0;
158  bool delete_file_stream_when_destroy_ = false;
159  };
160  }
161  }
162 }
Implements the Berkeley sockets interface.
Definition: socket.h:68
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:50
Represents an element in a xtd::net::sockets::send_packets_element array.
Definition: send_packets_element.h:38
Socket options apply to all sockets.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:30
std::reference_wrapper< std::ifstream > ifstream_ref
Represent ta std::ifstream reference.
Definition: send_packets_element.h:44