Jpp
15.0.0-rc.2
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JLang
JMultiPointer.cc
Go to the documentation of this file.
1
2
#include <iostream>
3
#include <iomanip>
4
5
#include "
JLang/JMultiPointer.hh
"
6
#include "
JLang/JType.hh
"
7
8
#include "
Jeep/JParser.hh
"
9
#include "
Jeep/JMessage.hh
"
10
11
12
namespace
{
13
14
using namespace
JPP;
15
16
17
/**
18
* Print object pointed to from given multi-pointer based on given data type.
19
* Note that the overloading of this method because partial specialisation
20
* of methods is not compliant with the C++ standard.
21
*
22
* \param out output stream
23
* \param ps multi-pointer
24
* \param type data type
25
*/
26
template
<
class
T,
class
JMultiPo
int
er_t>
27
inline
void
print
(std::ostream& out, JMultiPointer_t& ps,
const
JType<T>
& type)
28
{
29
T
* __p = ps.template get<T>();
30
31
if
(__p != NULL) {
32
out << *__p;
33
}
34
}
35
36
37
/**
38
* Print character string pointed to from given multi-pointer.
39
* Note that the overloading of this method because partial specialisation
40
* of methods is not compliant with the C++ standard.
41
*
42
* \param out output stream
43
* \param ps multi-pointer
44
* \param type const char type
45
*/
46
template
<
class
JMultiPo
int
er_t>
47
inline
void
print
(std::ostream& out, JMultiPointer_t& ps,
const
JType<const char>
& type)
48
{
49
const
char
* __p = ps.template get<const char>();
50
51
if
(__p != NULL) {
52
out << __p;
53
}
54
}
55
56
57
/**
58
* Print object pointed to from given multi-pointer based on given template argument.
59
*
60
* \param out output stream
61
* \param ps multi-pointer
62
*/
63
template
<
class
T,
class
JMultiPo
int
er_t>
64
inline
void
print
(std::ostream& out, JMultiPointer_t& ps)
65
{
66
out <<
"JMultiPointer: <"
;
67
68
print
(out, ps,
JType<T>
());
69
70
out <<
">"
<< std::endl;
71
}
72
}
73
74
75
/**
76
* \file
77
*
78
* Example program to test JLANG::JMultiPointer class.
79
* \author mdejong
80
*/
81
int
main
(
int
argc,
char
**argv)
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
117
JMultiPointer<typelist>
ps;
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
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JLANG::JMultiPointer::reset
void reset(const JMultiPointer< JClass_t > &pointer)
Reset multi-pointer.
Definition:
JMultiPointer.hh:52
JLANG::JType
Auxiliary class for a type holder.
Definition:
JType.hh:19
JLANG::JTypeList
Type list.
Definition:
JTypeList.hh:22
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1961
T
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Definition:
JCalibrateHeight.sh:61
debug
int debug
debug level
Definition:
JSirene.cc:63
print
print
Definition:
JConvertDusj.sh:44
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JMultiPointer.hh
JType.hh
JParser.hh
Utility class to parse command line options.
JLANG::JMultiPointer::get
T * get() const
Get single pointer.
Definition:
JMultiPointer.hh:64
JLANG::JMultiPointer
General purpose class for multiple pointers.
Definition:
JMultiPointer.hh:22
Generated by
1.8.5