Bump to libzypp-bindings 0.7.4
[platform/upstream/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 %ignore zypp::ResPool::byStatus;
7 %ignore zypp::ResPool::byStatusBegin;
8 %ignore zypp::ResPool::byStatusEnd;
9 %apply unsigned { zypp::ResPool::size_type };
10 %include <zypp/ResPool.h>
11
12 %ignore zypp::pool::operator<<;
13 %include "legacy/GetResolvablesToInsDel.h"
14 namespace zypp
15 {
16   typedef ::std::list<zyppPoolItem> PoolItemList;
17   %template(PoolItemList) ::std::list<PoolItem>;
18 }
19
20 namespace zypp
21 {
22
23 #ifdef SWIGPYTHON
24 namespace sat
25 {
26 %extend  Pool {
27   std::string loadSolvFile(std::string _solv, std::string _alias)
28   {
29     RepoInfo tmpRepo;
30     tmpRepo.setAlias(_alias);
31
32     try {
33       addRepoSolv(_solv, tmpRepo);
34     } catch ( const Exception & e ) {
35       return e.msg();
36     }
37
38     return std::string();
39   }
40 }
41 }
42 #endif
43
44 %extend ResPool {
45   pool::GetResolvablesToInsDel getTransaction()
46   {
47     return pool::GetResolvablesToInsDel( *self );
48   }
49 }
50
51
52 #ifdef SWIGPERL5
53
54 iter2(ResPool, PoolItem);
55
56 #endif
57
58 #ifdef SWIGRUBY
59
60 iter3(ResPool, zypp::PoolItem*);
61
62 // %extend ResPool {
63 //     void each()
64 //     {
65 //         ResPool::const_iterator i = self->begin();
66 //         while ( i != self->end() ) {
67 //             rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_zypp__PoolItem, 0));
68 //             ++i;
69 //         }
70 //     }
71 // }
72
73 %extend ResPool {
74     void each_by_kind( const ResKind & kind_r )
75     {
76         ResPool::byKind_iterator i = self->byKindBegin( kind_r );
77         while ( i != self->byKindEnd( kind_r ) ) {
78             rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_zypp__PoolItem, 0));
79             ++i;
80         }
81     }
82 }
83
84 %extend ResPool {
85     void each_by_name( const std::string &name )
86     {
87         ResPool::byName_iterator i = self->byNameBegin( name );
88         while ( i != self->byNameEnd( name ) ) {
89             rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_zypp__PoolItem, 0));
90             ++i;
91         }
92     }
93 }
94
95 #endif
96
97 #ifdef SWIGPYTHON
98 %newobject ResPool::const_iterator(PyObject **PYTHON_SELF);
99 %extend  ResPool {
100 #if SWIG_VERSION > 0x010336
101   swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF)
102 #else
103   swig::PySwigIterator* iterator(PyObject **PYTHON_SELF)
104 #endif
105   {
106     return swig::make_output_iterator(self->begin(), self->begin(),
107                                       self->end(), *PYTHON_SELF);
108   }
109 #if SWIG_VERSION > 0x010336
110   swig::SwigPyIterator* kinditerator(PyObject **PYTHON_SELF, const ResObject::Kind & kind_r)
111 #else
112   swig::PySwigIterator* kinditerator(PyObject **PYTHON_SELF, const ResObject::Kind & kind_r)
113 #endif
114   {
115     return swig::make_output_iterator(self->byKindBegin( kind_r ), self->byKindBegin( kind_r ),
116                                       self->byKindEnd( kind_r ), *PYTHON_SELF);
117   }
118 #if SWIG_VERSION > 0x010336
119   swig::SwigPyIterator* nameiterator(PyObject **PYTHON_SELF, const std::string &name)
120 #else
121   swig::PySwigIterator* nameiterator(PyObject **PYTHON_SELF, const std::string &name)
122 #endif
123   {
124     return swig::make_output_iterator(self->byNameBegin( name ), self->byNameBegin( name ),
125                                       self->byNameEnd( name ), *PYTHON_SELF);
126   }
127 %pythoncode {
128   def __iter__(self): return self.iterator()
129   def byKindIterator(self, kind): return self.kinditerator(kind)
130   def byNameIterator(self, name): return self.nameiterator(name)
131 }
132 }
133
134 #endif
135
136 }