Jpp  16.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JConversion.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "JLang/JConversion.hh"
6 
7 #include "Jeep/JParser.hh"
8 #include "Jeep/JMessage.hh"
9 
10 
11 namespace {
12 
13  struct __A__ {};
14 
15  struct __B__ : public __A__ {};
16 
17  /**
18  * Print class parameters.
19  *
20  * \param out output stream
21  * \param uname name of class
22  * \param vname name of class
23  */
24  template<class U, class V>
25  inline void print(std::ostream& out, const char* uname, const char* vname)
26  {
27  using namespace std;
28  using namespace JPP;
29 
30  out << setw(36) << left << string("<") + string(uname) + string(",") + string(vname) + string(">");
31  out << setw(4) << '.' << setw(8) << left << JConversion<U, V>::is_same;
32  out << setw(4) << '.' << setw(8) << left << JConversion<U, V>::is_derived;
33  out << endl;
34  }
35 }
36 
37 
38 /**
39  * Print class parameters.
40  *
41  * \param OUT output stream
42  * \param U class
43  * \param V class
44  */
45 #define PRINT(OUT, U, V) print<U,V>(OUT, #U, #V)
46 
47 
48 /**
49  * \file
50  *
51  * Example program to test JLANG::JConversion class.
52  * \author mdejong
53  */
54 int main(int argc, char **argv)
55 {
56  using namespace std;
57  using namespace JPP;
58 
59  int debug;
60 
61  try {
62 
63  JParser<> zap("Example program to test class inspection.");
64 
65  zap['d'] = make_field(debug) = 3;
66 
67  zap(argc, argv);
68  }
69  catch(const exception &error) {
70  FATAL(error.what() << endl);
71  }
72 
73  if (debug >= debug_t) {
74 
75  cout << setw(36) << left << "name";
76  cout << setw(12) << " same ";
77  cout << setw(12) << " derived";
78  cout << endl;
79 
80  cout << setfill('.');
81 
82  PRINT(cout, __A__, __A__);
83  PRINT(cout, __B__, __A__);
84  PRINT(cout, __A__, __B__);
85  PRINT(cout, __A__, __B__);
86  }
87 
88  ASSERT(( JConversion<__A__, __A__>::is_same));
89  ASSERT(( JConversion<__B__, __A__>::is_derived));
90  ASSERT((!JConversion<__A__, __B__>::is_same));
91  ASSERT((!JConversion<__A__, __B__>::is_derived));
92 }
Utility class to parse command line options.
Definition: JParser.hh:1500
debug
Definition: JMessage.hh:29
int main(int argc, char *argv[])
Definition: Main.cc:15
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
print
Definition: JConvertDusj.sh:44
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
#define PRINT(OUT, U, V)
Print class parameters.
Definition: JConversion.cc:45