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/indexfile.h>
00016 #include <apt-pkg/tagfile.h>
00017 
00018 class debListParser : public pkgCacheGenerator::ListParser
00019 {
00020    public:
00021 
00022    // Parser Helper
00023    struct WordList
00024    {
00025       const char *Str;
00026       unsigned char Val;
00027    };
00028    
00029    private:
00030    
00031    pkgTagFile Tags;
00032    pkgTagSection Section;
00033    unsigned long iOffset;
00034    string Arch;
00035    std::vector<std::string> Architectures;
00036    bool MultiArchEnabled;
00037 
00038    unsigned long UniqFindTagWrite(const char *Tag);
00039    bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver);
00040    bool ParseDepends(pkgCache::VerIterator &Ver,const char *Tag,
00041                      unsigned int Type);
00042    bool ParseProvides(pkgCache::VerIterator &Ver);
00043    static bool GrabWord(string Word,WordList *List,unsigned char &Out);
00044    
00045    public:
00046 
00047    static unsigned char GetPrio(string Str);
00048       
00049    // These all operate against the current section
00050    virtual string Package();
00051    virtual string Architecture();
00052    virtual bool ArchitectureAll();
00053    virtual string Version();
00054    virtual bool NewVersion(pkgCache::VerIterator &Ver);
00055    virtual string Description();
00056    virtual string DescriptionLanguage();
00057    virtual MD5SumValue Description_md5();
00058    virtual unsigned short VersionHash();
00059    virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
00060                            pkgCache::VerIterator &Ver);
00061    virtual unsigned long Offset() {return iOffset;};
00062    virtual unsigned long Size() {return Section.size();};
00063 
00064    virtual bool Step();
00065    
00066    bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
00067                         string section);
00068    
00069    static const char *ParseDepends(const char *Start,const char *Stop,
00070                             string &Package,string &Ver,unsigned int &Op,
00071                             bool const &ParseArchFlags = false,
00072                             bool const &StripMultiArch = false);
00073    static const char *ConvertRelation(const char *I,unsigned int &Op);
00074 
00075    debListParser(FileFd *File, string const &Arch = "");
00076 };
00077 
00078 #endif