Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JLang
JSTDObjectReader.cc
Go to the documentation of this file.
1
2
#include <string>
3
#include <iostream>
4
#include <iomanip>
5
#include <vector>
6
#include <set>
7
8
#include "
JLang/JSTDObjectReader.hh
"
9
#include "
JLang/JConversionIterator.hh
"
10
11
#include "
Jeep/JParser.hh
"
12
#include "
Jeep/JMessage.hh
"
13
14
15
/**
16
* \file
17
*
18
* Example program to test JLANG::JSTDObjectReader class.
19
* \author mdejong
20
*/
21
int
main
(
int
argc,
char
**argv)
22
{
23
using namespace
std;
24
25
int
debug
;
26
27
try
{
28
29
JParser<>
zap(
"Example program to test object iteration using STD containers."
);
30
31
zap[
'd'
] =
make_field
(
debug
) = 3;
32
33
zap(argc, argv);
34
}
35
catch
(
const
exception &error) {
36
FATAL
(error.what() << endl);
37
}
38
39
40
using namespace
JPP;
41
42
typedef
vector<double>
buffer_type;
43
44
buffer_type buffer;
45
46
for
(
int
i = 0; i != 3; ++i) {
47
buffer.push_back(i + 0.1);
48
}
49
50
{
51
JSTDObjectReader<double>
in
(buffer);
52
53
for
(
int
i = 0; in.hasNext(); ++i) {
54
55
const
double
value = *in.next();
56
57
DEBUG
(
"in "
<< value << endl);
58
59
ASSERT
(value == buffer[i]);
60
}
61
62
in.rewind();
63
64
JConversionIterator<double, int> out(in);
65
66
for
(
int
i = 0; out.hasNext(); ++i) {
67
68
const
int
value = *in.next();
69
70
DEBUG
(
"out "
<< value << endl);
71
72
ASSERT
(value == (
int
) buffer[i]);
73
}
74
}
75
{
76
JSTDObjectReader<const double>
in
(buffer);
77
78
for
(
int
i = 0; in.hasNext(); ++i) {
79
80
const
double
value = *in.next();
81
82
DEBUG
(
"in "
<< value << endl);
83
84
ASSERT
(value == buffer[i]);
85
}
86
}
87
88
return
0;
89
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1493
JConversionIterator.hh
in
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition:
JSirene.sh:45
JSTDObjectReader.hh
std::vector< double >
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition:
JMessage.hh:90
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1954
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.
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5