Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JLang
JWhiteSpacesFacet.cc
Go to the documentation of this file.
1
2
#include <string>
3
#include <iostream>
4
#include <fstream>
5
#include <locale>
6
#include <iomanip>
7
8
#include "
JLang/JWhiteSpacesFacet.hh
"
9
10
#include "
Jeep/JParser.hh
"
11
#include "
Jeep/JMessage.hh
"
12
13
14
/**
15
* \file
16
*
17
* Example program to test JLANG::JWhiteSpacesFacet class.
18
* \author mdejong
19
*/
20
int
main
(
int
argc,
char
**argv)
21
{
22
using namespace
std;
23
24
string
ws;
25
string
inputFile;
26
int
debug
;
27
28
try
{
29
30
JParser<>
zap(
"Example program to test white spaces handling using facet."
);
31
32
zap[
'c'
] =
make_field
(ws) =
" \t=."
;
33
zap[
'f'
] =
make_field
(inputFile) =
""
;
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
using namespace
JPP;
44
45
46
if
(inputFile ==
""
) {
47
48
for
( ; ; ) {
49
50
cout <<
"> "
<< flush;
51
52
string
buffer;
53
54
getline
(cin, buffer);
55
56
if
(buffer !=
""
) {
57
58
istringstream
is
(buffer);
59
60
const
locale
loc
(is.getloc(),
new
JWhiteSpacesFacet(is.getloc(), ws));
61
62
is.imbue(loc);
63
64
for
(
string
key; is >> key; ) {
65
cout << key << endl;
66
}
67
68
}
else
69
70
break
;
71
}
72
73
}
else
{
74
75
ifstream
in
(inputFile.c_str());
76
77
in
.imbue(locale(
in
.getloc(),
new
JWhiteSpacesFacet(
in
.getloc(), ws)));
78
79
for
(
string
key;
in
>> key; ) {
80
cout << key << endl;
81
}
82
83
in
.close();
84
}
85
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1493
JWhiteSpacesFacet.hh
in
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition:
JSirene.sh:45
is
is
Definition:
JDAQCHSM.chsm:167
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1954
JLANG::getline
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition:
JString.hh:478
debug
int debug
debug level
Definition:
JSirene.cc:61
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
loc
char * loc(char *orig)
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5