REDI_BASIC_PSTREAM(3)
π NAME π
redi::basic_pstream β Class template for Bidirectional PStreams π«
okay so welcome to section 3 of the Library Functions Manual, bestie, and lemme tell you about redi::basic_pstream, which is lowkey the main character of the whole bidirectional-pstream situation. π¦
β¨ SYNOPSIS β¨
#include <pstream.h>
so this class is out here with a whole royal family tree, no cap β it inherits from std::basic_iostream< CharT, std::char_traits< CharT > >, redi::pstream_common< CharT, Traits >, and redi::pstreams. three parents, iconic behavior, we love to see it. π
πΈ Public Types πΈ
typedef pbase_type::pmode pmodeβ Type used to specify how to connect to the process. this is the little tag that tells everyone what vibe the pipe has.typedef pbase_type::argv_type argv_typeβ Type used to hold the arguments for a command. the lil container that carries your args around.typedef int fd_typeβ Type used for file descriptors. yes bestie, anint, it's giving classic.
π«Ά Public Member Functions π«Ά
basic_pstream ()β Default constructor, creates an uninitialised stream. it exists, it's empty, it's waiting for its moment.basic_pstream (const std::string &cmd, pmode mode=pstdout|pstdin)β Constructor that initialises the stream by starting a process. πbasic_pstream (const std::string &file, const argv_type &argv, pmode mode=pstdout|pstdin)β Constructor that initialises the stream by starting a process.basic_pstream (const argv_type &argv, pmode mode=pstdout|pstdin)β Constructor that initialises the stream by starting a process.~basic_pstream ()β Destructor. it's the goodbye era, sadly.void open (const std::string &cmd, pmode mode=pstdout|pstdin)β Start a process.void open (const std::string &file, const argv_type &argv, pmode mode=pstdout|pstdin)β Start a process.basic_pstream & out ()β Set streambuf to read from process' stdout.basic_pstream & err ()β Set streambuf to read from process' stderr.int close ()β literally just vibes until you read the docs below, keep scrolling.bool is_open () constβ Report whether the stream's buffer has been initialised.const std::string & command () constβ Return the command used to initialise the stream.streambuf_type * rdbuf () constβ Return a pointer to the stream buffer.
π Static Public Attributes π
static const pmode pstdin = std::ios_base::outβ Write to stdin.static const pmode pstdout = std::ios_base::inβ Read from stdout.static const pmode pstderr = std::ios_base::appβ Read from stderr.static const pmode newpg = std::ios_base::truncβ Create a new process group for the child process.
π§ Protected Types π§
typedef basic_pstreambuf< CharT, Traits > streambuf_typetypedef std::basic_ios< CharT, Traits > ios_typeenum { bufsz = 32, pbsz = 2 }
π Protected Member Functions π
void do_open (const std::string &cmd, pmode mode)β Start a process.void do_open (const std::string &file, const argv_type &argv, pmode mode)β Start a process.
π Protected Attributes π
std::string command_β The command used to start the process.
π Detailed Description π
template<typename CharT, typename Traits = std::char_traits<CharT>>
class redi::basic_pstream< CharT, Traits >
Class template for Bidirectional PStreams. π
so here's the tea, bestie. Writing to a pstream opened with pmode pstdin writes to the standard input of the command. Reading from a pstream opened with pmode pstdout and/or pstderr reads the command's standard output and/or standard error. And listen β any of the process' stdin, stdout or stderr that is not connected to the pstream (as specified by the pmode) will be the same as the process that created the pstream object, unless altered by the command itself. so the unconnected bits just inherit the parent's vibe, periodt. β¨
π Member Enumeration Documentation π
anonymous enum [protected], [inherited]
the enumerators, bestie:
bufszβ Size of pstreambuf buffers.pbszβ Number of putback characters kept.
π Constructor & Destructor Documentation π
template<typename CharT, typename Traits = std::char_traits<CharT>>
redi::basic_pstream< CharT, Traits >::basic_pstream (const std::string &cmd,
pmode mode = pstdout|pstdin) [inline], [explicit]
Constructor that initialises the stream by starting a process. it initialises the stream buffer by calling do_open() with the supplied arguments. πΈ
Parameters
- cmd β a string containing a shell command.
- mode β the I/O mode to use when opening the pipe.
See also do_open(const std::string&, pmode)
template<typename CharT, typename Traits = std::char_traits<CharT>>
redi::basic_pstream< CharT, Traits >::basic_pstream (const std::string &file,
const argv_type &argv, pmode mode = pstdout|pstdin) [inline]
Constructor that initialises the stream by starting a process. initialises the stream buffer by calling do_open() with the supplied arguments. same energy, different args. π«Ά
Parameters
- file β a string containing the pathname of a program to execute.
- argv β a vector of argument strings passed to the new program.
- mode β the I/O mode to use when opening the pipe.
See also do_open(const std::string&, const argv_type&, pmode)
template<typename CharT, typename Traits = std::char_traits<CharT>>
redi::basic_pstream< CharT, Traits >::basic_pstream (const argv_type &argv,
pmode mode = pstdout|pstdin) [inline], [explicit]
Constructor that initialises the stream by starting a process. initialises the stream buffer by calling do_open(argv[0],argv,mode) β yes, argv[0] is out here doing the heavy lifting. π
Parameters
- argv β a vector of argument strings passed to the new program.
- mode β the I/O mode to use when opening the pipe.
See also do_open(const std::string&, const argv_type&, pmode)
template<typename CharT, typename Traits = std::char_traits<CharT>>
redi::basic_pstream< CharT, Traits >::~basic_pstream () [inline]
Destructor. Closes the stream and waits for the child to exit. it's not ghosting, it's actually waiting for the child process to wrap up. π
π Member Function Documentation π
template<typename C, typename T> int redi::pstream_common< C, T >::close () [inline], [inherited]
Close the pipe, returning the program's exit status, as pclose(3) does. π
Calls rdbuf->close() and sets failbit on error. Returns process's exit status, as pclose(3) does.
References buf_.
template<typename C, typename T> const std::string & redi::pstream_common< C, T >::command () const [inline], [inherited]
Return the command used to initialise the stream.
Returns a string containing the command used to initialise the stream.
References command_.
template<typename C, typename T> void redi::pstream_common< C, T >::do_open (const std::string & cmd, pmode mode) [inline], [protected], [inherited]
Start a process. Calls rdbuf()->open( command , mode ) and sets failbit on error. π₯
Parameters
- cmd β a string containing a shell command.
- mode β the I/O mode to use when opening the pipe.
See also basic_pstreambuf::open(const std::string&, pmode)
References buf_, and command_.
Referenced by redi::basic_ipstream< char >::open(), redi::basic_ipstream< char >::open(), redi::basic_opstream< char >::open(), redi::basic_opstream< char >::open(), redi::basic_pstream< char >::open(), redi::basic_pstream< char >::open(), redi::basic_rpstream< char >::open(), redi::basic_rpstream< char >::open(), pstream_common(), and pstream_common().
template<typename C, typename T> void redi::pstream_common< C, T >::do_open (const std::string & file, const argv_type & argv, pmode mode) [inline], [protected], [inherited]
Start a process. Calls rdbuf()->open( file, argv, mode ) and sets failbit on error.
Parameters
- file β a string containing the pathname of a program to execute.
- argv β a vector of argument strings passed to the new program.
- mode β the I/O mode to use when opening the pipe.
See also basic_pstreambuf::open(const std::string&, const argv_type&, pmode)
References buf_, and command_.
template<typename CharT, typename Traits = std::char_traits<CharT>>
basic_pstream & redi::basic_pstream< CharT, Traits >::err () [inline]
Set streambuf to read from process' stderr. π
Returns *this
template<typename C, typename T> bool redi::pstream_common< C, T >::is_open () const [inline], [inherited]
Report whether the stream's buffer has been initialised.
Returns rdbuf()->is_open().
See also basic_pstreambuf::is_open()
References buf_.
template<typename CharT, typename Traits = std::char_traits<CharT>> void
redi::basic_pstream< CharT, Traits >::open (const std::string & cmd,
pmode mode = pstdout|pstdin) [inline]
Start a process. Calls do_open( cnd , mode ). π¦
bestie, that's literally what the source says βcnd, notcmd. i am not fixing it, i am simply reporting the lore.
Parameters
- cmd β a string containing a shell command.
- mode β the I/O mode to use when opening the pipe.
See also do_open(const std::string&, pmode)
template<typename CharT, typename Traits = std::char_traits<CharT>> void
redi::basic_pstream< CharT, Traits >::open (const std::string & file,
const argv_type & argv, pmode mode = pstdout|pstdin) [inline]
Start a process. Calls do_open( file , argv , mode ).
Parameters
- file β a string containing the pathname of a program to execute.
- argv β a vector of argument strings passed to the new program.
- mode β the I/O mode to use when opening the pipe.
See also do_open(const std::string&, const argv_type&, pmode)
template<typename CharT, typename Traits = std::char_traits<CharT>>
basic_pstream & redi::basic_pstream< CharT, Traits >::out () [inline]
Set streambuf to read from process' stdout. π
Returns *this
template<typename C, typename T> pstream_common< C, T >::streambuf_type *
redi::pstream_common< C, T >::rdbuf () const [inline], [inherited]
Return a pointer to the stream buffer.
Returns a pointer to the private stream buffer member.
References buf_.
πΈ Author πΈ
Generated automatically by Doxygen for PStreams from the source code. (not me, i could never π )
and that's the whole page, bestie!! π«Ά this one came from PStreams and it's the redi::basic_pstream< CharT, Traits > page from section 3 β go forth and pipe bidirectional-ly, you absolute icon. πβ¨ππ¦
π¦ where this page comes from
- ubuntu resolute: libpstreams-dev 1.0.4-2 Β· BSL-1.0
- ubuntu stonking: libpstreams-dev 1.0.4-2 Β· BSL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms