[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Patch] Function for getting the value of an arbitrary control field



On Mi, 2011-01-05 at 20:28 -0500, Jonathan Thomas wrote:
> Hello,
> 
> I was wondering if there was any interest for a patch to allow an application to get the value of an arbitrary debian/control field via a pkgRecords::Parser object. The usecase would be for obtaining the values of nonstandard fields such as the "Supported" field of Ubuntu packages in main, or any of the several metadata fields that the GStreamer packages have. ("Gstreamer-Decoders", "Gstreamer-Elements", etc)
In theory, it's an abstract class and does no contain Debian-specific
stuff.


> In the Package class for my Qt APT library, LibQApt, I'm currently using something like the following to get the value of arbitrary control fields:
> 
>     pkgRecords::Parser &rec = d->records->Lookup(ver.FileList());
>     const char *start, *stop;
>     rec.GetRec(start, stop);
>     QString record(start);
> 
>     QStringList lines = record.split('\n');
> 
>     Q_FOREACH (const QString &line, lines) {
>         if (line.startsWith(name)) {
>             field = line.split(": ").at(1);
>             break;
>         }
>     }
> 
> I could replace this all with one call to the new function I have added in the patch, making things much more convenient. (I have attached the patch to this email)
> 
Just use pkgTagFile and Jump() to the ver->FileList()->Offset. At least
use pkgTagSection to parse the record instead of splitting stuff. Makes
it shorter.

PS. Please keep your lines at about 70 characters.

-- 
Julian Andres Klode  - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.



Reply to: