xtd 0.2.0
send_packets_element.h
Go to the documentation of this file.
1 #pragma once
5 #include "../ip_address.h"
6 #include "../../ustring.h"
7 #include <fstream>
8 #include <functional>
9 #include <vector>
10 
12 #undef unix
13 
16 namespace xtd {
18  namespace net {
20  namespace sockets {
22  class socket;
24 
39  class core_export_ send_packets_element : public xtd::object {
40  public:
42 
45  using ifstream_ref = std::reference_wrapper<std::ifstream>;
47 
49 
52  send_packets_element() = default;
53 
57  explicit send_packets_element(const std::vector<xtd::byte>& buffer);
58 
66  send_packets_element(const xtd::ustring& file_path, size_t offset, size_t count, bool end_of_packet);
67 
74  send_packets_element(const std::vector<xtd::byte>& buffer, size_t offset, size_t count, bool end_of_packet);
75 
82  send_packets_element(const xtd::ustring& file_path, size_t offset, size_t count);
83 
90  send_packets_element(std::ifstream& file_stream, size_t offset, size_t count, bool end_of_packet);
91 
97  send_packets_element(const std::vector<xtd::byte>& buffer, size_t offset, size_t count);
98 
103  explicit send_packets_element(const xtd::ustring& file_path);
104 
108  explicit send_packets_element(std::ifstream& file_stream);
110 
115 
117 
122  std::vector<xtd::byte> buffer() const noexcept;
123 
128  size_t count() const noexcept;
129 
133  bool end_of_packet() const noexcept;
134 
139  const xtd::ustring& file_path() const noexcept;
140 
144  std::optional<ifstream_ref> file_stream() const noexcept;
145 
149  size_t offset() const noexcept;
151 
152  private:
153  std::vector<xtd::byte> buffer_;
154  size_t count_ = 0;
155  bool end_of_packet_ = false;
156  xtd::ustring file_path_;
157  std::ifstream* file_stream_ = nullptr;
158  size_t offset_ = 0;
159  bool delete_file_stream_when_destroy_ = false;
160  };
161  }
162  }
163 }
Implements the Berkeley sockets interface.
Definition: socket.h:71
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:46
Represents an element in a xtd::net::sockets::send_packets_element array.
Definition: send_packets_element.h:39
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:32
std::reference_wrapper< std::ifstream > ifstream_ref
Represent ta std::ifstream reference.
Definition: send_packets_element.h:45
uint_least8_t byte
Represents a 8-bit unsigned integer.
Definition: types.h:39