libzypp 17.35.1
ValueTransform.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
11#ifndef ZYPP_BASE_VALUETRANSFORM_H
12#define ZYPP_BASE_VALUETRANSFORM_H
13
14#include <iosfwd>
15
16#include <zypp/base/Iterator.h>
17
19namespace zypp
20{
22 namespace base
23 {
34 template<class Tp, class TUnaryFunction>
36 {
37 using RawType = Tp;
38 using Transformator = TUnaryFunction;
40
41 public:
44
46 : _raw( std::move(raw_r) )
47 {}
48
52
53 public:
55 const RawType & raw() const
56 { return _raw; }
57
60 { return _raw; }
61
62 public:
65 { return _transform( _raw ); }
66
69 { return _transform( raw_r ); }
70
73 { return _transform; }
74
75 private:
78 };
79
90 template<class TContainer, class TUnaryFunction>
92 {
93 using Container = TContainer;
94 using Transformator = TUnaryFunction;
95 using size_type = typename Container::size_type;
96 using RawType = typename Container::value_type;
98
99 public:
102
104 : _raw( std::move(raw_r) )
105 {}
106
110
111 public:
112 bool empty() const
113 { return _raw.empty(); }
114
116 { return _raw.size(); }
117
118 using RawConstIterator = typename Container::const_iterator;
119
121 { return _raw.begin(); }
122
124 { return _raw.end(); }
125
127 const Container & raw() const
128 { return _raw; }
129
132 { return _raw; }
133
134 public:
136
138 { return make_transform_iterator( _raw.begin(), _transform ); }
139
141 { return make_transform_iterator( _raw.end(), _transform ); }
142
146
149 { return _transform( raw_r ); }
150
154
157 { return _transform; }
158
159 private:
162 };
163
164 } // namespace base
166} // namespace zypp
168#endif // ZYPP_BASE_VALUETRANSFORM_H
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
Definition Arch.h:364
typename result_of< T >::type result_of_t
Definition TypeTraits.h:51
Easy-to use interface to the ZYPP dependency resolver.
Helper managing a container of raw values with transformed representation.
TransformedType transformed(const RawConstIterator &rawIter_r) const
Return a transformed copy of a RawConstIterator raw value.
TransformedConstIterator transformedBegin() const
Container transformed() const
Return copy with transformed variables (expensive)
const Container & raw() const
Get the raw value.
std::result_of_t< Transformator(RawType)> TransformedType
typename Container::size_type size_type
RawConstIterator rawBegin() const
RawConstIterator rawEnd() const
typename Container::value_type RawType
const Transformator & transformator() const
Return the transformator.
TransformedType transformed(const RawType &raw_r) const
Return a transformed copy of an arbitrary RawType.
typename Container::const_iterator RawConstIterator
TransformedConstIterator transformedEnd() const
Container & raw()
Set the raw value.
ContainerTransform(Container raw_r, Transformator transform_r)
Helper managing raw values with transformed representation.
ValueTransform(RawType raw_r, Transformator transform_r)
std::result_of_t< Transformator(RawType)> TransformedType
const RawType & raw() const
Get the raw value.
TransformedType transformed() const
Return a transformed copy of the raw value.
RawType & raw()
Set the raw value.
const Transformator & transformator() const
Return the transformator.
TransformedType transformed(const RawType &raw_r) const
Return a transformed copy of an arbitrary RawType.