Main Page
Namespaces
Classes
Files
File List
File Members
libism
ISM
soci
src
core
type-holder.h
Go to the documentation of this file.
1
//
2
// Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton
3
// Distributed under the Boost Software License, Version 1.0.
4
// (See accompanying file LICENSE_1_0.txt or copy at
5
// http://www.boost.org/LICENSE_1_0.txt)
6
//
7
8
#ifndef SOCI_TYPE_HOLDER_H_INCLUDED
9
#define SOCI_TYPE_HOLDER_H_INCLUDED
10
// std
11
#include <typeinfo>
12
13
namespace
soci
14
{
15
16
namespace
details
17
{
18
19
// Base class holder + derived class type_holder for storing type data
20
// instances in a container of holder objects
21
template
<
typename
T>
22
class
type_holder
;
23
24
class
holder
25
{
26
public
:
27
holder
() {}
28
virtual
~holder
() {}
29
30
template
<
typename
T>
31
T
get
()
32
{
33
type_holder<T>
* p =
dynamic_cast<
type_holder<T>
*
>
(
this
);
34
if
(p)
35
{
36
return
p->template value<T>();
37
}
38
else
39
{
40
throw
std::bad_cast();
41
}
42
}
43
44
private
:
45
46
template
<
typename
T>
47
T
value
();
48
};
49
50
template
<
typename
T>
51
class
type_holder
:
public
holder
52
{
53
public
:
54
type_holder
(T * t) : t_(t) {}
55
~type_holder
() {
delete
t_; }
56
57
template
<
typename
TypeValue>
58
TypeValue
value
()
const
{
return
*t_; }
59
60
private
:
61
T *
t_
;
62
};
63
64
}
// namespace details
65
66
}
// namespace soci
67
68
#endif // SOCI_TYPE_HOLDER_H_INCLUDED
soci::details::type_holder::~type_holder
~type_holder()
Definition:
type-holder.h:55
soci::details::holder::value
T value()
soci::details::holder::holder
holder()
Definition:
type-holder.h:27
soci::details::type_holder::value
TypeValue value() const
Definition:
type-holder.h:58
soci::details::type_holder::t_
T * t_
Definition:
type-holder.h:61
soci::details::holder::~holder
virtual ~holder()
Definition:
type-holder.h:28
soci::details::type_holder
Definition:
type-holder.h:22
soci::details::type_holder::type_holder
type_holder(T *t)
Definition:
type-holder.h:54
soci::details::holder
Definition:
type-holder.h:24
soci
Definition:
db2/common.h:15
asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:41