REDI_BASIC_OPSTREAM(3)

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

🌸 redi::basic_opstream 🌸

okay bestie, welcome to a page straight outta the Library Functions Manual β€” this is the class template for Output PStreams and she is serving. grab a boba, we're going in πŸ’–


✨ NAME ✨

redi::basic_opstream β€” Class template for Output PStreams 🫢


✨ SYNOPSIS ✨

#include <pstream.h>

Inherits std::basic_ostream< CharT, std::char_traits< CharT > >, redi::pstream_common< CharT, Traits >, and redi::pstreams. she's got so many ancestors, main character energy fr fr πŸ‘‘

πŸ’œ Public Types πŸ’œ

  • typedef pbase_type::pmode pmode β€” the type you use to say how to connect to the process πŸ”Œ
  • typedef pbase_type::argv_type argv_type β€” the type that holds all the arguments for a command πŸ“
  • typedef int fd_type β€” the type used for file descriptors, it's just int and that's iconic πŸ’…

πŸ’œ Public Member Functions πŸ’œ

  • basic_opstream () β€” default constructor, makes an uninitialised stream (so, a little empty shell, no thoughts, head empty 🐚)
  • basic_opstream (const std::string &cmd, pmode mode=pstdin) β€” constructor that initialises the stream by starting a process πŸš€
  • basic_opstream (const std::string &file, const argv_type &argv, pmode mode=pstdin) β€” constructor that initialises the stream by starting a process πŸš€
  • basic_opstream (const argv_type &argv, pmode mode=pstdin) β€” constructor that initialises the stream by starting a process πŸš€
  • ~basic_opstream () β€” destructor, the farewell tour πŸ’€
  • void open (const std::string &cmd, pmode mode=pstdin) β€” start a process 🏁
  • void open (const std::string &file, const argv_type &argv, pmode mode=pstdin) β€” start a process 🏁
  • int close () β€” (the docs just drop the name and ghost us, no description given, she's mysterious like that πŸ™ˆ)
  • bool is_open () const β€” reports whether the stream's buffer has been initialised πŸ‘€
  • const std::string & command () const β€” returns the command used to initialise the stream πŸ“£
  • streambuf_type * rdbuf () const β€” returns 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 πŸ“œ

(noting for the record bestie: these are not member symbols 🫢)

  • template<typename C, typename T> std::basic_ostream< C, T > & peof (std::basic_ostream< C, T > &s) β€” manipulator to close the pipe connected to the process' stdin πŸ”š

πŸ’– Detailed Description πŸ’–

template<typename CharT, typename Traits = std::char_traits<CharT>>
class redi::basic_opstream< CharT, Traits >

"Class template for Output PStreams.

Writing to an open opstream writes to the standard input of the command; the command's standard output is the same as that of the process that created the pstream object, unless altered by the command itself."

so like. you write into it, and it lands on the command's stdin. the command's stdout? that's just whatever the process that made the pstream already had, unless the command itself switched it up. no cap πŸ’―


πŸ’– Member Enumeration Documentation πŸ’–

anonymous enum [protected], [inherited]

Enumerator πŸ‘‘

  • bufsz β€” Size of pstreambuf buffers πŸ“¦
  • pbsz β€” Number of putback characters kept ↩️

πŸ’– Constructor & Destructor Documentation πŸ’–

πŸ’— basic_opstream (const std::string & cmd, pmode mode = pstdin) [inline], [explicit]

template<typename CharT, typename Traits = std::char_traits<CharT>>
redi::basic_opstream< CharT, Traits >::basic_opstream (const std::string & cmd, pmode mode = pstdin)

Constructor that initialises the stream by starting a process. πŸš€ she initialises the stream buffer by calling do_open() with the args you handed her.

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)

πŸ’— basic_opstream (const std::string & file, const argv_type & argv, pmode mode = pstdin) [inline]

template<typename CharT, typename Traits = std::char_traits<CharT>>
redi::basic_opstream< CharT, Traits >::basic_opstream (const std::string & file, const argv_type & argv, pmode mode = pstdin)

Constructor that initialises the stream by starting a process. πŸš€ same vibe: calls do_open() with the supplied arguments.

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)

πŸ’— basic_opstream (const argv_type & argv, pmode mode = pstdin) [inline], [explicit]

