Jpp  16.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMultiPointer.cc File Reference

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

#include <iostream>
#include <iomanip>
#include "JLang/JMultiPointer.hh"
#include "JLang/JType.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::JMultiPointer class.

Author
mdejong

Definition in file JMultiPointer.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 81 of file JMultiPointer.cc.

82 {
83  using namespace std;
84 
85  int debug;
86 
87  try {
88 
89  JParser<> zap("Example program to test multi pointer.");
90 
91  zap['d'] = make_field(debug) = 3;
92 
93  zap(argc, argv);
94  }
95  catch(const exception &error) {
96  FATAL(error.what() << endl);
97  }
98 
99 
100  using namespace JPP;
101 
102  {
103  JMultiPointer< JTypeList<int> > ps(new int(-123));
104 
105  print<int>(cout, ps);
106 
107  delete ps.get<int>();
108  }
109 
110 
111  {
112  typedef
113  JTypeList<const char,
114  JTypeList<int,
115  JTypeList<double> > > typelist;
116 
118 
119  ps.reset("aap");
120  ps.reset(new int(1));
121  ps.reset(new double(123.456));
122 
123  *ps.get<int>() += 10;
124 
125  print<int> (cout, ps);
126  print<const char>(cout, ps);
127  print<double> (cout, ps);
128 
129  delete ps.get<int> ();
130  delete ps.get<double>();
131  }
132 }
Utility class to parse command line options.
Definition: JParser.hh:1500
void reset(const JMultiPointer< JClass_t > &pointer)
Reset multi-pointer.
Type list.
Definition: JTypeList.hh:22
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
T * get() const
Get single pointer.
General purpose class for multiple pointers.