From b8d3888fdcb2c625f9c025db9ca858ec8199d562 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Thu, 3 Apr 2014 16:20:28 +0200 Subject: [PATCH] INCOMPATIBLE bindings change: modernize Dataiterator/Datamatch classes Use attributes instead of methods to access the matched data (except for Datapos constructors). Also, while we're breaking the API, drop the solvid argument from the Dataiterator constructors. Add different constructors for the special cases. Also fix and document Datamatcher's 'binary' attribute. --- bindings/solv.i | 98 ++++++++++++++++++++----------- doc/libsolv-bindings.3 | 148 ++++++++++++++++++++++++++++++++--------------- doc/libsolv-bindings.txt | 118 +++++++++++++++++++++++-------------- examples/p5solv | 8 +-- examples/pysolv | 10 ++-- examples/rbsolv | 8 +-- 6 files changed, 251 insertions(+), 139 deletions(-) diff --git a/bindings/solv.i b/bindings/solv.i index 54b6022..eab2430 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -51,6 +51,9 @@ typedef struct { $result = $1.data ? Py_BuildValue("y#", $1.data, $1.len) : SWIG_Py_Void(); #else $result = SWIG_FromCharPtrAndSize($1.data, $1.len); +#if defined(SWIGPERL) + argvi++; +#endif #endif } @@ -1041,6 +1044,9 @@ typedef struct { solv_bin2hex(b, l, ret); return ret; } + const char *typestr() { + return solv_chksum_type2str(solv_chksum_get_type($self)); + } bool __eq__(Chksum *chk) { int l; @@ -1255,7 +1261,11 @@ typedef struct { } %newobject Dataiterator; - Dataiterator *Dataiterator(Id p, Id key, const char *match = 0, int flags = 0) { + Dataiterator *Dataiterator(Id key, const char *match = 0, int flags = 0) { + return new_Dataiterator($self, 0, 0, key, match, flags); + } + %newobject Dataiterator_solvid; + Dataiterator *Dataiterator_solvid(Id p, Id key, const char *match = 0, int flags = 0) { return new_Dataiterator($self, 0, p, key, match, flags); } const char *solvid2str(Id solvid) { @@ -1591,8 +1601,12 @@ rb_eval_string( } %newobject Dataiterator; - Dataiterator *Dataiterator(Id p, Id key, const char *match = 0, int flags = 0) { - return new_Dataiterator($self->pool, $self, p, key, match, flags); + Dataiterator *Dataiterator(Id key, const char *match = 0, int flags = 0) { + return new_Dataiterator($self->pool, $self, 0, key, match, flags); + } + %newobject Dataiterator_meta; + Dataiterator *Dataiterator_meta(Id key, const char *match = 0, int flags = 0) { + return new_Dataiterator($self->pool, $self, SOLVID_META, key, match, flags); } Id const id; @@ -1877,57 +1891,67 @@ rb_eval_string( } %newobject solvable; XSolvable * const solvable; + Id const key_id; + const char * const key_idstr; + Id const type_id; + const char * const type_idstr; + Id const id; + const char * const idstr; + const char * const str; + BinaryBlob const binary; + unsigned long long const num; + unsigned int const num2; %{ SWIGINTERN XSolvable *Datamatch_solvable_get(Dataiterator *di) { return new_XSolvable(di->pool, di->solvid); } - %} - Id key_id() { - return $self->key->name; + SWIGINTERN Id Datamatch_key_id_get(Dataiterator *di) { + return di->key->name; } - const char *key_idstr() { - return pool_id2str($self->pool, $self->key->name); + SWIGINTERN const char *Datamatch_key_idstr_get(Dataiterator *di) { + return pool_id2str(di->pool, di->key->name); } - Id type_id() { - return $self->key->type; + SWIGINTERN Id Datamatch_type_id_get(Dataiterator *di) { + return di->key->type; } - const char *type_idstr() { - return pool_id2str($self->pool, $self->key->type); + SWIGINTERN const char *Datamatch_type_idstr_get(Dataiterator *di) { + return pool_id2str(di->pool, di->key->type); } - Id id() { - return $self->kv.id; + SWIGINTERN Id Datamatch_id_get(Dataiterator *di) { + return di->kv.id; } - const char *idstr() { - if ($self->data && ($self->key->type == REPOKEY_TYPE_DIR || $self->key->type == REPOKEY_TYPE_DIRSTRARRAY || $self->key->type == REPOKEY_TYPE_DIRNUMNUMARRAY)) - return repodata_dir2str($self->data, $self->kv.id, 0); - if ($self->data && $self->data->localpool) - return stringpool_id2str(&self->data->spool, $self->kv.id); - return pool_id2str($self->pool, $self->kv.id); + SWIGINTERN const char *Datamatch_idstr_get(Dataiterator *di) { + if (di->data && (di->key->type == REPOKEY_TYPE_DIR || di->key->type == REPOKEY_TYPE_DIRSTRARRAY || di->key->type == REPOKEY_TYPE_DIRNUMNUMARRAY)) + return repodata_dir2str(di->data, di->kv.id, 0); + if (di->data && di->data->localpool) + return stringpool_id2str(&di->data->spool, di->kv.id); + return pool_id2str(di->pool, di->kv.id); } - const char *str() { - return $self->kv.str; + SWIGINTERN const char * const Datamatch_str_get(Dataiterator *di) { + return di->kv.str; } - BinaryBlob binary() { + SWIGINTERN BinaryBlob Datamatch_binary_get(Dataiterator *di) { BinaryBlob bl; bl.data = 0; bl.len = 0; - if ($self->key->type == REPOKEY_TYPE_BINARY) + if (di->key->type == REPOKEY_TYPE_BINARY) { - bl.data = $self->kv.str; - bl.len = $self->kv.num; + bl.data = di->kv.str; + bl.len = di->kv.num; } - else if ((bl.len = solv_chksum_len($self->key->type)) != 0) - bl.data = $self->kv.str; + else if ((bl.len = solv_chksum_len(di->key->type)) != 0) + bl.data = di->kv.str; return bl; } - unsigned long long num() { - if ($self->key->type == REPOKEY_TYPE_NUM) - return SOLV_KV_NUM64(&$self->kv); - return $self->kv.num; + SWIGINTERN unsigned long long Datamatch_num_get(Dataiterator *di) { + if (di->key->type == REPOKEY_TYPE_NUM) + return SOLV_KV_NUM64(&di->kv); + return di->kv.num; } - int num2() { - return $self->kv.num2; + SWIGINTERN unsigned int Datamatch_num2_get(Dataiterator *di) { + return di->kv.num2; } + %} %newobject pos; Datapos *pos() { Pool *pool = $self->pool; @@ -1949,7 +1973,11 @@ rb_eval_string( return pos; } #if defined(SWIGPERL) - %rename("str") __str__; + /* cannot use str here because swig reports a bogus conflict... */ + %rename("stringify") __str__; + %perlcode { + *solv::Datamatch::str = *solvc::Datamatch_stringify; + } #endif const char *__str__() { KeyValue kv = $self->kv; diff --git a/doc/libsolv-bindings.3 b/doc/libsolv-bindings.3 index dd7519f..7a9cf54 100644 --- a/doc/libsolv-bindings.3 +++ b/doc/libsolv-bindings.3 @@ -2,12 +2,12 @@ .\" Title: Libsolv-Bindings .\" Author: [see the "Author" section] .\" Generator: DocBook XSL Stylesheets v1.78.0 -.\" Date: 03/26/2014 +.\" Date: 04/03/2014 .\" Manual: LIBSOLV .\" Source: libsolv .\" Language: English .\" -.TH "LIBSOLV\-BINDINGS" "3" "03/26/2014" "libsolv" "LIBSOLV" +.TH "LIBSOLV\-BINDINGS" "3" "04/03/2014" "libsolv" "LIBSOLV" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -1003,7 +1003,20 @@ Lookup functions\&. Return the data element stored in the specified solvable\&. .RS 4 .\} .nf -\fBDataiterator Dataiterator(Id\fR \fIsolvid\fR\fB, Id\fR \fIkeyname\fR\fB, const char *\fR\fImatch\fR \fB= 0, int\fR \fIflags\fR \fB= 0)\fR +\fBDataiterator Dataiterator(Id\fR \fIkeyname\fR\fB, const char *\fR\fImatch\fR \fB= 0, int\fR \fIflags\fR \fB= 0)\fR +my \fI$di\fR \fB=\fR \fI$pool\fR\fB\->Dataiterator(\fR\fI$keyname\fR\fB,\fR \fI$match\fR\fB,\fR \fI$flags\fR\fB)\fR; +\fIdi\fR \fB=\fR \fIpool\fR\fB\&.Dataiterator(\fR\fIkeyname\fR\fB,\fR \fImatch\fR\fB,\fR \fIflags\fR\fB)\fR +\fIdi\fR \fB=\fR \fIpool\fR\fB\&.Dataiterator(\fR\fIkeyname\fR\fB,\fR \fImatch\fR\fB,\fR \fIflags\fR\fB)\fR +.fi +.if n \{\ +.RE +.\} +.sp +.if n \{\ +.RS 4 +.\} +.nf +\fBDataiterator Dataiterator_solvid(Id\fR \fIsolvid\fR\fB, Id\fR \fIkeyname\fR\fB, const char *\fR\fImatch\fR \fB= 0, int\fR \fIflags\fR \fB= 0)\fR my \fI$di\fR \fB=\fR \fI$pool\fR\fB\->Dataiterator(\fR\fI$solvid\fR\fB,\fR \fI$keyname\fR\fB,\fR \fI$match\fR\fB,\fR \fI$flags\fR\fB)\fR; \fIdi\fR \fB=\fR \fIpool\fR\fB\&.Dataiterator(\fR\fIsolvid\fR\fB,\fR \fIkeyname\fR\fB,\fR \fImatch\fR\fB,\fR \fIflags\fR\fB)\fR \fIdi\fR \fB=\fR \fIpool\fR\fB\&.Dataiterator(\fR\fIsolvid\fR\fB,\fR \fIkeyname\fR\fB,\fR \fImatch\fR\fB,\fR \fIflags\fR\fB)\fR @@ -1024,7 +1037,7 @@ my \fI$di\fR \fB=\fR \fI$pool\fR\fB\->Dataiterator(\fR\fI$solvid\fR\fB,\fR \fI$k .RE .\} .sp -Iterate over the matching data elements\&. See the Dataiterator class for more information\&. +Iterate over the matching data elements\&. See the Dataiterator class for more information\&. The Dataiterator method iterates over all solvables in the pool, whereas the Dataiterator_solvid only iterates over the specified solvable\&. .SS "ID METHODS" .sp The following methods deal with Ids, i\&.e\&. integers representing objects in the pool\&. They are considered \(lqlow level\(rq, in most cases you would not use them but instead the object orientated methods\&. @@ -1626,10 +1639,23 @@ Create a Selection consisting of all packages in the repository\&. .RS 4 .\} .nf -\fBDataiterator Dataiterator(Id\fR \fIp\fR\fB, Id\fR \fIkey\fR\fB, const char *\fR\fImatch\fR \fB= 0, int\fR \fIflags\fR \fB= 0)\fR -my \fI$di\fR \fB=\fR \fI$repo\fR\fB\->Dataiterator(\fR\fI$solvid\fR\fB,\fR \fI$keyname\fR\fB,\fR \fI$match\fR\fB,\fR \fI$flags\fR\fB)\fR; -\fIdi\fR \fB=\fR \fIrepo\fR\fB\&.Dataiterator(\fR\fIsolvid\fR\fB,\fR \fIkeyname\fR\fB,\fR \fImatch\fR\fB,\fR \fIflags\fR\fB)\fR -\fIdi\fR \fB=\fR \fIrepo\fR\fB\&.Dataiterator(\fR\fIsolvid\fR\fB,\fR \fIkeyname\fR\fB,\fR \fImatch\fR\fB,\fR \fIflags\fR\fB)\fR +\fBDataiterator Dataiterator(Id\fR \fIkey\fR\fB, const char *\fR\fImatch\fR \fB= 0, int\fR \fIflags\fR \fB= 0)\fR +my \fI$di\fR \fB=\fR \fI$repo\fR\fB\->Dataiterator(\fR\fI$keyname\fR\fB,\fR \fI$match\fR\fB,\fR \fI$flags\fR\fB)\fR; +\fIdi\fR \fB=\fR \fIrepo\fR\fB\&.Dataiterator(\fR\fIkeyname\fR\fB,\fR \fImatch\fR\fB,\fR \fIflags\fR\fB)\fR +\fIdi\fR \fB=\fR \fIrepo\fR\fB\&.Dataiterator(\fR\fIkeyname\fR\fB,\fR \fImatch\fR\fB,\fR \fIflags\fR\fB)\fR +.fi +.if n \{\ +.RE +.\} +.sp +.if n \{\ +.RS 4 +.\} +.nf +\fBDataiterator Dataiterator_meta(Id\fR \fIkey\fR\fB, const char *\fR\fImatch\fR \fB= 0, int\fR \fIflags\fR \fB= 0)\fR +my \fI$di\fR \fB=\fR \fI$repo\fR\fB\->Dataiterator_meta(\fR\fI$keyname\fR\fB,\fR \fI$match\fR\fB,\fR \fI$flags\fR\fB)\fR; +\fIdi\fR \fB=\fR \fIrepo\fR\fB\&.Dataiterator_meta(\fR\fIkeyname\fR\fB,\fR \fImatch\fR\fB,\fR \fIflags\fR\fB)\fR +\fIdi\fR \fB=\fR \fIrepo\fR\fB\&.Dataiterator_meta(\fR\fIkeyname\fR\fB,\fR \fImatch\fR\fB,\fR \fIflags\fR\fB)\fR .fi .if n \{\ .RE @@ -1647,7 +1673,7 @@ my \fI$di\fR \fB=\fR \fI$repo\fR\fB\->Dataiterator(\fR\fI$solvid\fR\fB,\fR \fI$k .RE .\} .sp -Iterate over the matching data elements in this repository\&. See the Dataiterator class for more information\&. +Iterate over the matching data elements in this repository\&. See the Dataiterator class for more information\&. The Dataiterator() method iterates over all solvables in a repository, whereas the Dataiterator_meta method only iterates over the repository\(cqs meta data\&. .sp .if n \{\ .RS 4 @@ -2612,16 +2638,15 @@ The solvable containing the value that was matched\&. .\} .sp The id of the solvable that matched\&. -.SS "METHODS" .sp .if n \{\ .RS 4 .\} .nf -\fBId key_id()\fR; -\fI$d\fR\fB\->key_id()\fR -\fId\fR\fB\&.key_id()\fR -\fId\fR\fB\&.key_id()\fR +\fBId\fR \fIkey_id\fR; +\fI$d\fR\fB\->{\fR\fIkey_id\fR\fB}\fR +\fId\fR\fB\&.key_id\fR +\fId\fR\fB\&.key_id\fR .fi .if n \{\ .RE @@ -2631,10 +2656,10 @@ The id of the solvable that matched\&. .RS 4 .\} .nf -\fBconst char *key_idstr()\fR; -\fI$d\fR\fB\->key_idstr()\fR -\fId\fR\fB\&.key_idstr()\fR -\fId\fR\fB\&.key_idstr()\fR +\fBconst char *\fR\fIkey_idstr\fR; +\fI$d\fR\fB\->{\fR\fIkey_idstr\fR\fB}\fR +\fId\fR\fB\&.key_idstr\fR +\fId\fR\fB\&.key_idstr\fR .fi .if n \{\ .RE @@ -2646,10 +2671,10 @@ The keyname that matched, either as id or string\&. .RS 4 .\} .nf -\fBId type_id()\fR; -\fI$d\fR\fB\->type_id()\fR -\fId\fR\fB\&.type_id()\fR -\fId\fR\fB\&.type_id()\fR +\fBId\fR \fItype_id\fR; +\fI$d\fR\fB\->{\fR\fItype_id\fR\fB}\fR +\fId\fR\fB\&.type_id\fR +\fId\fR\fB\&.type_id\fR .fi .if n \{\ .RE @@ -2659,10 +2684,10 @@ The keyname that matched, either as id or string\&. .RS 4 .\} .nf -\fBconst char *type_idstr()\fR; -\fI$d\fR\fB\->type_idstr()\fR; -\fId\fR\fB\&.type_idstr()\fR -\fId\fR\fB\&.type_idstr()\fR +\fBconst char *\fR\fItype_idstr\fR; +\fI$d\fR\fB\->{\fR\fItype_idstr\fR\fB}\fR; +\fId\fR\fB\&.type_idstr\fR +\fId\fR\fB\&.type_idstr\fR .fi .if n \{\ .RE @@ -2674,10 +2699,10 @@ The key type of the value that was matched, either as id or string\&. .RS 4 .\} .nf -\fBId id()\fR; -\fI$d\fR\fB\->id()\fR -\fId\fR\fB\&.id()\fR -\fId\fR\fB\&.id()\fR +\fBId\fR \fIid\fR; +\fI$d\fR\fB\->{id}\fR +\fId\fR\fB\&.id\fR +\fId\fR\fB\&.id\fR .fi .if n \{\ .RE @@ -2687,10 +2712,10 @@ The key type of the value that was matched, either as id or string\&. .RS 4 .\} .nf -\fBId idstr()\fR; -\fI$d\fR\fB\->idstr()\fR -\fId\fR\fB\&.idstr()\fR -\fId\fR\fB\&.idstr()\fR +\fBId\fR \fIidstr\fR; +\fI$d\fR\fB\->{idstr}\fR +\fId\fR\fB\&.idstr\fR +\fId\fR\fB\&.idstr\fR .fi .if n \{\ .RE @@ -2702,10 +2727,10 @@ The Id of the value that was matched (only valid for id types), either as id or .RS 4 .\} .nf -\fBconst char *str()\fR; -\fI$d\fR\fB\->str()\fR -\fId\fR\fB\&.str()\fR -\fId\fR\fB\&.str()\fR +\fBconst char *\fR\fIstr\fR; +\fI$d\fR\fB\->{str}\fR +\fId\fR\fB\&.str\fR +\fId\fR\fB\&.str\fR .fi .if n \{\ .RE @@ -2717,10 +2742,10 @@ The string value that was matched (only valid for string types)\&. .RS 4 .\} .nf -\fBunsigned long long num()\fR; -\fI$d\fR\fB\->num()\fR -\fId\fR\fB\&.num()\fR -\fId\fR\fB\&.num()\fR +\fBunsigned long long\fR \fInum\fR; +\fI$d\fR\fB\->{num}\fR +\fId\fR\fB\&.num\fR +\fId\fR\fB\&.num\fR .fi .if n \{\ .RE @@ -2732,10 +2757,10 @@ The numeric value that was matched (only valid for numeric types)\&. .RS 4 .\} .nf -\fBunsigned int num2()\fR; -\fI$d\fR\fB\->num2()\fR -\fId\fR\fB\&.num2()\fR -\fId\fR\fB\&.num2()\fR +\fBunsigned int\fR \fInum2\fR; +\fI$d\fR\fB\->{num2}\fR +\fId\fR\fB\&.num2\fR +\fId\fR\fB\&.num2\fR .fi .if n \{\ .RE @@ -2747,6 +2772,22 @@ The secondary numeric value that was matched (only valid for types containing tw .RS 4 .\} .nf +\fBunsigned int\fR \fIbinary\fR; +\fI$d\fR\fB\->{binary}\fR +\fId\fR\fB\&.binary\fR +\fId\fR\fB\&.binary\fR +.fi +.if n \{\ +.RE +.\} +.sp +The value in binary form, useful for checksums and other data that cannot be represented as a string\&. +.SS "METHODS" +.sp +.if n \{\ +.RS 4 +.\} +.nf \fBDatapos pos()\fR; my \fI$pos\fR \fB=\fR \fI$d\fR\fB\->pos()\fR; \fIpos\fR \fB=\fR \fId\fR\fB\&.pos()\fR @@ -4934,6 +4975,21 @@ Finalize the checksum and return the result as hex string\&. .RS 4 .\} .nf +\fBconst char *typestr()\fR +my \fI$typestr\fR \fB=\fR \fI$chksum\fR\fB\->typestr()\fR; +\fItypestr\fR \fB=\fR \fIchksum\fR\fB\&.typestr\fR +\fItypestr\fR \fB=\fR \fIchksum\fR\fB\&.typestr\fR +.fi +.if n \{\ +.RE +.\} +.sp +Return the type of the checksum as a string, e\&.g\&. "sha256"\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf \fB\fR \fBif (\fR\fI$chksum1\fR \fB==\fR \fI$chksum2\fR\fB)\fR \fBif\fR \fIchksum1\fR \fB==\fR \fIchksum2\fR\fB:\fR diff --git a/doc/libsolv-bindings.txt b/doc/libsolv-bindings.txt index 06e2bc9..e8c4eb9 100644 --- a/doc/libsolv-bindings.txt +++ b/doc/libsolv-bindings.txt @@ -566,7 +566,12 @@ desired solvable by Id. Lookup functions. Return the data element stored in the specified solvable. You should probably use the methods of the Solvable class instead. - Dataiterator Dataiterator(Id solvid, Id keyname, const char *match = 0, int flags = 0) + Dataiterator Dataiterator(Id keyname, const char *match = 0, int flags = 0) + my $di = $pool->Dataiterator($keyname, $match, $flags); + di = pool.Dataiterator(keyname, match, flags) + di = pool.Dataiterator(keyname, match, flags) + + Dataiterator Dataiterator_solvid(Id solvid, Id keyname, const char *match = 0, int flags = 0) my $di = $pool->Dataiterator($solvid, $keyname, $match, $flags); di = pool.Dataiterator(solvid, keyname, match, flags) di = pool.Dataiterator(solvid, keyname, match, flags) @@ -576,7 +581,8 @@ You should probably use the methods of the Solvable class instead. for d in di Iterate over the matching data elements. See the Dataiterator class for more -information. +information. The Dataiterator method iterates over all solvables in the pool, +whereas the Dataiterator_solvid only iterates over the specified solvable. === ID METHODS === @@ -935,17 +941,24 @@ areas. Create a Selection consisting of all packages in the repository. - Dataiterator Dataiterator(Id p, Id key, const char *match = 0, int flags = 0) - my $di = $repo->Dataiterator($solvid, $keyname, $match, $flags); - di = repo.Dataiterator(solvid, keyname, match, flags) - di = repo.Dataiterator(solvid, keyname, match, flags) + Dataiterator Dataiterator(Id key, const char *match = 0, int flags = 0) + my $di = $repo->Dataiterator($keyname, $match, $flags); + di = repo.Dataiterator(keyname, match, flags) + di = repo.Dataiterator(keyname, match, flags) + + Dataiterator Dataiterator_meta(Id key, const char *match = 0, int flags = 0) + my $di = $repo->Dataiterator_meta($keyname, $match, $flags); + di = repo.Dataiterator_meta(keyname, match, flags) + di = repo.Dataiterator_meta(keyname, match, flags) for my $d (@$di) for d in di: for d in di Iterate over the matching data elements in this repository. See the -Dataiterator class for more information. +Dataiterator class for more information. The Dataiterator() method +iterates over all solvables in a repository, whereas the Dataiterator_meta +method only iterates over the repository's meta data. my $str = $repo->str; @@ -1466,67 +1479,75 @@ The solvable containing the value that was matched. The id of the solvable that matched. -=== METHODS === - - Id key_id(); - $d->key_id() - d.key_id() - d.key_id() + Id key_id; + $d->{key_id} + d.key_id + d.key_id - const char *key_idstr(); - $d->key_idstr() - d.key_idstr() - d.key_idstr() + const char *key_idstr; + $d->{key_idstr} + d.key_idstr + d.key_idstr The keyname that matched, either as id or string. - Id type_id(); - $d->type_id() - d.type_id() - d.type_id() + Id type_id; + $d->{type_id} + d.type_id + d.type_id - const char *type_idstr(); - $d->type_idstr(); - d.type_idstr() - d.type_idstr() + const char *type_idstr; + $d->{type_idstr}; + d.type_idstr + d.type_idstr The key type of the value that was matched, either as id or string. - Id id(); - $d->id() - d.id() - d.id() + Id id; + $d->{id} + d.id + d.id - Id idstr(); - $d->idstr() - d.idstr() - d.idstr() + Id idstr; + $d->{idstr} + d.idstr + d.idstr The Id of the value that was matched (only valid for id types), either as id or string. - const char *str(); - $d->str() - d.str() - d.str() + const char *str; + $d->{str} + d.str + d.str The string value that was matched (only valid for string types). - unsigned long long num(); - $d->num() - d.num() - d.num() + unsigned long long num; + $d->{num} + d.num + d.num The numeric value that was matched (only valid for numeric types). - unsigned int num2(); - $d->num2() - d.num2() - d.num2() + unsigned int num2; + $d->{num2} + d.num2 + d.num2 The secondary numeric value that was matched (only valid for types containing two values). + unsigned int binary; + $d->{binary} + d.binary + d.binary + +The value in binary form, useful for checksums and other data +that cannot be represented as a string. + +=== METHODS === + Datapos pos(); my $pos = $d->pos(); pos = d.pos() @@ -3039,6 +3060,13 @@ result can contain NUL bytes or unprintable characters. Finalize the checksum and return the result as hex string. + const char *typestr() + my $typestr = $chksum->typestr(); + typestr = chksum.typestr + typestr = chksum.typestr + +Return the type of the checksum as a string, e.g. "sha256". + if ($chksum1 == $chksum2) if chksum1 == chksum2: diff --git a/examples/p5solv b/examples/p5solv index 77d580a..330ec63 100755 --- a/examples/p5solv +++ b/examples/p5solv @@ -197,7 +197,7 @@ our @ISA = ('Repo::generic'); sub find { my ($self, $what) = @_; - my $di = $self->{handle}->Dataiterator($solv::SOLVID_META, $solv::REPOSITORY_REPOMD_TYPE, $what, $solv::Dataiterator::SEARCH_STRING); + my $di = $self->{handle}->Dataiterator_meta($solv::REPOSITORY_REPOMD_TYPE, $what, $solv::Dataiterator::SEARCH_STRING); $di->prepend_keyname($solv::REPOSITORY_REPOMD); for my $d (@$di) { my $dp = $d->parentpos(); @@ -318,7 +318,7 @@ our @ISA = ('Repo::generic'); sub find { my ($self, $what) = @_; - my $di = $self->{handle}->Dataiterator($solv::SOLVID_META, $solv::SUSETAGS_FILE_NAME, $what, $solv::Dataiterator::SEARCH_STRING); + my $di = $self->{handle}->Dataiterator_meta($solv::SUSETAGS_FILE_NAME, $what, $solv::Dataiterator::SEARCH_STRING); $di->prepend_keyname($solv::SUSETAGS_FILE); for my $d (@$di) { my $dp = $d->parentpos(); @@ -364,7 +364,7 @@ sub add_ext { sub add_exts { my ($self) = @_; my $repodata = $self->{handle}->add_repodata(0); - my $di = $self->{handle}->Dataiterator($solv::SOLVID_META, $solv::SUSETAGS_FILE_NAME, undef, 0); + my $di = $self->{handle}->Dataiterator_meta($solv::SUSETAGS_FILE_NAME, undef, 0); $di->prepend_keyname($solv::SUSETAGS_FILE); for my $d (@$di) { my $filename = $d->str(); @@ -551,7 +551,7 @@ for my $repo (@repos) { if ($cmd eq 'search') { $pool->createwhatprovides(); my $sel = $pool->Selection(); - my $di = $pool->Dataiterator(0, $solv::SOLVABLE_NAME, $ARGV[0], $solv::Dataiterator::SEARCH_SUBSTRING | $solv::Dataiterator::SEARCH_NOCASE); + my $di = $pool->Dataiterator($solv::SOLVABLE_NAME, $ARGV[0], $solv::Dataiterator::SEARCH_SUBSTRING | $solv::Dataiterator::SEARCH_NOCASE); for my $d (@$di) { $sel->add_raw($solv::Job::SOLVER_SOLVABLE, $d->{solvid}); } diff --git a/examples/pysolv b/examples/pysolv index ef1672d..22ae209 100755 --- a/examples/pysolv +++ b/examples/pysolv @@ -344,7 +344,7 @@ class repo_repomd(repo_generic): return True def find(self, what): - di = self.handle.Dataiterator(solv.SOLVID_META, solv.REPOSITORY_REPOMD_TYPE, what, solv.Dataiterator.SEARCH_STRING) + di = self.handle.Dataiterator_meta(solv.REPOSITORY_REPOMD_TYPE, what, solv.Dataiterator.SEARCH_STRING) di.prepend_keyname(solv.REPOSITORY_REPOMD) for d in di: dp = d.parentpos() @@ -453,7 +453,7 @@ class repo_susetags(repo_generic): return True def find(self, what): - di = self.handle.Dataiterator(solv.SOLVID_META, solv.SUSETAGS_FILE_NAME, what, solv.Dataiterator.SEARCH_STRING) + di = self.handle.Dataiterator_meta(solv.SUSETAGS_FILE_NAME, what, solv.Dataiterator.SEARCH_STRING) di.prepend_keyname(solv.SUSETAGS_FILE) for d in di: dp = d.parentpos() @@ -490,10 +490,10 @@ class repo_susetags(repo_generic): def add_exts(self): repodata = self.handle.add_repodata(0) - di = self.handle.Dataiterator(solv.SOLVID_META, solv.SUSETAGS_FILE_NAME, None, 0) + di = self.handle.Dataiterator_meta(solv.SUSETAGS_FILE_NAME, None, 0) di.prepend_keyname(solv.SUSETAGS_FILE) for d in di: - filename = d.str() + filename = d.str if not filename: continue if filename[0:9] != "packages.": @@ -658,7 +658,7 @@ if options.repos: if cmd == 'search': pool.createwhatprovides() sel = pool.Selection() - di = pool.Dataiterator(0, solv.SOLVABLE_NAME, args[0], solv.Dataiterator.SEARCH_SUBSTRING|solv.Dataiterator.SEARCH_NOCASE) + di = pool.Dataiterator(solv.SOLVABLE_NAME, args[0], solv.Dataiterator.SEARCH_SUBSTRING|solv.Dataiterator.SEARCH_NOCASE) for d in di: sel.add_raw(solv.Job.SOLVER_SOLVABLE, d.solvid) if repofilter: diff --git a/examples/rbsolv b/examples/rbsolv index c67a4c4..470438d 100755 --- a/examples/rbsolv +++ b/examples/rbsolv @@ -219,7 +219,7 @@ end class Repo_rpmmd < Repo_generic def find(what) - di = @handle.Dataiterator(Solv::SOLVID_META, Solv::REPOSITORY_REPOMD_TYPE, what, Solv::Dataiterator::SEARCH_STRING) + di = @handle.Dataiterator_meta(Solv::REPOSITORY_REPOMD_TYPE, what, Solv::Dataiterator::SEARCH_STRING) di.prepend_keyname(Solv::REPOSITORY_REPOMD) for d in di dp = d.parentpos() @@ -337,7 +337,7 @@ end class Repo_susetags < Repo_generic def find(what) - di = @handle.Dataiterator(Solv::SOLVID_META, Solv::SUSETAGS_FILE_NAME, what, Solv::Dataiterator::SEARCH_STRING) + di = @handle.Dataiterator_meta(Solv::SUSETAGS_FILE_NAME, what, Solv::Dataiterator::SEARCH_STRING) di.prepend_keyname(Solv::SUSETAGS_FILE) for d in di dp = d.parentpos() @@ -428,7 +428,7 @@ class Repo_susetags < Repo_generic def add_exts repodata = @handle.add_repodata(0) - di = @handle.Dataiterator(Solv::SOLVID_META, Solv::SUSETAGS_FILE_NAME, nil, 0) + di = @handle.Dataiterator_meta(Solv::SUSETAGS_FILE_NAME, nil, 0) di.prepend_keyname(Solv::SUSETAGS_FILE) for d in di filename = d.str @@ -560,7 +560,7 @@ end if cmd == 'search' pool.createwhatprovides() sel = pool.Selection - for di in pool.Dataiterator(0, Solv::SOLVABLE_NAME, args[0], Solv::Dataiterator::SEARCH_SUBSTRING | Solv::Dataiterator::SEARCH_NOCASE) + for di in pool.Dataiterator(Solv::SOLVABLE_NAME, args[0], Solv::Dataiterator::SEARCH_SUBSTRING | Solv::Dataiterator::SEARCH_NOCASE) sel.add_raw(Solv::Job::SOLVER_SOLVABLE, di.solvid) end for s in sel.solvables -- 2.7.4