CppCommon  1.0.4.1
C++ Common Library
Public Member Functions | Friends | List of all members
CppCommon::Pipe Class Reference

Pipe. More...

#include <pipe.h>

Inheritance diagram for CppCommon::Pipe:
CppCommon::Reader CppCommon::Writer

Public Member Functions

 Pipe ()
 
 Pipe (const Pipe &)=delete
 
 Pipe (Pipe &&pipe)=delete
 
virtual ~Pipe ()
 
Pipeoperator= (const Pipe &)=delete
 
Pipeoperator= (Pipe &&pipe)=delete
 
void * reader () const noexcept
 Get the native read endpoint handler. More...
 
void * writer () const noexcept
 Get the native write endpoint handler. More...
 
bool IsPipeOpened () const noexcept
 Is pipe opened for reading or writing? More...
 
bool IsPipeReadOpened () const noexcept
 Is pipe opened for reading? More...
 
bool IsPipeWriteOpened () const noexcept
 Is pipe opened for writing? More...
 
size_t Read (void *buffer, size_t size) override
 Read a bytes buffer from the pipe. More...
 
size_t Write (const void *buffer, size_t size) override
 Write a byte buffer into the pipe. More...
 
void CloseRead ()
 Close the read pipe endpoint. More...
 
void CloseWrite ()
 Close the write pipe endpoint. More...
 
void Close ()
 Close all pipe endpoints. More...
 
void swap (Pipe &pipe) noexcept
 Swap two instances. More...
 
std::vector< uint8_t > ReadAllBytes ()
 Read all bytes. More...
 
std::string ReadAllText ()
 Read all text. More...
 
std::vector< std::string > ReadAllLines ()
 Read all text lines. More...
 
virtual size_t Write (const void *buffer, size_t size)=0
 Write a byte buffer base method. More...
 
size_t Write (const std::string &text)
 Write a text string. More...
 
size_t Write (const std::vector< std::string > &lines)
 Write text lines. More...
 
- Public Member Functions inherited from CppCommon::Reader
 Reader () noexcept=default
 
 Reader (const Reader &) noexcept=default
 
 Reader (Reader &&) noexcept=default
 
virtual ~Reader () noexcept=default
 
Readeroperator= (const Reader &) noexcept=default
 
Readeroperator= (Reader &&) noexcept=default
 
std::vector< uint8_t > ReadAllBytes ()
 Read all bytes. More...
 
std::string ReadAllText ()
 Read all text. More...
 
std::vector< std::string > ReadAllLines ()
 Read all text lines. More...
 
- Public Member Functions inherited from CppCommon::Writer
 Writer () noexcept=default
 
 Writer (const Writer &) noexcept=default
 
 Writer (Writer &&) noexcept=default
 
virtual ~Writer () noexcept=default
 
Writeroperator= (const Writer &) noexcept=default
 
Writeroperator= (Writer &&) noexcept=default
 
size_t Write (const std::string &text)
 Write a text string. More...
 
size_t Write (const std::vector< std::string > &lines)
 Write text lines. More...
 
virtual void Flush ()
 Flush the writer. More...
 

Friends

void swap (Pipe &pipe1, Pipe &pipe2) noexcept
 

Detailed Description

Pipe.

A pipe is a section of shared memory that processes use for communication. The process that creates a pipe is the pipe server. A process that connects to a pipe is a pipe client. One process writes information to the pipe, then the other process reads the information from the pipe. This overview describes how to create, manage, and use pipes.

Not thread-safe.

Examples
system_pipe.cpp, and system_process_pipes.cpp.

Definition at line 30 of file pipe.h.

Constructor & Destructor Documentation

◆ Pipe() [1/3]

CppCommon::Pipe::Pipe ( )

Definition at line 183 of file pipe.cpp.

◆ Pipe() [2/3]

CppCommon::Pipe::Pipe ( const Pipe )
delete

◆ Pipe() [3/3]

CppCommon::Pipe::Pipe ( Pipe &&  pipe)
delete

◆ ~Pipe()

CppCommon::Pipe::~Pipe ( )
virtual

Definition at line 194 of file pipe.cpp.

