REDI_BASIC_RPSTREAM(3)

πŸ“¦
version 1.0.4 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– 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 just int, 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 process
  • basic_rpstream (const std::string &file, const argv_type &argv, pmode mode=pstdout|pstdin) β€” constructor that initialises the stream by starting a process
  • basic_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 process
  • void open (const std::string &file, const argv_type &argv, pmode mode=pstdout|pstdin) β€” start a process
  • istream_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 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 🧚

  • 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 buffers
  • pbsz β€” 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 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_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 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_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 program
  • mode β€” 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 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_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 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>> 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