REDI_BASIC_RPSTREAM(3)
π NAME π
okay so bestie, welcome to redi::basic_rpstream β the Class template for Restricted PStreams. she's the whole reason you're here, and she's iconic for it π
β¨ SYNOPSIS β¨
#include <pstream.h>
so like, before anything else, she inherits from a whole friend group of base classes, no cap:
std::basic_ostream< CharT, std::char_traits< CharT > >std::basic_istream< CharT, std::char_traits< CharT > >redi::pstream_common< CharT, Traits >redi::pstreams
πΈ Public Types πΈ
typedef pbase_type::pmode pmodeβ the type you use to say how you wanna connect to the process π«Άtypedef pbase_type::argv_type argv_typeβ the type that holds all the arguments for a command, like her little to-do list πtypedef int fd_typeβ the type used for file descriptors, literally justint, slay
π Public Member Functions π
basic_rpstream ()β default constructor, makes an uninitialised stream (she's not ready yet, give her a sec π)basic_rpstream (const std::string &cmd, pmode mode=pstdout|pstdin)β constructor that initialises the stream by starting a processbasic_rpstream (const std::string &file, const argv_type &argv, pmode mode=pstdout|pstdin)β constructor that initialises the stream by starting a processbasic_rpstream (const argv_type &argv, pmode mode=pstdout|pstdin)β constructor that initialises the stream by starting a process~basic_rpstream ()β destructor, she's leaving the group chat πvoid open (const std::string &cmd, pmode mode=pstdout|pstdin)β start a processvoid open (const std::string &file, const argv_type &argv, pmode mode=pstdout|pstdin)β start a processistream_type & out ()β get a reference to the istream that reads the process' stdout πistream_type & err ()β get a reference to the istream that reads the process' stderr π
β Static Public Attributes β
static const pmode pstdin = std::ios_base::outβ write to stdinstatic const pmode pstdout = std::ios_base::inβ read from stdoutstatic const pmode pstderr = std::ios_base::appβ read from stderrstatic const pmode newpg = std::ios_base::truncβ create a new process group for the child process
π§ Protected Types π§
enum { bufsz = 32, pbsz = 2 }
π Detailed Description π
template<typename CharT, typename Traits = std::char_traits<CharT>>
class redi::basic_rpstream< CharT, Traits >
Class template for Restricted PStreams.
ok so here's the tea βοΈ β writing to an rpstream that was opened with pmode pstdin writes to the standard input of the command. periodt.
but listen: it is not possible to read directly from an rpstream object. to use an rpstream as an istream you must call either basic_rpstream::out() or basic_rpstream::err(). and why, you ask? because the class is literally protecting you from yourself β it's to prevent accidental reads from the wrong input source. she's a bodyguard, honestly π«Ά
if the rpstream was not opened with pmode pstderr then the class cannot read the process' stderr, and basic_rpstream::err() will return an istream that reads from the process' stdout. and vice versa, bestie, vice versa.
reading from an rpstream opened with pmode pstdout and/or pstderr reads the command's standard output and/or standard error. 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. iykyk.
π Member Enumeration Documentation π
anonymous enum [protected], [inherited]
enumerators, bestie:
bufszβ size of pstreambuf bufferspbszβ number of putback characters kept
π Constructor & Destructor Documentation π
template<typename CharT, typename Traits = std::char_traits<CharT>> redi::basic_rpstream< CharT, Traits >::basic_rpstream (const std::string & cmd, pmode mode = pstdout|pstdin) [inline], [explicit]
constructor that initialises the stream by starting a process β¨
she initialises the stream buffer by calling do_open() with the supplied arguments. so organised.
Parameters
cmdβ a string containing a shell commandmodeβ 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_rpstream< CharT, Traits >::basic_rpstream (const std::string & file, const argv_type & argv, pmode mode = pstdout|pstdin) [inline]
constructor that initialises the stream by starting a process β¨
she initialises the stream buffer by calling do_open() with the supplied arguments. again. consistent queen.
Parameters
fileβ a string containing the pathname of a program to executeargvβ a vector of argument strings passed to the new programmodeβ 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_rpstream< CharT, Traits >::basic_rpstream (const argv_type & argv, pmode mode = pstdout|pstdin) [inline], [explicit]
constructor that initialises the stream by starting a process β¨
she initialises the stream buffer by calling do_open(argv[0],argv,mode). yes, argv[0], that's the whole trick π¦
Parameters
argvβ a vector of argument strings passed to the new programmodeβ the I/O mode to use when opening the pipe
See also
do_open(const std::string&, const argv_type&, pmode)
π Member Function Documentation π
template<typename CharT, typename Traits = std::char_traits<CharT>> istream_type & redi::basic_rpstream< CharT, Traits >::err () [inline]
obtain a reference to the istream that reads the process' stderr π
Returns
*this
template<typename CharT, typename Traits = std::char_traits<CharT>> void redi::basic_rpstream< CharT, Traits >::open (const std::string & cmd, pmode mode = pstdout|pstdin) [inline]
start a process. calls do_open( cmd , mode ). π
Parameters
cmdβ a string containing a shell commandmodeβ 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_rpstream< 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 executeargvβ a vector of argument strings passed to the new programmodeβ 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>> istream_type & redi::basic_rpstream< CharT, Traits >::out () [inline]
obtain a reference to the istream that reads the process' stdout π
Returns
*this
π«Ά Author π«Ά
generated automatically by Doxygen for PStreams from the source code. she didn't write herself, she was born that way π
and that's the whole page, bestie!! this was redi::basic_rpstream(3) from PStreams β the manual name is right there in the title so you always know which page you're on, and the footer was just the same title with PStreams as the source and no date attached (doxygen left the date blank, so we move π). mwah, go read the source, ily πβ¨
π¦ 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