template<typename CharT, typename Traits = std::char_traits<CharT>>
redi::basic_opstream< CharT, Traits >::basic_opstream (const argv_type & argv, pmode mode = pstdin)

Constructor that initialises the stream by starting a process. πŸš€ this one calls do_open(argv[0],argv,mode|pstdin) β€” yes, exactly like that, argv[0] and everything, periodt.

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)

πŸ’— ~basic_opstream () [inline]

template<typename CharT, typename Traits = std::char_traits<CharT>>
redi::basic_opstream< CharT, Traits >::~basic_opstream ()

Destructor. Closes the stream and waits for the child to exit. 😭 the emotional goodbye β€” she closes up and waits for the child, very responsible queen πŸ’…


πŸ’– Member Function Documentation πŸ’–

πŸ’— close () [inline], [inherited]

template<typename C, typename T> int redi::pstream_common< C, T >::close ()

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_.

πŸ’— command () const [inline], [inherited]

template<typename C, typename T> const std::string & redi::pstream_common< C, T >::command () const

Return the command used to initialise the stream. πŸ“£

Returns

  • a string containing the command used to initialise the stream 🫢

References command_.

πŸ’— do_open (const std::string & cmd, pmode mode) [inline], [protected], [inherited]

template<typename C, typename T> void redi::pstream_common< C, T >::do_open (const std::string & cmd, pmode mode)

Start a process. Calls rdbuf()->open( cmd , 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(). (she's everywhere, the social butterfly of this library πŸ¦‹)

πŸ’— do_open (const std::string & file, const argv_type & argv, pmode mode) [inline], [protected], [inherited]

template<typename C, typename T> void redi::pstream_common< C, T >::do_open (const std::string & file, const argv_type & argv, pmode mode)

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_.

πŸ’— is_open () const [inline], [inherited]

template<typename C, typename T> bool redi::pstream_common< C, T >::is_open () const

Report whether the stream's buffer has been initialised. πŸ‘€

Returns

  • rdbuf()->is_open()

See also

  • basic_pstreambuf::is_open()

References buf_.

πŸ’— open (const std::string & cmd, pmode mode = pstdin) [inline]

template<typename CharT, typename Traits = std::char_traits<CharT>> void
redi::basic_opstream< CharT, Traits >::open (const std::string & cmd, pmode mode = pstdin)

Start a process. Calls do_open( cmd , mode|pstdin ). 🏁 notice the |pstdin bestie, don't lose it ✨

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)

πŸ’— open (const std::string & file, const argv_type & argv, pmode mode = pstdin) [inline]

template<typename CharT, typename Traits = std::char_traits<CharT>> void
redi::basic_opstream< CharT, Traits >::open (const std::string & file, const argv_type & argv, pmode mode = pstdin)

Start a process. Calls do_open( file , argv , mode|pstdin ). 🏁 again with the |pstdin β€” it's part of the fit, it stays πŸ’…

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)

πŸ’— rdbuf () const [inline], [inherited]

template<typename C, typename T> pstream_common< C, T >::streambuf_type *
redi::pstream_common< C, T >::rdbuf () const

Return a pointer to the stream buffer. 🎯

Returns

  • a pointer to the private stream buffer member πŸ”

References buf_.


template<typename C, typename T> std::basic_ostream< C, T > & peof
(std::basic_ostream< C, T > & s)

Manipulator to close the pipe connected to the process' stdin. When inserted into an output pstream the manipulator calls basic_pstreambuf<C,T>::peof() to close the output pipe, causing the child process to receive the end-of-file indicator on subsequent reads from its stdin stream. πŸ”šβœ¨

Parameters

  • s β€” An output PStream class 🫢

Returns

  • The stream object the manipulator was invoked on ↩️

See also

  • basic_pstreambuf<C,T>::peof() basic_pstream basic_rpstream

πŸ’– Author πŸ’–

Generated automatically by Doxygen for PStreams from the source code. πŸ€– (not a human author bestie, it's the robot doing the typing ✨)


and that's the whole page, bestie!! 🌈 this came out of PStreams, living in section 3 of the manual (redi::basi...T, Traits >(3), the header and footer doing their little matching fit πŸ‘‘). every single flag, type, default, param and reference is still here, i just gave it a makeover. mwah πŸ’‹

πŸ“¦ where this page comes from