Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JSystem
JProcess.cc
Go to the documentation of this file.
1
2
#include <string>
3
#include <iostream>
4
#include <iomanip>
5
#include <algorithm>
6
7
#include "
JSystem/JProcess.hh
"
8
#include "
Jeep/JParser.hh
"
9
#include "
Jeep/JMessage.hh
"
10
11
12
/**
13
* \file
14
*
15
* Example for testing inter-process communication.
16
* \author mdejong
17
*/
18
int
main
(
int
argc,
char
* argv[])
19
{
20
using namespace
std;
21
22
string
command;
23
bool
use_cin;
24
bool
revert;
25
26
try
{
27
28
JParser<>
zap(
"Example for testing inter-process communication."
);
29
30
zap[
'c'
] =
make_field
(command);
31
zap[
'C'
] =
make_field
(use_cin);
32
zap[
'r'
] =
make_field
(revert);
33
34
zap(argc, argv);
35
}
36
catch
(
const
exception &error) {
37
FATAL
(error.what() << endl);
38
}
39
40
41
42
using namespace
JPP;
43
44
try
{
45
46
JProcess process(command);
47
48
if
(!use_cin) {
49
50
istream in(process.getInputStreamBuffer());
51
52
for
(
string
buffer;
getline
(in, buffer); ) {
53
cout << buffer << endl;
54
}
55
56
}
else
{
57
58
ostream out(process.getOutputStreamBuffer());
59
istream in (process.getInputStreamBuffer());
60
61
for
(
string
buffer;
getline
(cin, buffer) && buffer !=
""
; ) {
62
63
out << buffer << endl;
64
65
getline
(in, buffer);
66
67
if
(revert) {
68
reverse(buffer.begin(), buffer.end());
69
}
70
71
cout << buffer << endl;
72
}
73
}
74
}
75
catch
(
const
JException& error) {
76
cerr << error.what() << endl;
77
}
78
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1410
JProcess.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1836
JLANG::getline
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition:
JString.hh:468
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:65
JParser.hh
Utility class to parse command line options.
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5