Class: RPM::MatchIterator

Inherits:
Data
  • Object
show all
Includes:
Enumerable
Defined in:
ext/rpm/db.c

Instance Method Summary collapse

Instance Method Details

#countObject



1183
1184
1185
1186
1187
# File 'ext/rpm/db.c', line 1183

VALUE
rpm_mi_get_iterator_count(VALUE mi)
{
	return INT2NUM(rpmdbGetIteratorCount(RPM_MI(mi)));
}

#eachObject



1231
1232
1233
1234
1235
1236
1237
1238
# File 'ext/rpm/db.c', line 1231

VALUE
rpm_mi_each(VALUE mi)
{
	VALUE p;
	while(!NIL_P( p = rpm_mi_next_iterator(mi)))
		rb_yield (p);
        return Qnil;
}

#get_iterator_countObject



1183
1184
1185
1186
1187
# File 'ext/rpm/db.c', line 1183

VALUE
rpm_mi_get_iterator_count(VALUE mi)
{
	return INT2NUM(rpmdbGetIteratorCount(RPM_MI(mi)));
}

#lengthObject



1183
1184
1185
1186
1187
# File 'ext/rpm/db.c', line 1183

VALUE
rpm_mi_get_iterator_count(VALUE mi)
{
	return INT2NUM(rpmdbGetIteratorCount(RPM_MI(mi)));
}

#next_iteratorObject



1173
1174
1175
1176
1177
1178
1179
1180
1181
# File 'ext/rpm/db.c', line 1173

VALUE
rpm_mi_next_iterator(VALUE mi)
{
	Header hdr;
	hdr = rpmdbNextIterator(RPM_MI(mi));
	if (hdr)
		return rpm_package_new_from_header(hdr);
	return Qnil;
}

#offsetObject



1189
1190
1191
1192
1193
1194
1195
1196
# File 'ext/rpm/db.c', line 1189

VALUE
rpm_mi_get_iterator_offset(VALUE mi)
{
	int off = rpmdbGetIteratorOffset(RPM_MI(mi));
	if (off)
		return INT2NUM(off);
	return Qnil;
}

#regexp(tag, mode, re) ⇒ Object



1198
1199
1200
1201
1202
1203
1204
1205
1206
# File 'ext/rpm/db.c', line 1198

VALUE
rpm_mi_set_iterator_re(VALUE mi,VALUE tag, VALUE mode, VALUE re)
{
	if (TYPE(re) != T_STRING)
		rb_raise(rb_eTypeError, "illegal argument type");

	rpmdbSetIteratorRE(RPM_MI(mi),NUM2INT(tag),NUM2INT(mode),RSTRING_PTR(re));
	return mi;
}

#set_iterator_re(tag, mode, re) ⇒ Object



1198
1199
1200
1201
1202
1203
1204
1205
1206
# File 'ext/rpm/db.c', line 1198

VALUE
rpm_mi_set_iterator_re(VALUE mi,VALUE tag, VALUE mode, VALUE re)
{
	if (TYPE(re) != T_STRING)
		rb_raise(rb_eTypeError, "illegal argument type");

	rpmdbSetIteratorRE(RPM_MI(mi),NUM2INT(tag),NUM2INT(mode),RSTRING_PTR(re));
	return mi;
}

#set_iterator_version(version) ⇒ Object



1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
# File 'ext/rpm/db.c', line 1208

VALUE
rpm_mi_set_iterator_version(VALUE mi, VALUE version)
{
/* Epoch!! */
	VALUE r;
	if (rb_obj_is_kind_of(version, rpm_cVersion) == Qfalse)
		rb_raise(rb_eTypeError, "illegal argument type");
#if RPM_VERSION_CODE < RPM_VERSION(4,1,0)
	rpmdbSetIteratorVersion(RPM_MI(mi),RSTRING_PTR(rpm_version_get_v(version)));
#else
	rpmdbSetIteratorRE(RPM_MI(mi),RPMTAG_VERSION,RPMMIRE_DEFAULT,RSTRING_PTR(rpm_version_get_v(version)));
#endif
	r = rpm_version_get_r(version);
	if(!NIL_P(r)){
#if RPM_VERSION_CODE < RPM_VERSION(4,1,0)
		rpmdbSetIteratorRelease(RPM_MI(mi),RSTRING_PTR(r));
#else
		rpmdbSetIteratorRE(RPM_MI(mi),RPMTAG_RELEASE,RPMMIRE_DEFAULT,RSTRING_PTR(r));
#endif
	}
	return mi;
}

#version(version) ⇒ Object



1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
# File 'ext/rpm/db.c', line 1208

VALUE
rpm_mi_set_iterator_version(VALUE mi, VALUE version)
{
/* Epoch!! */
	VALUE r;
	if (rb_obj_is_kind_of(version, rpm_cVersion) == Qfalse)
		rb_raise(rb_eTypeError, "illegal argument type");
#if RPM_VERSION_CODE < RPM_VERSION(4,1,0)
	rpmdbSetIteratorVersion(RPM_MI(mi),RSTRING_PTR(rpm_version_get_v(version)));
#else
	rpmdbSetIteratorRE(RPM_MI(mi),RPMTAG_VERSION,RPMMIRE_DEFAULT,RSTRING_PTR(rpm_version_get_v(version)));
#endif
	r = rpm_version_get_r(version);
	if(!NIL_P(r)){
#if RPM_VERSION_CODE < RPM_VERSION(4,1,0)
		rpmdbSetIteratorRelease(RPM_MI(mi),RSTRING_PTR(r));
#else
		rpmdbSetIteratorRE(RPM_MI(mi),RPMTAG_RELEASE,RPMMIRE_DEFAULT,RSTRING_PTR(r));
#endif
	}
	return mi;
}