Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JTypeList.cc File Reference

Example program to test JLANG::JTypeList class. More...

#include <iostream>
#include <iomanip>
#include <typeinfo>
#include "JLang/JType.hh"
#include "JLang/JTypeList.hh"
#include "JLang/JConversion.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test JLANG::JTypeList class.

Author
mdejong

Definition in file JTypeList.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 53 of file JTypeList.cc.

54 {
55  using namespace std;
56 
57  int debug;
58 
59  try {
60 
61  JParser<> zap("Example program to test type lists.");
62 
63  zap['d'] = make_field(debug) = 3;
64 
65  zap(argc, argv);
66  }
67  catch(const exception &error) {
68  FATAL(error.what() << endl);
69  }
70 
71  using namespace JPP;
72 
73  typedef JTYPELIST<char,
74  short>::typelist removal;
75 
76  typedef JTYPELIST<char,
77  short,
78  int,
79  float,
80  double>::typelist typelist;
81 
82  const int N = 30;
83 
84  cout << setw(N) << left << "typelist" << JType<typelist>() << endl;
85  cout << setw(N) << left << "removal list" << JType<removal> () << endl;
86  cout << setw(N) << left << "index of char" << JIndexOf<typelist,char> ::value << endl;
87  cout << setw(N) << left << "index of float" << JIndexOf<typelist,float>::value << endl;
88 
89  cout << setw(N) << left << "typelist w/o char" << JType<JRemove<typelist, char> ::typelist>() << endl;
90  cout << setw(N) << left << "typelist w/o int" << JType<JRemove<typelist, int> ::typelist>() << endl;
91  cout << setw(N) << left << "typelist w/o removal list" << JType<JRemove<typelist, removal>::typelist>() << endl;
92  cout << setw(N) << left << "removal list w int" << JType<JAppend<removal, int> ::typelist>() << endl;
93  cout << setw(N) << left << "removal list w typelist" << JType<JAppend<removal, typelist>::typelist>() << endl;
94 
95  cout << "Length of typelist " << JLength<typelist>::value << endl;
96  cout << "Type at 0 is char " << JConversion<char, JTypeAt<typelist, 0, false>::value_type>::is_same << endl;
97  cout << "Type at 4 is double " << JConversion<double, JTypeAt<typelist, 4, false>::value_type>::is_same << endl;
98  cout << "Type at 5 is null " << JConversion<JNullType, JTypeAt<typelist, 5, false>::value_type>::is_same << endl;
99  //cout << "Type at 5 is null " << JConversion<JNullType, JTypeAt<typelist, 5, true> ::value_type>::is_same << endl;
100 }
Utility class to parse command line options.
Definition: JParser.hh:1410
Template class test for polymorphism.
Definition: JConversion.hh:21
Auxiliary class for a type holder.
Definition: JType.hh:19
Length of type list.
Definition: JTypeList.hh:176
Auxiliary class for recursive type list generation.
Definition: JTypeList.hh:377
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65
Indexing of data type in type list.
Definition: JTypeList.hh:310