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