Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JLang
JNullStream.cc
Go to the documentation of this file.
1
2
#include <string>
3
#include <iostream>
4
#include <iomanip>
5
6
#include "
JLang/JFileStream.hh
"
7
#include "
JLang/JNullStream.hh
"
8
9
#include "
Jeep/JParser.hh
"
10
#include "
Jeep/JMessage.hh
"
11
12
13
/**
14
* \file
15
*
16
* Example program to test JANG::JFileSream and JLANG::JNullStream classes.
17
* \author mdejong
18
*/
19
int
main
(
int
argc,
char
**argv)
20
{
21
using namespace
std;
22
using namespace
JPP;
23
24
bool
use_cin;
25
bool
use_cout;
26
int
debug
;
27
28
try
{
29
30
JParser<>
zap(
"Example program to test file streaming."
);
31
32
zap[
'c'
] =
make_field
(use_cin);
33
zap[
'C'
] =
make_field
(use_cout);
34
zap[
'd'
] =
make_field
(
debug
) = 0;
35
36
zap(argc, argv);
37
}
38
catch
(
const
exception &error) {
39
FATAL
(error.what() << endl);
40
}
41
42
43
JFileInputStream is(STDIN_FILENO);
44
JFileOutputStream os(STDOUT_FILENO);
45
46
istream in (use_cin ? cin .rdbuf() : is.rdbuf());
47
ostream out(use_cout ? cout.rdbuf() : os.rdbuf());
48
49
for
( ; ; ) {
50
51
string
buffer;
52
53
out <<
"> "
<< flush;
54
getline
(in,buffer);
55
56
if
(buffer !=
""
) {
57
58
cout <<
"out -> <"
<< flush; out << buffer << flush; cout <<
">"
<< endl;
59
cout <<
"null -> <"
<< flush;
null
<< buffer << flush; cout <<
">"
<< endl;
60
61
}
else
{
62
63
break
;
64
}
65
}
66
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1410
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
debug
int debug
debug level
Definition:
JSirene.cc:59
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:65
JParser.hh
Utility class to parse command line options.
JFileStream.hh
JLANG::null
static JNullStream null
Null I/O stream.
Definition:
JNullStream.hh:51
JNullStream.hh
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5