apt  1.5
debsrcrecords.h
00001 // -*- mode: cpp; mode: fold -*-
00002 // Description                                                          /*{{{*/
00003 // $Id: debsrcrecords.h,v 1.8 2004/03/17 05:58:54 mdz Exp $
00004 /* ######################################################################
00005    
00006    Debian Source Package Records - Parser implementation for Debian style
00007                                    source indexes
00008    
00009    ##################################################################### */
00010                                                                         /*}}}*/
00011 #ifndef PKGLIB_DEBSRCRECORDS_H
00012 #define PKGLIB_DEBSRCRECORDS_H
00013 
00014 
00015 #include <apt-pkg/srcrecords.h>
00016 #include <apt-pkg/tagfile.h>
00017 #include <apt-pkg/fileutl.h>
00018 
00019 class debSrcRecordParser : public pkgSrcRecords::Parser
00020 {
00022    void *d;
00023 
00024    FileFd Fd;
00025    pkgTagFile Tags;
00026    pkgTagSection Sect;
00027    std::vector<const char*> StaticBinList;
00028    unsigned long iOffset;
00029    char *Buffer;
00030    
00031    public:
00032 
00033    virtual bool Restart() {return Tags.Jump(Sect,0);};
00034    virtual bool Step() {iOffset = Tags.Offset(); return Tags.Step(Sect);};
00035    virtual bool Jump(unsigned long const &Off) {iOffset = Off; return Tags.Jump(Sect,Off);};
00036 
00037    virtual std::string Package() const {return Sect.FindS("Package");};
00038    virtual std::string Version() const {return Sect.FindS("Version");};
00039    virtual std::string Maintainer() const {return Sect.FindS("Maintainer");};
00040    virtual std::string Section() const {return Sect.FindS("Section");};
00041    virtual const char **Binaries();
00042    virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true);
00043    virtual unsigned long Offset() {return iOffset;};
00044    virtual std::string AsStr() 
00045    {
00046       const char *Start=0,*Stop=0;
00047       Sect.GetSection(Start,Stop);
00048       return std::string(Start,Stop);
00049    };
00050    virtual bool Files(std::vector<pkgSrcRecords::File> &F);
00051 
00052    debSrcRecordParser(std::string const &File,pkgIndexFile const *Index) 
00053       : Parser(Index), Fd(File,FileFd::ReadOnly, FileFd::Extension), Tags(&Fd,102400), 
00054         Buffer(NULL) {}
00055    virtual ~debSrcRecordParser();
00056 };
00057 
00058 #endif