From def5c50960eea4c112647f88361a3ae7155901a8 Mon Sep 17 00:00:00 2001 From: egor-tensin Date: Tue, 4 Jul 2023 00:48:00 +0000 Subject: =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20egor-tensin/wina?= =?UTF-8?q?pi-common@0c196cbe8b4927c78c02b2c7312fc69a507db845=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handle_8hpp_source.html | 152 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 handle_8hpp_source.html (limited to 'handle_8hpp_source.html') diff --git a/handle_8hpp_source.html b/handle_8hpp_source.html new file mode 100644 index 0000000..179b098 --- /dev/null +++ b/handle_8hpp_source.html @@ -0,0 +1,152 @@ + + + + + + + +winapi_common: include/winapi/handle.hpp Source File + + + + + + + + + +
+
+ + + + + + +
+
winapi_common +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
handle.hpp
+
+
+
1 // Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com>
+
2 // This file is part of the "winapi-common" project.
+
3 // For details, see https://github.com/egor-tensin/winapi-common.
+
4 // Distributed under the MIT License.
+
5 
+
6 #pragma once
+
7 
+
8 #include "buffer.hpp"
+
9 
+
10 #include <windows.h>
+
11 
+
12 #include <cstddef>
+
13 #include <memory>
+
14 #include <string>
+
15 #include <utility>
+
16 
+
17 namespace winapi {
+
18 
+
25 class Handle {
+
26 public:
+
27  Handle() = default;
+
28  explicit Handle(HANDLE);
+
29 
+
30  HANDLE get() const { return m_impl.get(); }
+
31  HANDLE ptr() const { return get(); }
+
32 
+
33  explicit operator HANDLE() const { return ptr(); }
+
34 
+
35  bool is_valid() const;
+
36  static bool is_valid(HANDLE);
+
37 
+
39  void close();
+
40 
+
42  bool is_std() const;
+
44  static Handle std_in();
+
46  static Handle std_out();
+
48  static Handle std_err();
+
49 
+
51  Buffer read() const;
+
52 
+
53  static constexpr std::size_t max_chunk_size = 16 * 1024;
+
59  bool read_chunk(Buffer& read_chunk) const;
+
60 
+
66  void write(const void* data, std::size_t nb) const;
+
71  void write(const Buffer& buffer) const;
+
72 
+
77  template <typename CharT>
+
78  void write(const std::basic_string<CharT>& src) const {
+
79  write(src.c_str(), src.size() * sizeof(CharT));
+
80  }
+
81 
+
82  void inherit(bool yes = true) const;
+
83  void dont_inherit() const { inherit(false); }
+
84 
+
85 private:
+
86  struct Close {
+
87  void operator()(HANDLE) const;
+
88  };
+
89 
+
90  std::unique_ptr<void, Close> m_impl;
+
91 };
+
92 
+
93 } // namespace winapi
+
Binary data container.
Definition: buffer.hpp:24
+
HANDLE wrapper.
Definition: handle.hpp:25
+
static Handle std_in()
Definition: handle.cpp:55
+
bool read_chunk(Buffer &read_chunk) const
Definition: handle.cpp:67
+
void close()
Definition: handle.cpp:47
+
static Handle std_out()
Definition: handle.cpp:59
+
static Handle std_err()
Definition: handle.cpp:63
+
void write(const std::basic_string< CharT > &src) const
Definition: handle.hpp:78
+
bool is_std() const
Definition: handle.cpp:51
+
Buffer read() const
Definition: handle.cpp:93
+
void write(const void *data, std::size_t nb) const
Definition: handle.cpp:109
+
+ + + + -- cgit v1.2.3