Add per-datatype iterators to rpmtd

- just uint32 and string iterators for now, those are the most common ones
- allows somewhat more convenient code constructs when type is known,
  eg no need to separately check for non-null inside loops
This commit is contained in:
Panu Matilainen 2008-05-21 14:49:12 +03:00
parent 3d8656f040
commit 35c0252857
2 changed files with 34 additions and 0 deletions

View File

@ -96,6 +96,26 @@ int rpmtdNext(rpmtd td)
return i; return i;
} }
uint32_t *rpmtdNextUint32(rpmtd td)
{
assert(td != NULL);
uint32_t *res = NULL;
if (rpmtdNext(td) >= 0) {
res = rpmtdGetUint32(td);
}
return res;
}
const char *rpmtdNextString(rpmtd td)
{
assert(td != NULL);
const char *res = NULL;
if (rpmtdNext(td) >= 0) {
res = rpmtdGetString(td);
}
return res;
}
char * rpmtdGetChar(rpmtd td) char * rpmtdGetChar(rpmtd td)
{ {
char *res = NULL; char *res = NULL;

View File

@ -86,6 +86,20 @@ int rpmtdInit(rpmtd td);
*/ */
int rpmtdNext(rpmtd td); int rpmtdNext(rpmtd td);
/** \ingroup rpmtd
* Iterate over uint32_t type tag data container.
* @param td Tag data container
* @return Pointer to next value, NULL on termination or error
*/
uint32_t *rpmtdNextUint32(rpmtd td);
/** \ingroup rpmtd
* Iterate over string / string array type tag data container.
* @param td Tag data container
* @return Pointer to next value, NULL on termination or error
*/
const char *rpmtdNextString(rpmtd td);
/** \ingroup rpmtd /** \ingroup rpmtd
* Return char data from tag container. * Return char data from tag container.
* For scalar return type, just return pointer to the integer. On array * For scalar return type, just return pointer to the integer. On array