Jpp
software
JLang
JSTDObjectOutput.hh
Go to the documentation of this file.
1
#ifndef __JLANG__JSTDOBJECTOUTPUT__
2
#define __JLANG__JSTDOBJECTOUTPUT__
3
4
#include <iterator>
5
6
#include "
JLang/JObjectOutput.hh
"
7
#include "
JLang/JObject.hh
"
8
#include "
JLang/JSTDTypes.hh
"
9
10
11
/**
12
* \author mdejong
13
*/
14
15
namespace
JLANG
{}
16
namespace
JPP
{
using namespace
JLANG
; }
17
18
namespace
JLANG
{
19
20
/**
21
* Implementation of object output for STD compatible output iterator.
22
*
23
* This class implements the JLANG::JObjectOutput interface for the corresponding data type.
24
*/
25
template
<
class
JOutputIterator_t>
26
class
JSTDObjectOutput
:
27
public
JObjectOutput
<typename JOutputIterator_t::container_type::value_type>,
28
public
JObject
< JSTDObjectOutput<JOutputIterator_t> >
29
30
{
31
public
:
32
33
typedef
typename
JOutputIterator_t::container_type::value_type
value_type
;
34
35
36
/**
37
* Constructor.
38
*
39
* \param out output iterator
40
*/
41
JSTDObjectOutput
(
const
JOutputIterator_t&
out
) :
42
out
(
out
)
43
{}
44
45
46
/**
47
* Object output.
48
*
49
* \param object object
50
* \return true
51
*/
52
virtual
bool
put
(
const
value_type
&
object
)
53
{
54
*
out
= object;
55
++
out
;
56
57
return
true
;
58
}
59
60
protected
:
61
JOutputIterator_t
out
;
62
};
63
64
65
/**
66
* Helper method to create STD compatible object output.
67
*
68
* \param buffer output buffer
69
* \return object output
70
*/
71
template
<
class
JElement_t,
class
JAllocator_t>
72
inline
JSTDObjectOutput<std::back_insert_iterator< std::vector<JElement_t, JAllocator_t>
> >
73
getObjectOutput
(
std::vector<JElement_t, JAllocator_t>
& buffer)
74
{
75
return
JSTDObjectOutput<std::back_insert_iterator< std::vector<JElement_t, JAllocator_t>
> >(std::back_inserter(buffer));
76
}
77
78
79
/**
80
* Helper method to create STD compatible object output.
81
*
82
* \param buffer output buffer
83
* \return object output
84
*/
85
template
<
class
JElement_t,
class
JAllocator_t>
86
inline
JSTDObjectOutput<std::back_insert_iterator< std::list<JElement_t, JAllocator_t>
> >
87
getObjectOutput
(
std::list<JElement_t, JAllocator_t>
& buffer)
88
{
89
return
JSTDObjectOutput<std::back_insert_iterator< std::list<JElement_t, JAllocator_t>
> >(std::back_inserter(buffer));
90
}
91
92
93
/**
94
* Helper method to create STD compatible object output.
95
*
96
* \param buffer output buffer
97
* \return object output
98
*/
99
template
<
class
JElement_t,
class
JComparator_t,
class
JAllocator_t>
100
inline
JSTDObjectOutput<std::insert_iterator< std::set<JElement_t, JComparator_t, JAllocator_t>
> >
101
getObjectOutput
(
std::set<JElement_t, JComparator_t, JAllocator_t>
& buffer)
102
{
103
return
JSTDObjectOutput<std::insert_iterator< std::set<JElement_t, JComparator_t, JAllocator_t>
> >(std::inserter(buffer, buffer.end()));
104
}
105
106
107
/**
108
* Helper method to create STD compatible object output.
109
*
110
* \param buffer output buffer
111
* \return object output
112
*/
113
template
<
class
JElement_t,
class
JComparator_t,
class
JAllocator_t>
114
inline
JSTDObjectOutput<std::insert_iterator< std::set<JElement_t, JComparator_t, JAllocator_t>
> >
115
getObjectOutput
(
std::multiset<JElement_t, JComparator_t, JAllocator_t>
& buffer)
116
{
117
return
JSTDObjectOutput<std::insert_iterator< std::set<JElement_t, JComparator_t, JAllocator_t>
> >(std::inserter(buffer, buffer.end()));
118
}
119
120
121
/**
122
* Helper method to create STD compatible object output.
123
*
124
* \param buffer output buffer
125
* \return object output
126
*/
127
template
<
class
JKey_t,
class
JValue_t,
class
JComparator_t,
class
JAllocator_t>
128
inline
JSTDObjectOutput<std::insert_iterator< std::map<JKey_t, JValue_t, JComparator_t, JAllocator_t>
> >
129
getObjectOutput
(
std::map<JKey_t, JValue_t, JComparator_t, JAllocator_t>
& buffer)
130
{
131
return
JSTDObjectOutput<std::insert_iterator< std::map<JKey_t, JValue_t, JComparator_t, JAllocator_t>
> >(std::inserter(buffer, buffer.end()));
132
}
133
134
135
/**
136
* Helper method to create STD compatible object output.
137
*
138
* \param buffer output buffer
139
* \return object output
140
*/
141
template
<
class
JKey_t,
class
JValue_t,
class
JComparator_t,
class
JAllocator_t>
142
inline
JSTDObjectOutput<std::insert_iterator< std::multimap<JKey_t, JValue_t, JComparator_t, JAllocator_t>
> >
143
getObjectOutput
(
std::multimap<JKey_t, JValue_t, JComparator_t, JAllocator_t>
& buffer)
144
{
145
return
JSTDObjectOutput<std::insert_iterator< std::multimap<JKey_t, JValue_t, JComparator_t, JAllocator_t>
> >(std::inserter(buffer, buffer.end()));
146
}
147
}
148
149
#endif
JLANG::JSTDObjectOutput::out
JOutputIterator_t out
Definition:
JSTDObjectOutput.hh:61
JLANG::JObject
Auxiliary base class for inline creation of a static value or clone from a temporary object.
Definition:
JObject.hh:18
std::vector
Definition:
JSTDTypes.hh:12
JSTDTypes.hh
JLANG::JObjectOutput
Forward declarations for definitions of I/O redirect and pipe operators.
Definition:
JObjectIterator.hh:31
std::set
Definition:
JSTDTypes.hh:13
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition:
JAAnetToolkit.hh:37
JLANG::JSTDObjectOutput::value_type
JOutputIterator_t::container_type::value_type value_type
Definition:
JSTDObjectOutput.hh:33
JLANG::JSTDObjectOutput
Implementation of object output for STD compatible output iterator.
Definition:
JSTDObjectOutput.hh:26
std::multiset
Definition:
JSTDTypes.hh:14
JLANG::JSTDObjectOutput::JSTDObjectOutput
JSTDObjectOutput(const JOutputIterator_t &out)
Constructor.
Definition:
JSTDObjectOutput.hh:41
JObject.hh
std::map
Definition:
JSTDTypes.hh:16
JLANG::JSTDObjectOutput::put
virtual bool put(const value_type &object)
Object output.
Definition:
JSTDObjectOutput.hh:52
std::multimap
Definition:
JSTDTypes.hh:17
JLANG::getObjectOutput
JSTDObjectOutput< std::insert_iterator< std::multimap< JKey_t, JValue_t, JComparator_t, JAllocator_t > > > getObjectOutput(std::multimap< JKey_t, JValue_t, JComparator_t, JAllocator_t > &buffer)
Helper method to create STD compatible object output.
Definition:
JSTDObjectOutput.hh:143
std::list
Definition:
JSTDTypes.hh:24
JLANG
Auxiliary classes and methods for language specific functionality.
Definition:
JAbstractClass.hh:10
JObjectOutput.hh
Generated by
1.8.16