Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTuple.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "JTools/JTuple.hh"
6 
7 #include "Jeep/JParser.hh"
8 #include "Jeep/JMessage.hh"
9 
10 
11 /**
12  * \file
13  *
14  * Example program to test JTOOLS::JTuple class.
15  * \author mdejong
16  */
17 int main(int argc, char **argv)
18 {
19  using namespace std;
20 
21  int debug;
22 
23  try {
24 
25  JParser<> zap("Example program to test tuple class.");
26 
27  zap['d'] = make_field(debug) = 3;
28 
29  zap(argc, argv);
30  }
31  catch(const exception &error) {
32  FATAL(error.what() << endl);
33  }
34 
35 
36  using namespace JPP;
37 
38  {
40 
41  JTuple<typelist> A(+1, +2, +0.9999);
42  JTuple<typelist> B(-A);
43 
44  cout << A.first << endl;
45  cout << A.second.first << endl;
46  cout << A.second.second << endl;
47 
48  cout << "A = " << showpos << A << endl;
49  cout << "B = " << showpos << B << endl;
50  cout << "A + B = " << noshowpos << A+B << endl;
51 
52  cout << "A == A ? " << (A == A) << endl;
53  cout << "A == B ? " << (A == B) << endl;
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  cout << "A = " << A << endl;
69  cout << "B = " << B << endl;
70  cout << "A + B = " << A+B << endl; // uses std::string operator::+=()
71  cout << "A == A ? " << (A == A) << endl;
72  cout << "A == B ? " << (A == B) << endl;
73  }
74 
75  {
76  cout << JPP::make_tuple(1, string("aap"), 0.99) << endl;
77  }
78 }
Utility class to parse command line options.
Definition: JParser.hh:1410
Type list.
Definition: JTypeList.hh:22
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
int debug
debug level
Definition: JSirene.cc:59
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:65
Utility class to parse command line options.
Data structure based on type list.
JTuple< JTypeList< JNullType, JNullType > > make_tuple(const JNullType &b, const JNullType &c, const JNullType &d, const JNullType &e, const JNullType &f, const JNullType &g, const JNullType &h, const JNullType &i, const JNullType &j, const JNullType &k, const JNullType &l, const JNullType &m, const JNullType &n, const JNullType &o, const JNullType &p, const JNullType &q, const JNullType &r, const JNullType &s, const JNullType &t, const JNullType &u, const JNullType &v, const JNullType &w, const JNullType &x, const JNullType &y, const JNullType &z)
Helper method for tuple.
Definition: JTuple.hh:724
int main(int argc, char *argv[])
Definition: Main.cpp:15