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