1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include "pstream.h"
#include <iostream>
// TODO abstract process creation and control to a process class.
template class redi::basic_pstreambuf<char>;
template class redi::pstream_common<char>;
template class redi::basic_pstream<char>;
template class redi::basic_ipstream<char>;
template class redi::basic_opstream<char>;
template class redi::basic_rpstream<char>;
int main()
{
using namespace redi;
char c;
ipstream who("id -un");
if (!(who >> c))
return 1;
redi::opstream cat("cat");
if (!(cat << c))
return 2;
while (who >> c)
cat << c;
cat << '\n' << peof;
pstream fail("ghghghg", pstreambuf::pstderr);
std::string s;
if (!std::getline(fail, s))
return 3;
std::cerr << s << '\n';
rpstream who2("id -un");
if (!(who2.out() >> c))
return 4;
}
|