9 #ifndef CPPCOMMON_SYSTEM_PIPE_H
10 #define CPPCOMMON_SYSTEM_PIPE_H
42 void*
reader() const noexcept;
44 void*
writer() const noexcept;
62 size_t Read(
void* buffer,
size_t size) override;
77 size_t Write(const
void* buffer,
size_t size) override;
96 Impl& impl() noexcept {
return reinterpret_cast<Impl&
>(_storage); }
97 const Impl& impl() const noexcept {
return reinterpret_cast<Impl const&
>(_storage); }
99 static const size_t StorageSize = 16;
100 #if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
101 static const size_t StorageAlign = 4;
103 static const size_t StorageAlign = 8;
105 alignas(StorageAlign) std::byte _storage[StorageSize];
bool IsPipeOpened() const noexcept
Is pipe opened for reading or writing?
Pipe & operator=(Pipe &&pipe)=delete
Pipe(const Pipe &)=delete
void CloseWrite()
Close the write pipe endpoint.
virtual size_t Write(const void *buffer, size_t size)=0
Write a byte buffer base method.
size_t Read(void *buffer, size_t size) override
Read a bytes buffer from the pipe.
void Close()
Close all pipe endpoints.
Pipe & operator=(const Pipe &)=delete
bool IsPipeWriteOpened() const noexcept
Is pipe opened for writing?
std::vector< std::string > ReadAllLines()
Read all text lines.
bool IsPipeReadOpened() const noexcept
Is pipe opened for reading?
void * reader() const noexcept
Get the native read endpoint handler.
std::vector< uint8_t > ReadAllBytes()
Read all bytes.
void * writer() const noexcept
Get the native write endpoint handler.
void CloseRead()
Close the read pipe endpoint.
std::string ReadAllText()
Read all text.
void swap(Pipe &pipe) noexcept
Swap two instances.
C++ Common project definitions.
Pipe inline implementation.
Reader interface definition.
Writer interface definition.