Jpp
15.0.5
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JTools
JTuple.cc
Go to the documentation of this file.
1
2
#include <iostream>
3
#include <sstream>
4
#include <iomanip>
5
6
#include "
JTools/JTuple.hh
"
7
8
#include "
Jeep/JParser.hh
"
9
#include "
Jeep/JMessage.hh
"
10
11
12
/**
13
* \file
14
*
15
* Example program to test JTOOLS::JTuple class.
16
* \author mdejong
17
*/
18
int
main
(
int
argc,
char
**argv)
19
{
20
using namespace
std;
21
using namespace
JPP;
22
23
int
debug
;
24
25
try
{
26
27
JParser<>
zap(
"Example program to test tuple class."
);
28
29
zap[
'd'
] =
make_field
(
debug
) = 3;
30
31
zap(argc, argv);
32
}
33
catch
(
const
exception &error) {
34
FATAL
(error.what() << endl);
35
}
36
37
38
{
39
typedef
JTYPELIST<int, int, double>::typelist
typelist;
40
41
JTuple<typelist>
A
(+1, +2, +0.9999);
42
JTuple<typelist> B(-A);
43
44
DEBUG
(A.first << endl);
45
DEBUG
(A.second.first << endl);
46
DEBUG
(A.second.second << endl);
47
48
DEBUG
(
"A = "
<< showpos << A << endl);
49
DEBUG
(
"B = "
<< showpos << B << endl);
50
DEBUG
(
"A + B = "
<< noshowpos << A+B << endl);
51
52
ASSERT
(A == A,
"A == A"
);
53
ASSERT
(A != B,
"A != B"
);
54
}
55
56
{
57
typedef
JTYPELIST<string, int>::typelist
typelist;
58
59
JTuple<typelist>
A
;
60
JTuple<typelist> B;
61
62
A.first =
"aap"
;
63
A.second = 1234;
64
65
B.first =
"noot"
;
66
B.second = -A.second;
67
68
JTuple<typelist>
C
= A + B;
69
70
DEBUG
(
"A = "
<< A << endl);
71
DEBUG
(
"B = "
<< B << endl);
72
DEBUG
(
"A + B = "
<< C << endl);
// uses std::string operator::+=()
73
74
75
ASSERT
(C == JTuple<typelist>(
"aapnoot"
, 0),
"Test of A + B with std::string"
);
76
}
77
78
{
79
ostringstream os;
80
81
os <<
JPP::make_tuple
(1,
string
(
"aap"
), 0.99);
82
83
DEBUG
(os.str() << endl);
84
85
ASSERT
(os.str() ==
"1 aap 0.99"
,
"Test of JPP::make_tuple"
);
86
}
87
88
return
0;
89
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JPHYSICS::C
static const double C
Physics constants.
Definition:
JPhysics/JConstants.hh:25
JLANG::JTypeList
Type list.
Definition:
JTypeList.hh:22
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:1961
JTOOLS::make_tuple
JTuple< typename JTYPELIST< Args...>::typelist > make_tuple(const Args &...args)
Helper method for tuple.
Definition:
JTuple.hh:705
debug
int debug
debug level
Definition:
JSirene.cc:63
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
DEBUG
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
Definition:
JCalibratePMT.sh:21
JTuple.hh
Data structure based on type list.
A
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A
Definition:
JShellParser.csh:15
Generated by
1.8.5