Btk
Btk::PStream Class Reference

Pipe stream to or from a process. More...

#include <popen.hpp>

Public Member Functions

 PStream (const char *cmd, const char *modes)
 Construct a new PStream object. More...
 
 PStream (const PStream &)=delete
 
 PStream (PStream &&)
 
void close ()
 Close the stream. More...
 
void open (const char *cmd, const char *modes)
 Open a new stream. More...
 
void open (std::string_view cmd, std::string_view modes)
 
bool try_open (const char *cmd, const char *modes)
 Trt open a new stream. More...
 
bool try_open (std::string_view cmd, std::string_view modes)
 
bool bad ()
 Check the stream status. More...
 
bool eof ()
 Check the stream at eof. More...
 
PStreamoperator= (PStream &&)
 Assign from a lval stream. More...
 
FILE * operator* () const noexcept
 
 operator bool ()
 

Friends

PStreamoperator>> (PStream &, std::string &)
 Read a line to string. More...
 
PStreamoperator<< (PStream &, std::string_view)
 Write String to stream It w. More...
 

Detailed Description

Pipe stream to or from a process.

Constructor & Destructor Documentation

◆ PStream()

Btk::PStream::PStream ( const char *  cmd,
const char *  modes 
)
inline

Construct a new PStream object.

Parameters
cmdThe commond line
modesThe pipe mode

Member Function Documentation

◆ bad()

bool Btk::PStream::bad ( )
inline

Check the stream status.

Returns
true Is bad
false Is good

◆ close()

void Btk::PStream::close ( )
inline

Close the stream.

◆ eof()

bool Btk::PStream::eof ( )
inline

Check the stream at eof.

Returns
true Is eof
false Is not at eof

◆ open()

void Btk::PStream::open ( const char *  cmd,
const char *  modes 
)
inline

Open a new stream.

Parameters
cmdThe command line
modesThe pipe mode

◆ operator=()

PStream & Btk::PStream::operator= ( PStream &&  pstream)
inline

Assign from a lval stream.

Returns
PStream& The stream ref

◆ try_open()

bool Btk::PStream::try_open ( const char *  cmd,
const char *  modes 
)
inline

Trt open a new stream.

Parameters
cmdThe command line
modesThe pipe mode
Returns
true Succeed
false Failed

Friends And Related Function Documentation

◆ operator<<

PStream& operator<< ( PStream stream,
std::string_view  data 
)
friend

Write String to stream It w.

Returns
PStream& The stream ref

◆ operator>>

PStream& operator>> ( PStream stream,
std::string &  str 
)
friend

Read a line to string.

Parameters
streamThe stream
strThe string ref
Returns
PStream& The stream ref

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