Scopira  20080306
iterator_imp.h
1 
2 /*
3  * Copyright (c) 2002 National Research Council
4  *
5  * All rights reserved.
6  *
7  * This material is confidential and proprietary information of
8  * National Research Council Canada ("Confidential Information").
9  * This Confidential Information may only be used and reproduced
10  * in accordance with the terms of the license agreement.
11  *
12  */
13 
14 #ifndef __INCLUDED__SCOPIRA_TOOL_ITERATOR_IMP_H__
15 #define __INCLUDED__SCOPIRA_TOOL_ITERATOR_IMP_H__
16 
17 // the following is for developers who want to quickly build
18 // iterator_imps from stl based ones
19 
20 #include <scopira/tool/iterator.h>
21 
22 namespace scopira
23 {
24  namespace tool
25  {
26  template <class T> struct deref {
27  typedef T in_type;
28  T operator()(T r) const { return r; }
29  };
30  template <class TOUT, class DEF, class TIN = typename DEF::in_type > struct deref_first {
31  typedef TIN in_type;
32  TOUT operator()(TIN r) { return DEF()(r).first; }
33  };
34  template <class TOUT, class DEF, class TIN = typename DEF::in_type > struct deref_second {
35  typedef TIN in_type;
36  TOUT operator()(TIN r) { return DEF()(r).second; }
37  };
38  template <class TOUT, class DEF, class TIN = typename DEF::in_type > struct deref_ptr {
39  typedef TIN in_type;
40  TOUT operator()(TIN a) { return *DEF()(a); }
41  };
42  template <class TOUT, class DEF, class TIN = typename DEF::in_type > struct deref_objauto {
43  typedef TIN in_type;
44  TOUT operator()(TIN a) { return DEF()(a).get(); }
45  };
46  template <class ITER, class T, class DEF > class stl_iterator_imp_g;
47 
48  // utlity for for_each
49  }
50 }
51 
57 template <class ITER, class T, class DEF> class scopira::tool::stl_iterator_imp_g
59 {
60  protected:
61  ITER m_current, m_end;
62 
63  public:
64  stl_iterator_imp_g(const ITER & _start, const ITER & _end)
65  : m_current(_start), m_end(_end) { }
67  virtual T current(void) {
68  return DEF()(*m_current);
69  }
71  virtual bool valid(void) const {
72  return m_current != m_end;
73  }
75  virtual void next(void) {
76  m_current++;
77  }
78 };
79 
80 #endif
81 
virtual bool valid(void) const
is there a next one?
Definition: iterator_imp.h:71
Definition: iterator_imp.h:38
Definition: iterator_imp.h:30
virtual void next(void)
advance to the next item
Definition: iterator_imp.h:75
Definition: archiveflow.h:20
virtual T current(void)
gets the current item
Definition: iterator_imp.h:67
Definition: iterator_imp.h:46
Definition: iterator_imp.h:42
Definition: iterator_imp.h:26
Definition: iterator_imp.h:34
Definition: iterator.h:31