Member Function Documentation

◆ Close()

void CppCommon::Pipe::Close ( )

Close all pipe endpoints.

Definition at line 212 of file pipe.cpp.

◆ CloseRead()

void CppCommon::Pipe::CloseRead ( )

Close the read pipe endpoint.

Definition at line 210 of file pipe.cpp.

◆ CloseWrite()

void CppCommon::Pipe::CloseWrite ( )

Close the write pipe endpoint.

Definition at line 211 of file pipe.cpp.

◆ IsPipeOpened()

bool CppCommon::Pipe::IsPipeOpened ( ) const
noexcept

Is pipe opened for reading or writing?

Definition at line 203 of file pipe.cpp.

◆ IsPipeReadOpened()

bool CppCommon::Pipe::IsPipeReadOpened ( ) const
noexcept

Is pipe opened for reading?

Definition at line 204 of file pipe.cpp.

◆ IsPipeWriteOpened()

bool CppCommon::Pipe::IsPipeWriteOpened ( ) const
noexcept

Is pipe opened for writing?

Definition at line 205 of file pipe.cpp.

◆ operator=() [1/2]

Pipe& CppCommon::Pipe::operator= ( const Pipe )
delete

◆ operator=() [2/2]

Pipe& CppCommon::Pipe::operator= ( Pipe &&  pipe)
delete

◆ Read()

size_t CppCommon::Pipe::Read ( void *  buffer,
size_t  size 
)
overridevirtual

Read a bytes buffer from the pipe.

If the pipe is not opened for reading the method will raise a system exception!

Parameters
buffer- Buffer to read
size- Buffer size
Returns
Count of read bytes

Implements CppCommon::Reader.

Examples
system_pipe.cpp.

Definition at line 207 of file pipe.cpp.

◆ ReadAllBytes()

std::vector< uint8_t > CppCommon::Reader::ReadAllBytes

Read all bytes.

Returns
Bytes buffer

Definition at line 46 of file reader.cpp.

◆ ReadAllLines()

std::vector< std::string > CppCommon::Reader::ReadAllLines

Read all text lines.

Returns
Text lines

Definition at line 56 of file reader.cpp.

◆ ReadAllText()

std::string CppCommon::Reader::ReadAllText

Read all text.

Returns
Text string
Examples
system_process_pipes.cpp.

Definition at line 51 of file reader.cpp.

◆ reader()

void * CppCommon::Pipe::reader ( ) const
noexcept

Get the native read endpoint handler.

Definition at line 200 of file pipe.cpp.

◆ swap()

void CppCommon::Pipe::swap ( Pipe pipe)
noexcept

Swap two instances.

Definition at line 214 of file pipe.cpp.

◆ Write() [1/4]

size_t CppCommon::Writer::Write

Write a text string.

Parameters
text- Text string
Returns
Count of written characters

Definition at line 46 of file writer.cpp.

◆ Write() [2/4]

size_t CppCommon::Writer::Write

Write text lines.

Parameters
lines- Text lines
Returns
Count of written lines

Definition at line 52 of file writer.cpp.

◆ Write() [3/4]

size_t CppCommon::Pipe::Write ( const void *  buffer,
size_t  size 
)
overridevirtual

Write a byte buffer into the pipe.

If the pipe is not opened for writing the method will raise a system exception!

Parameters
buffer- Buffer to write
size- Buffer size
Returns
Count of written bytes

Implements CppCommon::Writer.

Examples
system_pipe.cpp, and system_process_pipes.cpp.

Definition at line 208 of file pipe.cpp.

◆ Write() [4/4]

virtual size_t CppCommon::Writer::Write

Write a byte buffer base method.

Parameters
buffer- Buffer to write
size- Buffer size
Returns
Count of written bytes

◆ writer()

void * CppCommon::Pipe::writer ( ) const
noexcept

Get the native write endpoint handler.

Definition at line 201 of file pipe.cpp.

Friends And Related Function Documentation

◆ swap

void swap ( Pipe pipe1,
Pipe pipe2 
)
friend

Definition at line 11 of file pipe.inl.


The documentation for this class was generated from the following files: