summaryrefslogtreecommitdiff
path: root/swig/ResPool.i
blob: 8c1c45f0b407939c2a7150a2a72167e81115d736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// missing resfilter:: to call these
%ignore zypp::ResPool::byKindBegin;
%ignore zypp::ResPool::byKindEnd;
%ignore zypp::ResPool::byNameBegin;
%ignore zypp::ResPool::byNameEnd;
%apply unsigned { zypp::ResPool::size_type };
%include <zypp/ResPool.h>

%ignore zypp::pool::operator<<;
%include "legacy/GetResolvablesToInsDel.h"
namespace zypp
{
  typedef ::std::list<zyppPoolItem> PoolItemList;
  %template(PoolItemList) ::std::list<PoolItem>;
}

namespace zypp
{
%extend ResPool {
  pool::GetResolvablesToInsDel getTransaction()
  {
    return pool::GetResolvablesToInsDel( *self );
  }
}


#ifdef SWIGPERL5

iter2(ResPool, PoolItem);

#endif

#ifdef SWIGRUBY

iter3(ResPool, zypp::PoolItem*);

// %extend ResPool {
//     void each()
//     {
//         ResPool::const_iterator i = self->begin();
//         while ( i != self->end() ) {
//             rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_zypp__PoolItem, 0));
//             ++i;
//         }
//     }
// }

%extend ResPool {
    void each_by_kind( const ResKind & kind_r )
    {
        ResPool::byKind_iterator i = self->byKindBegin( kind_r );
        while ( i != self->byKindEnd( kind_r ) ) {
            rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_zypp__PoolItem, 0));
            ++i;
        }
    }
}

%extend ResPool {
    void each_by_name( const std::string &name )
    {
        ResPool::byName_iterator i = self->byNameBegin( name );
        while ( i != self->byNameEnd( name ) ) {
            rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_zypp__PoolItem, 0));
            ++i;
        }
    }
}

#endif

#ifdef SWIGPYTHON
%newobject ResPool::const_iterator(PyObject **PYTHON_SELF);
%extend  ResPool {
#if SWIG_VERSION > 0x010336
  swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF)
#else
  swig::PySwigIterator* iterator(PyObject **PYTHON_SELF)
#endif
  {
    return swig::make_output_iterator(self->begin(), self->begin(),
                                      self->end(), *PYTHON_SELF);
  }
#if SWIG_VERSION > 0x010336
  swig::SwigPyIterator* kinditerator(PyObject **PYTHON_SELF, const ResObject::Kind & kind_r)
#else
  swig::PySwigIterator* kinditerator(PyObject **PYTHON_SELF, const ResObject::Kind & kind_r)
#endif
  {
    return swig::make_output_iterator(self->byKindBegin( kind_r ), self->byKindBegin( kind_r ),
                                      self->byKindEnd( kind_r ), *PYTHON_SELF);
  }
#if SWIG_VERSION > 0x010336
  swig::SwigPyIterator* nameiterator(PyObject **PYTHON_SELF, const std::string &name)
#else
  swig::PySwigIterator* nameiterator(PyObject **PYTHON_SELF, const std::string &name)
#endif
  {
    return swig::make_output_iterator(self->byNameBegin( name ), self->byNameBegin( name ),
                                      self->byNameEnd( name ), *PYTHON_SELF);
  }
%pythoncode {
  def __iter__(self): return self.iterator()
  def byKindIterator(self, kind): return self.kinditerator(kind)
  def byNameIterator(self, name): return self.nameiterator(name)
}
}

#endif

}