.TH "redi::basic_opstream< CharT, Traits >" 3 "Sat Jul 21 2018" "PStreams" \" -*- nroff -*- .ad l .nh .SH NAME redi::basic_opstream< CharT, Traits > \- Class template for Output PStreams\&. .SH SYNOPSIS .br .PP .PP \fC#include \fP .PP Inherits basic_ostream< CharT, Traits >, \fBredi::pstream_common< CharT, Traits >\fP, and \fBredi::pstreams\fP\&. .SS "Public Types" .in +1c .ti -1c .RI "typedef pbase_type::pmode \fBpmode\fP" .br .RI "Type used to specify how to connect to the process\&. " .ti -1c .RI "typedef pbase_type::argv_type \fBargv_type\fP" .br .RI "Type used to hold the arguments for a command\&. " .ti -1c .RI "typedef int \fBfd_type\fP" .br .RI "Type used for file descriptors\&. " .ti -1c .RI "typedef int \fBfd_type\fP" .br .RI "Type used for file descriptors\&. " .in -1c .SS "Public Member Functions" .in +1c .ti -1c .RI "\fBbasic_opstream\fP ()" .br .RI "Default constructor, creates an uninitialised stream\&. " .ti -1c .RI "\fBbasic_opstream\fP (const std::string &cmd, \fBpmode\fP mode=\fBpstdin\fP)" .br .RI "Constructor that initialises the stream by starting a process\&. " .ti -1c .RI "\fBbasic_opstream\fP (const std::string &file, const \fBargv_type\fP &argv, \fBpmode\fP mode=\fBpstdin\fP)" .br .RI "Constructor that initialises the stream by starting a process\&. " .ti -1c .RI "\fBbasic_opstream\fP (const \fBargv_type\fP &argv, \fBpmode\fP mode=\fBpstdin\fP)" .br .RI "Constructor that initialises the stream by starting a process\&. " .ti -1c .RI "\fB~basic_opstream\fP ()" .br .RI "Destructor\&. " .ti -1c .RI "void \fBopen\fP (const std::string &cmd, \fBpmode\fP mode=\fBpstdin\fP)" .br .RI "Start a process\&. " .ti -1c .RI "void \fBopen\fP (const std::string &file, const \fBargv_type\fP &argv, \fBpmode\fP mode=\fBpstdin\fP)" .br .RI "Start a process\&. " .ti -1c .RI "void \fBclose\fP ()" .br .RI "Close the pipe\&. " .ti -1c .RI "bool \fBis_open\fP () const" .br .RI "Report whether the stream's buffer has been initialised\&. " .ti -1c .RI "const std::string & \fBcommand\fP () const" .br .RI "Return the command used to initialise the stream\&. " .ti -1c .RI "\fBstreambuf_type\fP * \fBrdbuf\fP () const" .br .RI "Return a pointer to the stream buffer\&. " .in -1c .SS "Static Public Attributes" .in +1c .ti -1c .RI "static const \fBpmode\fP \fBpstdin\fP = std::ios_base::out" .br .RI "Write to stdin\&. " .ti -1c .RI "static const \fBpmode\fP \fBpstdout\fP = std::ios_base::in" .br .RI "Read from stdout\&. " .ti -1c .RI "static const \fBpmode\fP \fBpstderr\fP = std::ios_base::app" .br .RI "Read from stderr\&. " .ti -1c .RI "static const \fBpmode\fP \fBnewpg\fP = std::ios_base::trunc" .br .RI "Create a new process group for the child process\&. " .ti -1c .RI "static const \fBpmode\fP \fBpstdin\fP = std::ios_base::out" .br .RI "Write to stdin\&. " .ti -1c .RI "static const \fBpmode\fP \fBpstdout\fP = std::ios_base::in" .br .RI "Read from stdout\&. " .ti -1c .RI "static const \fBpmode\fP \fBpstderr\fP = std::ios_base::app" .br .RI "Read from stderr\&. " .ti -1c .RI "static const \fBpmode\fP \fBnewpg\fP = std::ios_base::trunc" .br .RI "Create a new process group for the child process\&. " .in -1c .SS "Protected Types" .in +1c .ti -1c .RI "typedef \fBbasic_pstreambuf\fP< CharT, Traits > \fBstreambuf_type\fP" .br .ti -1c .RI "enum { \fBbufsz\fP = 32 }" .br .ti -1c .RI "enum { \fBpbsz\fP = 2 }" .br .ti -1c .RI "enum { \fBbufsz\fP = 32 }" .br .ti -1c .RI "enum { \fBpbsz\fP = 2 }" .br .in -1c .SS "Protected Member Functions" .in +1c .ti -1c .RI "void \fBdo_open\fP (const std::string &cmd, \fBpmode\fP mode)" .br .RI "Start a process\&. " .ti -1c .RI "void \fBdo_open\fP (const std::string &file, const \fBargv_type\fP &argv, \fBpmode\fP mode)" .br .RI "Start a process\&. " .in -1c .SS "Protected Attributes" .in +1c .ti -1c .RI "std::string \fBcommand_\fP" .br .RI "The command used to start the process\&. " .ti -1c .RI "\fBstreambuf_type\fP \fBbuf_\fP" .br .RI "The stream buffer\&. " .in -1c .SS "Related Functions" (Note that these are not member functions\&.) .in +1c .ti -1c .RI "template std::basic_ostream< C, T > & \fBpeof\fP (std::basic_ostream< C, T > &s)" .br .RI "Manipulator to close the pipe connected to the process' stdin\&. " .in -1c .SH "Detailed Description" .PP .SS "template> .br 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\&. .SH "Constructor & Destructor Documentation" .PP .SS "template> \fBredi::basic_opstream\fP< CharT, Traits >::\fBbasic_opstream\fP (const std::string & cmd, \fBpmode\fP mode = \fC\fBpstdin\fP\fP)\fC [inline]\fP, \fC [explicit]\fP" .PP Constructor that initialises the stream by starting a process\&. Initialises the stream buffer by calling \fBdo_open()\fP with the supplied arguments\&. .PP \fBParameters:\fP .RS 4 \fIcmd\fP a string containing a shell command\&. .br \fImode\fP the I/O mode to use when opening the pipe\&. .RE .PP \fBSee also:\fP .RS 4 \fBdo_open(const std::string&, pmode)\fP .RE .PP .SS "template> \fBredi::basic_opstream\fP< CharT, Traits >::\fBbasic_opstream\fP (const std::string & file, const \fBargv_type\fP & argv, \fBpmode\fP mode = \fC\fBpstdin\fP\fP)\fC [inline]\fP" .PP Constructor that initialises the stream by starting a process\&. Initialises the stream buffer by calling \fBdo_open()\fP with the supplied arguments\&. .PP \fBParameters:\fP .RS 4 \fIfile\fP a string containing the pathname of a program to execute\&. .br \fIargv\fP a vector of argument strings passed to the new program\&. .br \fImode\fP the I/O mode to use when opening the pipe\&. .RE .PP \fBSee also:\fP .RS 4 \fBdo_open(const std::string&, const argv_type&, pmode)\fP .RE .PP .SS "template> \fBredi::basic_opstream\fP< CharT, Traits >::\fBbasic_opstream\fP (const \fBargv_type\fP & argv, \fBpmode\fP mode = \fC\fBpstdin\fP\fP)\fC [inline]\fP, \fC [explicit]\fP" .PP Constructor that initialises the stream by starting a process\&. Initialises the stream buffer by calling \fCdo_open\fP(argv[0],argv,mode|pstdin) .PP \fBParameters:\fP .RS 4 \fIargv\fP a vector of argument strings passed to the new program\&. .br \fImode\fP the I/O mode to use when opening the pipe\&. .RE .PP \fBSee also:\fP .RS 4 \fBdo_open(const std::string&, const argv_type&, pmode)\fP .RE .PP .PP References redi::pstreams::pstdin\&. .SS "template> \fBredi::basic_opstream\fP< CharT, Traits >::~\fBbasic_opstream\fP ()\fC [inline]\fP" .PP Destructor\&. Closes the stream and waits for the child to exit\&. .SH "Member Function Documentation" .PP .SS "template void \fBredi::pstream_common\fP< C, T >::close ()\fC [inline]\fP, \fC [inherited]\fP" .PP Close the pipe\&. Calls rdbuf->\fBclose()\fP and sets \fCfailbit\fP on error\&. .PP References redi::pstream_common< CharT, Traits >::buf_, and redi::basic_pstreambuf< CharT, Traits >::close()\&. .SS "template const std::string & \fBredi::pstream_common\fP< C, T >::command () const\fC [inline]\fP, \fC [inherited]\fP" .PP Return the command used to initialise the stream\&. .PP \fBReturns:\fP .RS 4 a string containing the command used to initialise the stream\&. .RE .PP .PP References redi::pstream_common< CharT, Traits >::command_\&. .SS "template void \fBredi::pstream_common\fP< C, T >::do_open (const std::string & cmd, \fBpmode\fP mode)\fC [inline]\fP, \fC [protected]\fP, \fC [inherited]\fP" .PP Start a process\&. Calls \fBrdbuf()\fP->open( \fIcommand\fP , \fImode\fP ) and sets \fCfailbit\fP on error\&. .PP \fBParameters:\fP .RS 4 \fIcmd\fP a string containing a shell command\&. .br \fImode\fP the I/O mode to use when opening the pipe\&. .RE .PP \fBSee also:\fP .RS 4 \fBbasic_pstreambuf::open(const std::string&, pmode)\fP .RE .PP .PP References redi::pstream_common< CharT, Traits >::buf_, redi::pstream_common< CharT, Traits >::command_, and redi::basic_pstreambuf< CharT, Traits >::open()\&. .PP Referenced by redi::pstream_common< CharT, Traits >::pstream_common()\&. .SS "template void \fBredi::pstream_common\fP< C, T >::do_open (const std::string & file, const \fBargv_type\fP & argv, \fBpmode\fP mode)\fC [inline]\fP, \fC [protected]\fP, \fC [inherited]\fP" .PP Start a process\&. Calls \fBrdbuf()\fP->open( \fIfile\fP, \fIargv\fP, \fImode\fP ) and sets \fCfailbit\fP on error\&. .PP \fBParameters:\fP .RS 4 \fIfile\fP a string containing the pathname of a program to execute\&. .br \fIargv\fP a vector of argument strings passed to the new program\&. .br \fImode\fP the I/O mode to use when opening the pipe\&. .RE .PP \fBSee also:\fP .RS 4 \fBbasic_pstreambuf::open(const std::string&, const argv_type&, pmode)\fP .RE .PP .PP References redi::pstream_common< CharT, Traits >::buf_, redi::pstream_common< CharT, Traits >::command_, and redi::basic_pstreambuf< CharT, Traits >::open()\&. .SS "template bool \fBredi::pstream_common\fP< C, T >::is_open () const\fC [inline]\fP, \fC [inherited]\fP" .PP Report whether the stream's buffer has been initialised\&. .PP \fBReturns:\fP .RS 4 \fBrdbuf()\fP->\fBis_open()\fP\&. .RE .PP \fBSee also:\fP .RS 4 \fBbasic_pstreambuf::is_open()\fP .RE .PP .PP References redi::pstream_common< CharT, Traits >::buf_, and redi::basic_pstreambuf< CharT, Traits >::is_open()\&. .SS "template> void \fBredi::basic_opstream\fP< CharT, Traits >::open (const std::string & cmd, \fBpmode\fP mode = \fC\fBpstdin\fP\fP)\fC [inline]\fP" .PP Start a process\&. Calls do_open( \fIcmd\fP , \fImode|pstdin\fP )\&. .PP \fBParameters:\fP .RS 4 \fIcmd\fP a string containing a shell command\&. .br \fImode\fP the I/O mode to use when opening the pipe\&. .RE .PP \fBSee also:\fP .RS 4 \fBdo_open(const std::string&, pmode)\fP .RE .PP .PP References redi::pstreams::pstdin\&. .SS "template> void \fBredi::basic_opstream\fP< CharT, Traits >::open (const std::string & file, const \fBargv_type\fP & argv, \fBpmode\fP mode = \fC\fBpstdin\fP\fP)\fC [inline]\fP" .PP Start a process\&. Calls do_open( \fIfile\fP , \fIargv\fP , \fImode|pstdin\fP )\&. .PP \fBParameters:\fP .RS 4 \fIfile\fP a string containing the pathname of a program to execute\&. .br \fIargv\fP a vector of argument strings passed to the new program\&. .br \fImode\fP the I/O mode to use when opening the pipe\&. .RE .PP \fBSee also:\fP .RS 4 \fBdo_open(const std::string&, const argv_type&, pmode)\fP .RE .PP .PP References redi::pstreams::pstdin\&. .SS "template \fBpstream_common\fP< C, T >::\fBstreambuf_type\fP * \fBredi::pstream_common\fP< C, T >::rdbuf () const\fC [inline]\fP, \fC [inherited]\fP" .PP Return a pointer to the stream buffer\&. .PP \fBReturns:\fP .RS 4 a pointer to the private stream buffer member\&. .RE .PP .PP References redi::pstream_common< CharT, Traits >::buf_, redi::pstreams::pstderr, redi::pstreams::pstdin, and redi::pstreams::pstdout\&. .SH "Friends And Related Function Documentation" .PP .SS "template std::basic_ostream< C, T > & peof (std::basic_ostream< C, T > & s)\fC [related]\fP" .PP Manipulator to close the pipe connected to the process' stdin\&. When inserted into an output pstream the manipulator calls \fBbasic_pstreambuf::peof()\fP to close the output pipe, causing the child process to receive the end-of-file indicator on subsequent reads from its \fCstdin\fP stream\&. .PP \fBParameters:\fP .RS 4 \fIs\fP An output PStream class\&. .RE .PP \fBReturns:\fP .RS 4 The stream object the manipulator was invoked on\&. .RE .PP \fBSee also:\fP .RS 4 \fBbasic_pstreambuf::peof()\fP \fBbasic_pstream\fP \fBbasic_rpstream\fP .RE .PP .PP References redi::basic_pstreambuf< CharT, Traits >::peof()\&. .SH "Author" .PP Generated automatically by Doxygen for PStreams from the source code\&.