[Debtags-devel] poptags

Enrico Zini enrico at enricozini.org
Mon Aug 15 20:15:11 UTC 2005


On Sun, Aug 14, 2005 at 06:23:39PM -0300, Gustavo Franco wrote:
> On 8/13/05, Enrico Zini <enrico at enricozini.org> wrote:
> > Do you think you could make a 'popcon' tool with at least a 'popcon
> > update' command that, like debtags, downloads popcon data and creates a
> > binary index to access them quickly?  I (or you if you do C++) could
> > then integrate that library into libapt-front.
> Are you asking for a popcon code only or something like poptags but
> with the 'update' feature creating a binary index ? In both cases i'll
> use debtags code as reference.

I'd add the 'update' command to poptags, and then maybe, later on,
discuss with the maintainer of 'popcon' about turning it into a 'popcon'
tool.

If you want to see C++ code that handles the binary index, you can see
TDBFile.h [package tagcoll] and a simple use in Vocabulary.h [package
debtags].

What you would do is define a structure that can hold all the popcon
data about a package, such as:

struct PopconData
{
	int inst;
	int vote;
	int old;
	int recent;
	int no-files;
};

Then you write it with:

  TDBFile file("index.dat");
  PopconData myData;
  // fill in myData
  file.set("myPackage", myData);

and you read it with:
  file.get("myPackage", myData);

The 'get' and 'set' methods are template methods which are smart enough
to see what is the size of the type of myData and write and read
accordingly.

If you need it, you can easily cut the dependencies of the class TDBFile
to just tdb.h and use it in your code.


Ciao,

Enrico proud of those get and set methods :)

--
GPG key: 1024D/797EBFAB 2000-12-05 Enrico Zini <enrico at enricozini.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/debtags-devel/attachments/20050815/9d9396e1/attachment.pgp


More information about the Debtags-devel mailing list