-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathio_redirect_handler.h
56 lines (49 loc) · 1.14 KB
/
io_redirect_handler.h
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef IOREDIRECTHANDLER_HPP
#define IOREDIRECTHANDLER_HPP
#include <iostream>
#include <fstream>
#include "config.h"
/*
If --server given, then
Redirect cin and cout to the input and output pipes given as parametres --ipipe --opipe.
else
do nothing
Redirection is done by the constructor. The destructor undoes the redirection.
serverOK() == true -> --server was given and pipes where successfuly opened.
*/
class CppIORedirectHandler
{
std::streambuf *cin_buffer;
std::streambuf *cout_buffer;
std::ifstream *ifs;
std::ofstream *ofs;
bool ok;
public:
CppIORedirectHandler(const config &cfg);
~CppIORedirectHandler();
bool serverOK();
};
class CppWIORedirectHandler
{
std::wstreambuf *cin_buffer;
std::wstreambuf *cout_buffer;
std::wifstream *ifs;
std::wofstream *ofs;
bool ok;
public:
CppWIORedirectHandler(const config &cfg);
~CppWIORedirectHandler();
bool serverOK();
};
class Fd0WcoutRedirectHandler
{
int original_stdin;
std::wstreambuf *cout_buffer;
std::wofstream *ofs;
bool ok;
public:
Fd0WcoutRedirectHandler(const config &cfg);
~Fd0WcoutRedirectHandler();
bool serverOK();
};
#endif