apt @VERSION@
deblistparser.h
00001 // -*- mode: cpp; mode: fold -*-
00002 // Description                                                          /*{{{*/
00003 // $Id: deblistparser.h,v 1.9 2001/02/20 07:03:17 jgg Exp $
00004 /* ######################################################################
00005    
00006    Debian Package List Parser - This implements the abstract parser 
00007    interface for Debian package files
00008    
00009    ##################################################################### */
00010                                                                         /*}}}*/
00011 #ifndef PKGLIB_DEBLISTPARSER_H
00012 #define PKGLIB_DEBLISTPARSER_H
00013 
00014 #include <apt-pkg/pkgcachegen.h>
00015 #include <apt-pkg/tagfile.h>
00016 
00017 class debListParser : public pkgCacheGenerator::ListParser
00018 {
00019    public:
00020 
00021    // Parser Helper
00022    struct WordList
00023    {
00024       const char *Str;
00025       unsigned char Val;
00026    };
00027 
00028    private:
00030    void *d;
00031 
00032    protected:
00033    pkgTagFile Tags;
00034    pkgTagSection Section;
00035    unsigned long iOffset;
00036    std::string Arch;
00037    std::vector<std::string> Architectures;
00038    bool MultiArchEnabled;
00039 
00040    unsigned long UniqFindTagWrite(const char *Tag);
00041    virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
00042    bool ParseDepends(pkgCache::VerIterator &Ver,const char *Tag,
00043                      unsigned int Type);
00044    bool ParseProvides(pkgCache::VerIterator &Ver);
00045    bool NewProvidesAllArch(pkgCache::VerIterator &Ver, std::string const &Package, std::string const &Version);
00046    static bool GrabWord(std::string Word,WordList *List,unsigned char &Out);
00047    
00048    public:
00049 
00050    static unsigned char GetPrio(std::string Str);
00051       
00052    // These all operate against the current section
00053    virtual std::string Package();
00054    virtual std::string Architecture();
00055    virtual bool ArchitectureAll();
00056    virtual std::string Version();
00057    virtual bool NewVersion(pkgCache::VerIterator &Ver);
00058    virtual std::string Description();
00059    virtual std::string DescriptionLanguage();
00060    virtual MD5SumValue Description_md5();
00061    virtual unsigned short VersionHash();
00062    virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
00063                            pkgCache::VerIterator &Ver);
00064    virtual unsigned long Offset() {return iOffset;};
00065    virtual unsigned long Size() {return Section.size();};
00066 
00067    virtual bool Step();
00068    
00069    bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
00070                         std::string section);
00071    
00072    static const char *ParseDepends(const char *Start,const char *Stop,
00073                             std::string &Package,std::string &Ver,unsigned int &Op,
00074                             bool const &ParseArchFlags = false,
00075                             bool const &StripMultiArch = true);
00076    static const char *ConvertRelation(const char *I,unsigned int &Op);
00077 
00078    debListParser(FileFd *File, std::string const &Arch = "");
00079    virtual ~debListParser() {};
00080 };
00081 
00082 #endif