libzypp  17.25.6
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 
19 namespace zypp
20 {
22  namespace base
23  {
34  template<class Tp, class TUnaryFunction>
36  {
37  typedef Tp RawType;
38  typedef TUnaryFunction Transformator;
39  typedef typename Transformator::result_type TransformedType;
40 
41  public:
43  {}
44 
45  explicit ValueTransform( RawType raw_r )
46  : _raw( std::move(raw_r) )
47  {}
48 
49  ValueTransform( RawType raw_r, Transformator transform_r )
50  : _raw( std::move(raw_r) ), _transform( std::move(transform_r) )
51  {}
52 
53  public:
55  const RawType & raw() const
56  { return _raw; }
57 
60  { return _raw; }
61 
62  public:
65  { return _transform( _raw ); }
66 
68  TransformedType transformed( const RawType & raw_r ) const
69  { return _transform( raw_r ); }
70 
72  const Transformator & transformator() const
73  { return _transform; }
74 
75  private:
78  };
79 
90  template<class TContainer, class TUnaryFunction>
92  {
93  typedef TContainer Container;
94  typedef TUnaryFunction Transformator;
95  typedef typename Container::size_type size_type;
96  typedef typename Container::value_type RawType;
97  typedef typename Transformator::result_type TransformedType;
98 
99  public:
101  {}
102 
103  explicit ContainerTransform( Container raw_r )
104  : _raw( std::move(raw_r) )
105  {}
106 
108  : _raw( std::move(raw_r) ), _transform( std::move(transform_r) )
109  {}
110 
111  public:
112  bool empty() const
113  { return _raw.empty(); }
114 
115  size_type size() const
116  { return _raw.size(); }
117 
118  typedef typename Container::const_iterator RawConstIterator;
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:
135  typedef transform_iterator<Transformator, typename Container::const_iterator> TransformedConstIterator;
136 
138  { return make_transform_iterator( _raw.begin(), _transform ); }
139 
141  { return make_transform_iterator( _raw.end(), _transform ); }
142 
145  { return Container( transformedBegin(), transformedEnd() ); }
146 
148  TransformedType transformed( const RawType & raw_r ) const
149  { return _transform( raw_r ); }
150 
152  TransformedType transformed( const RawConstIterator & rawIter_r ) const
153  { return _transform( *rawIter_r ); }
154 
156  const Transformator & transformator() const
157  { return _transform; }
158 
159  private:
162  };
163 
164  } // namespace base
166 } // namespace zypp
168 #endif // ZYPP_BASE_VALUETRANSFORM_H
zypp::base::ContainerTransform::RawType
Container::value_type RawType
Definition: ValueTransform.h:96
zypp::base::ContainerTransform::Container
TContainer Container
Definition: ValueTransform.h:93
zypp::base::ValueTransform::transformed
TransformedType transformed() const
Return a transformed copy of the raw value.
Definition: ValueTransform.h:64
zypp::base::ContainerTransform::size_type
Container::size_type size_type
Definition: ValueTransform.h:95
zypp::base::ValueTransform::ValueTransform
ValueTransform()
Definition: ValueTransform.h:42
zypp::base::ContainerTransform::_raw
Container _raw
Definition: ValueTransform.h:160
zypp::base::ContainerTransform::transformedBegin
TransformedConstIterator transformedBegin() const
Definition: ValueTransform.h:137
zypp::base::ValueTransform::ValueTransform
ValueTransform(RawType raw_r)
Definition: ValueTransform.h:45
zypp::base::ContainerTransform::ContainerTransform
ContainerTransform(Container raw_r)
Definition: ValueTransform.h:103
zypp::base::ContainerTransform::RawConstIterator
Container::const_iterator RawConstIterator
Definition: ValueTransform.h:118
zypp::base::ContainerTransform::_transform
Transformator _transform
Definition: ValueTransform.h:161
zypp::base::ValueTransform::transformed
TransformedType transformed(const RawType &raw_r) const
Return a transformed copy of an arbitrary RawType.
Definition: ValueTransform.h:68
zypp::base::ValueTransform::transformator
const Transformator & transformator() const
Return the transformator.
Definition: ValueTransform.h:72
zypp::base::ValueTransform::raw
const RawType & raw() const
Get the raw value.
Definition: ValueTransform.h:55
zypp::base::ContainerTransform::TransformedType
Transformator::result_type TransformedType
Definition: ValueTransform.h:97
zypp::base::ValueTransform::Transformator
TUnaryFunction Transformator
Definition: ValueTransform.h:38
zypp::base::ContainerTransform::Transformator
TUnaryFunction Transformator
Definition: ValueTransform.h:94
zypp::base::ContainerTransform::size
size_type size() const
Definition: ValueTransform.h:115
zypp::base::ContainerTransform::transformedEnd
TransformedConstIterator transformedEnd() const
Definition: ValueTransform.h:140
zypp::base::ContainerTransform::raw
const Container & raw() const
Get the raw value.
Definition: ValueTransform.h:127
zypp::base::ContainerTransform::ContainerTransform
ContainerTransform()
Definition: ValueTransform.h:100
zypp::base::ValueTransform::_transform
Transformator _transform
Definition: ValueTransform.h:77
zypp::base::ContainerTransform::transformed
TransformedType transformed(const RawConstIterator &rawIter_r) const
Return a transformed copy of a RawConstIterator raw value.
Definition: ValueTransform.h:152
zypp::base::ContainerTransform::raw
Container & raw()
Set the raw value.
Definition: ValueTransform.h:131
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::base::ValueTransform::_raw
RawType _raw
Definition: ValueTransform.h:76
zypp::base::ContainerTransform::TransformedConstIterator
transform_iterator< Transformator, typename Container::const_iterator > TransformedConstIterator
Definition: ValueTransform.h:135
zypp::base::ContainerTransform
Helper managing a container of raw values with transformed representation.
Definition: ValueTransform.h:92
zypp::base::ValueTransform
Helper managing raw values with transformed representation.
Definition: ValueTransform.h:36
zypp::base::ContainerTransform::transformed
TransformedType transformed(const RawType &raw_r) const
Return a transformed copy of an arbitrary RawType.
Definition: ValueTransform.h:148
zypp::base::ContainerTransform::rawEnd
RawConstIterator rawEnd() const
Definition: ValueTransform.h:123
Iterator.h
zypp::base::ValueTransform::raw
RawType & raw()
Set the raw value.
Definition: ValueTransform.h:59
zypp::base::ContainerTransform::transformed
Container transformed() const
Return copy with transformed variables (expensive)
Definition: ValueTransform.h:144
zypp::base::ContainerTransform::empty
bool empty() const
Definition: ValueTransform.h:112
std
Definition: Arch.h:348
zypp::base::ContainerTransform::rawBegin
RawConstIterator rawBegin() const
Definition: ValueTransform.h:120
zypp::repo::RepoVariablesUrlReplacer
Functor replacing repository variables.
Definition: RepoVariables.h:120
zypp::base::ValueTransform::ValueTransform
ValueTransform(RawType raw_r, Transformator transform_r)
Definition: ValueTransform.h:49
zypp::sat::detail::size_type
SolvableIdType size_type
Definition: PoolMember.h:126
zypp::base::ValueTransform::TransformedType
Transformator::result_type TransformedType
Definition: ValueTransform.h:39
zypp::Url
Url manipulation class.
Definition: Url.h:92
zypp::base::ContainerTransform::ContainerTransform
ContainerTransform(Container raw_r, Transformator transform_r)
Definition: ValueTransform.h:107
zypp::base::ValueTransform::RawType
Tp RawType
Definition: ValueTransform.h:37
zypp::base::ContainerTransform::transformator
const Transformator & transformator() const
Return the transformator.
Definition: ValueTransform.h:156