REDI_BASIC_PSTREAM(3)

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

πŸŽ€ 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, an int, 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_type
  • typedef std::basic_ios< CharT, Traits > ios_type
  • enum { 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, not cmd. 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