diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-03-10 12:39:04 +0500 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-03-10 12:48:59 +0500 |
commit | 4a13df61b92b8bf673f8a71d5fa0abf0356a4899 (patch) | |
tree | 071a3830ce0f2309e40a4bb16b7dd42018bd852f /include/winapi/handle.hpp | |
parent | Makefile: remove stupid header, etc. (diff) | |
download | winapi-common-4a13df61b92b8bf673f8a71d5fa0abf0356a4899.tar.gz winapi-common-4a13df61b92b8bf673f8a71d5fa0abf0356a4899.zip |
add Doxygen docs
Diffstat (limited to '')
-rw-r--r-- | include/winapi/handle.hpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/include/winapi/handle.hpp b/include/winapi/handle.hpp index 8ea90aa..b5a7547 100644 --- a/include/winapi/handle.hpp +++ b/include/winapi/handle.hpp @@ -16,6 +16,12 @@ namespace winapi { +/** + * @brief HANDLE wrapper. + * + * This class wraps HANDLE, allowing for painless reads and writes from a + * random handle. + */ class Handle { public: Handle() = default; @@ -29,21 +35,45 @@ public: bool is_valid() const; static bool is_valid(HANDLE); + /** Close this handle. */ void close(); + /** Check if this is a standard console handle. */ bool is_std() const; + /** Check if this is the stdin handle. */ static Handle std_in(); + /** Check if this is the stdout handle. */ static Handle std_out(); + /** Check if this is the stderr handle. */ static Handle std_err(); + /** Read everything from this handle. */ Buffer read() const; static constexpr std::size_t max_chunk_size = 16 * 1024; + /** + * Read a chunk from this handle. + * @param read_chunk Receives the data read. + * @return `true` if there's more data, `false` otherwise. + */ bool read_chunk(Buffer& read_chunk) const; - void write(const void*, std::size_t nb) const; + /** + * Write data to this handle. + * @param data Pointer to binary data. + * @param nb Data size. + */ + void write(const void* data, std::size_t nb) const; + /** + * Write data to this handle. + * @param buffer Binary data to write. + */ void write(const Buffer& buffer) const; + /** + * Write data to this handle. + * @param src Binary data to write. + */ template <typename CharT> void write(const std::basic_string<CharT>& src) const { write(src.c_str(), src.size() * sizeof(CharT)); |