00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef STXXL_STREAM__CHOOSE_H_
00014 #define STXXL_STREAM__CHOOSE_H_
00015
00016 #include <stxxl/bits/namespace.h>
00017
00018
00019 __STXXL_BEGIN_NAMESPACE
00020
00022 namespace stream
00023 {
00025
00027
00028 template <class Input_, int Which>
00029 class choose
00030 { };
00031
00038 template <class Input_>
00039 class choose<Input_, 1>
00040 {
00041 Input_ & in;
00042
00043 typedef typename Input_::value_type tuple_type;
00044
00045 public:
00047 typedef typename tuple_type::first_type value_type;
00048
00050 choose(Input_ & in_) : in(in_)
00051 { }
00052
00054 const value_type & operator * () const
00055 {
00056 return (*in).first;
00057 }
00058
00059 const value_type * operator -> () const
00060 {
00061 return &(*in).first;
00062 }
00063
00065 choose & operator ++ ()
00066 {
00067 ++in;
00068 return *this;
00069 }
00070
00072 bool empty() const
00073 {
00074 return in.empty();
00075 }
00076 };
00077
00084 template <class Input_>
00085 class choose<Input_, 2>
00086 {
00087 Input_ & in;
00088
00089 typedef typename Input_::value_type tuple_type;
00090
00091 public:
00093 typedef typename tuple_type::second_type value_type;
00094
00096 choose(Input_ & in_) : in(in_)
00097 { }
00098
00100 const value_type & operator * () const
00101 {
00102 return (*in).second;
00103 }
00104
00105 const value_type * operator -> () const
00106 {
00107 return &(*in).second;
00108 }
00109
00111 choose & operator ++ ()
00112 {
00113 ++in;
00114 return *this;
00115 }
00116
00118 bool empty() const
00119 {
00120 return in.empty();
00121 }
00122 };
00123
00130 template <class Input_>
00131 class choose<Input_, 3>
00132 {
00133 Input_ & in;
00134
00135 typedef typename Input_::value_type tuple_type;
00136
00137 public:
00139 typedef typename tuple_type::third_type value_type;
00140
00142 choose(Input_ & in_) : in(in_)
00143 { }
00144
00146 const value_type & operator * () const
00147 {
00148 return (*in).third;
00149 }
00150
00151 const value_type * operator -> () const
00152 {
00153 return &(*in).third;
00154 }
00155
00157 choose & operator ++ ()
00158 {
00159 ++in;
00160 return *this;
00161 }
00162
00164 bool empty() const
00165 {
00166 return in.empty();
00167 }
00168 };
00169
00176 template <class Input_>
00177 class choose<Input_, 4>
00178 {
00179 Input_ & in;
00180
00181 typedef typename Input_::value_type tuple_type;
00182
00183 public:
00185 typedef typename tuple_type::fourth_type value_type;
00186
00188 choose(Input_ & in_) : in(in_)
00189 { }
00190
00192 const value_type & operator * () const
00193 {
00194 return (*in).fourth;
00195 }
00196
00197 const value_type * operator -> () const
00198 {
00199 return &(*in).fourth;
00200 }
00201
00203 choose & operator ++ ()
00204 {
00205 ++in;
00206 return *this;
00207 }
00208
00210 bool empty() const
00211 {
00212 return in.empty();
00213 }
00214 };
00215
00222 template <class Input_>
00223 class choose<Input_, 5>
00224 {
00225 Input_ & in;
00226
00227 typedef typename Input_::value_type tuple_type;
00228
00229 public:
00231 typedef typename tuple_type::fifth_type value_type;
00232
00234 choose(Input_ & in_) : in(in_)
00235 { }
00236
00238 const value_type & operator * () const
00239 {
00240 return (*in).fifth;
00241 }
00242
00243 const value_type * operator -> () const
00244 {
00245 return &(*in).fifth;
00246 }
00247
00249 choose & operator ++ ()
00250 {
00251 ++in;
00252 return *this;
00253 }
00254
00256 bool empty() const
00257 {
00258 return in.empty();
00259 }
00260 };
00261
00268 template <class Input_>
00269 class choose<Input_, 6>
00270 {
00271 Input_ & in;
00272
00273 typedef typename Input_::value_type tuple_type;
00274
00275 public:
00277 typedef typename tuple_type::sixth_type value_type;
00278
00280 choose(Input_ & in_) : in(in_)
00281 { }
00282
00284 const value_type & operator * () const
00285 {
00286 return (*in).sixth;
00287 }
00288
00289 const value_type * operator -> () const
00290 {
00291 return &(*in).sixth;
00292 }
00293
00295 choose & operator ++ ()
00296 {
00297 ++in;
00298 return *this;
00299 }
00300
00302 bool empty() const
00303 {
00304 return in.empty();
00305 }
00306 };
00307
00308
00310 }
00311
00312 __STXXL_END_NAMESPACE
00313
00314
00315 #include <stxxl/bits/stream/unique.h>
00316
00317
00318 #endif // !STXXL_STREAM__CHOOSE_H_
00319