Tizen 2.1 base
[external/libzypp-bindings.git] / swig / ResPool.i
1 // missing resfilter:: to call these
2 %ignore zypp::ResPool::byKindBegin;
3 %ignore zypp::ResPool::byKindEnd;
4 %ignore zypp::ResPool::byNameBegin;
5 %ignore zypp::ResPool::byNameEnd;
6 %apply unsigned { zypp::ResPool::size_type };
7 %include <zypp/ResPool.h>
8
9 %ignore zypp::pool::operator<<;
10 %include <zypp/pool/GetResolvablesToInsDel.h>
11 namespace zypp
12 {
13   typedef ::std::list<zyppPoolItem> PoolItemList;
14   %template(PoolItemList) ::std::list<PoolItem>;
15 }
16
17 namespace zypp
18 {
19
20 #ifdef SWIGPERL5
21
22 iter2(ResPool, PoolItem);
23
24 #endif
25
26 #ifdef SWIGRUBY
27
28 iter3(ResPool, PoolItem*);
29
30 // %extend ResPool {
31 //     void each()
32 //     {
33 //         ResPool::const_iterator i = self->begin();
34 //         while ( i != self->end() ) {
35 //             rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_PoolItem, 0));
36 //             ++i;
37 //         }
38 //     }
39 // }
40
41 %extend ResPool {
42     void each_by_kind( const ResObject::Kind & kind_r )
43     {
44         ResPool::byKind_iterator i = self->byKindBegin( kind_r );
45         while ( i != self->byKindEnd( kind_r ) ) {
46             rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_PoolItem, 0));
47             ++i;
48         }
49     }
50 }
51
52 %extend ResPool {
53     void each_by_name( const std::string &name )
54     {
55         ResPool::byName_iterator i = self->byNameBegin( name );
56         while ( i != self->byNameEnd( name ) ) {
57             rb_yield( SWIG_NewPointerObj( (void *) &*i, $descriptor(PoolItem), 0));
58             ++i;
59         }
60     }
61 }
62
63 #endif
64
65 #ifdef SWIGPYTHON
66 %newobject ResPool::const_iterator(PyObject **PYTHON_SELF);
67 %extend  ResPool {
68   swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF)
69   {
70     return swig::make_output_iterator(self->begin(), self->begin(),
71                                       self->end(), *PYTHON_SELF);
72   }
73   swig::SwigPyIterator* kinditerator(PyObject **PYTHON_SELF, const ResObject::Kind & kind_r)
74   {
75     return swig::make_output_iterator(self->byKindBegin( kind_r ), self->byKindBegin( kind_r ),
76                                       self->byKindEnd( kind_r ), *PYTHON_SELF);
77   }
78   swig::SwigPyIterator* nameiterator(PyObject **PYTHON_SELF, const std::string &name)
79   {
80     return swig::make_output_iterator(self->byNameBegin( name ), self->byNameBegin( name ),
81                                       self->byNameEnd( name ), *PYTHON_SELF);
82   }
83 %pythoncode {
84   def __iter__(self): return self.iterator()
85   def byKindIterator(self, kind): return self.kinditerator(kind)
86   def byNameIterator(self, name): return self.nameiterator(name)
87 }
88 }
89
90 #endif
91
92 }