FBB::StdExtractor(3bobcat)

πŸ’– FBB::StdExtractor πŸ’–

okay bestie, welcome to FBB::StdExtractor πŸ’… β€” she lives in section 3bobcat, and her official vibe in the title is Executing Child Processes. Yeah. She spawns external programs and catches what they scream into standard error. Main character energy fr fr πŸ‘‘


✨ NAME ✨

FBB::StdExtractor β€” Runs external programs writing standard error 🫢


🌸 SYNOPSIS 🌸

#include <bobcat/cerrextractor>

Linking option: -lbobcat


πŸ¦‹ DESCRIPTION πŸ¦‹

So the FBB::StdExtractor class is basically the basic interface for calling external programs β€” you know, child processes β€” and dealing with the standard output and standard error streams they write. The child processes' standard input streams are, by default, not handled by StdExtractor objects. Nope, not her job πŸ’€

The child's standard output and standard error streams are read through the StdExtractor object: anything the child process writes to those streams gets extracted (or just read) from the StdExtractor object. Simple as that.

Heads up bestie: the PATH environment variable is not used when calling child processes. Child process programs must be specified using paths. No shortcuts, no searching, she needs the full address 🏠

StdExtractor objects may repeatedly be used to execute the same child process, or a whole different one. Reuse is iconic, periodt ♻️

Now, the quoting lore πŸ“œ β€” arguments passed to child processes may be surrounded by double or single quotes:

  • Arguments surrounded by double quotes have their double quotes removed, while interpreting any escape-sequences that may have been used within.
  • Arguments surrounded by single quotes have their single quotes removed, while accepting their content as-is.
  • Bonus: unquoted escape-sequences may also be specified, and those escape sequences are evaluated and replaced by their intended characters β€” for example, \100 is converted to @ ✨

🌈 NAMESPACE 🌈

FBB

All constructors, members, operators and manipulators mentioned in this man-page are defined in the namespace FBB. πŸ’œ


🧚 INHERITS FROM 🧚

FBB::Exec (private), FBB::IFdBuf (private), std::istream


πŸŽ€ CONSTRUCTOR πŸŽ€

  • StdExtractor(size_t bufSize = 100) β€” you may pass a bufSize argument, and it defines the internal buffer size used by the StdExtractor's streambuf. By default the standard input stream is not handled. πŸ™ˆ
  • CoutExtractor(Mode mode, size_t bufSize = 100) β€” the mode argument must be StdExtractor::CLOSE_STD. It indicates that the standard input stream is redirected to /dev/null: the child processes cannot read their standard input streams. And yep, a bufSize argument may be specified too β€” it defines the internal buffer size used by the CinInserter's streambuf.
  • Copy and move constructors (and assignment operators) are not available. She does not do duplicates, sorry 🚫

πŸ’… MEMBERS πŸ’…

  • void execute(std::string const &cmd) β€” the argument specifies the command to execute, and the command itself must be specified as a path (the PATH environment variable isn't used, as established). This member immediately returns, and after that, information written by the child process to its standard output and standard error streams may be extracted from the StdExtractor object. πŸƒβ€β™€οΈπŸ’¨

Once execute has returned, it can be called again β€” either with the same command or another one. Round two, let's go πŸ”₯

Arguments passed to the program to be executed as child process may optionally be specified using single or double quotes, as described in this man-page's DESCRIPTION section. Same rules, same energy πŸ’–

  • int ret() const β€” once execute has returned, this member provides the actual exit code of the child process. Its value equals -1 before the first execute call. So before you've done anything, she's at negative one, and that's just the lore πŸ€·β€β™€οΈ

πŸ‘‘ PROTECTED MEMBER πŸ‘‘

  • Pipe &childOutPipe() β€” if derived classes need to override the redirections-members, then they probably need access to the pipe written by the child process. This member provides a reference to that pipe. By default the parent process reads information from the pipe, while the child process inserts its standard error output into the pipe. 🀝

⭐ EXAMPLE ⭐

#include <iostream>

#include <bobcat/cerrextractor>

using namespace std;
using namespace FBB;

int main()
{
    CerrExtractor extractor;

    extractor.execute("/bin/cat driver.cc");

    cout << extractor.rdbuf();

    cerr << "Returning: " << extractor.ret() << "\n"
            "again:\n";

    extractor.execute("/bin/cat driver.cc");

    cout << extractor.rdbuf();

    cerr << "Returning: " << extractor.ret() << ’\n’;

}

πŸ“ FILES πŸ“

  • bobcat/cerrextractor β€” provides the class interface

πŸ’œ SEE ALSO πŸ’œ

bobcat(7), cerrextractor(3bobcat), cininserter(3bobcat), coutextractor(3bobcat), execl(3), exec(3bobcat), fork(3bobcat), process(3bobcat).

Go read those too bestie, they're all connected πŸ¦‹


πŸ’€ BUGS πŸ’€

None reported. We love a clean record, no cap ✨


🌼 BOBCAT PROJECT FILES 🌼

Debian Bobcat project files:

  • libbobcat6 β€” debian package containing the shared library, changelog and copyright note;
  • libbobcat-dev β€” debian package containing the static library, headers, manual pages, and developer info;

🌸 BOBCAT 🌸

Bobcat is an acronym of Brokken's Own Base Classes And Templates. Cute acronym, honestly obsessed 😌


This is free software, distributed under the terms of the GNU General Public License (GPL). Free as in freedom, slay πŸ’…


πŸ’Œ AUTHOR πŸ’Œ

Frank B. Brokken (f.b.brokken@rug.nl).


okay and that's the whole page bestie, you made it to the end πŸŽ‰ this was libbobcat-dev_6.15.01, dated 2005-2026, and yeah it's FBB::StdExtractor(3bobcat) β€” literally iconic, no notes πŸ’–βœ¨πŸ‘‘

πŸ“¦ where this page comes from