X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/eff0c22e59e65b6b63e854ff41eb091278e05714..baec76f5f0f9fcbd71f6e2afaa7fc85543bd624c:/apt-pkg/tagfile.h?ds=sidebyside diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 0f4c15436..bd3b4d1ea 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -49,10 +49,22 @@ class pkgTagFilePrivate; class pkgTagSection { const char *Section; - unsigned int AlphaIndexes[0x100]; + unsigned int AlphaIndexes[128]; + unsigned int BetaIndexes[128]; pkgTagSectionPrivate * const d; + APT_HIDDEN bool FindInternal(unsigned int Pos,const char *&Start, const char *&End) const; +#if defined(APT_PKG_EXPOSE_STRING_VIEW) + APT_HIDDEN APT::StringView FindInternal(unsigned int Pos) const; + APT_HIDDEN APT::StringView FindRawInternal(unsigned int Pos) const; +#endif + APT_HIDDEN signed int FindIInternal(unsigned int Pos,signed long Default = 0) const; + APT_HIDDEN bool FindBInternal(unsigned int Pos, bool Default = false) const; + APT_HIDDEN unsigned long long FindULLInternal(unsigned int Pos, unsigned long long const &Default = 0) const; + APT_HIDDEN bool FindFlagInternal(unsigned int Pos,uint8_t &Flags, uint8_t const Flag) const; + APT_HIDDEN bool FindFlagInternal(unsigned int Pos,unsigned long &Flags, unsigned long Flag) const; + protected: const char *Stop; @@ -77,7 +89,19 @@ class pkgTagSection std::string FindS(const char *Tag) const; std::string FindRawS(const char *Tag) const; + // Functions for lookup with a perfect hash function + enum class Key; + APT_HIDDEN bool Find(Key key,const char *&Start, const char *&End) const; + APT_HIDDEN bool Find(Key key,unsigned int &Pos) const; + APT_HIDDEN signed int FindI(Key key,signed long Default = 0) const; + APT_HIDDEN bool FindB(Key key, bool Default = false) const; + APT_HIDDEN unsigned long long FindULL(Key key, unsigned long long const &Default = 0) const; + APT_HIDDEN bool FindFlag(Key key,uint8_t &Flags, uint8_t const Flag) const; + APT_HIDDEN bool FindFlag(Key key,unsigned long &Flags, unsigned long Flag) const; + APT_HIDDEN bool Exists(Key key) const; #ifdef APT_PKG_EXPOSE_STRING_VIEW + APT_HIDDEN APT::StringView Find(Key key) const; + APT_HIDDEN APT::StringView FindRaw(Key key) const; APT_HIDDEN bool Find(APT::StringView Tag,const char *&Start, const char *&End) const; APT_HIDDEN bool Find(APT::StringView Tag,unsigned int &Pos) const; APT_HIDDEN APT::StringView Find(APT::StringView Tag) const; @@ -114,11 +138,10 @@ class pkgTagSection * @return \b true if section end was found, \b false otherwise. * Beware that internal state will be inconsistent if \b false is returned! */ - APT_MUSTCHECK bool Scan(const char *Start, unsigned long MaxLength, bool const Restart = true); + APT_MUSTCHECK bool Scan(const char *Start, unsigned long MaxLength, bool const SupportComments); inline unsigned long size() const {return Stop - Section;}; - void Trim(); - virtual void TrimRecord(bool BeforeRecord, const char* &End); + void TrimRecord(bool BeforeRecord, const char* &End, bool SupportComments); /** \brief amount of Tags in the current section * @@ -163,11 +186,6 @@ class pkgTagSection }; -class APT_DEPRECATED_MSG("Use pkgTagFile with the SUPPORT_COMMENTS flag instead") pkgUserTagSection : public pkgTagSection -{ - virtual void TrimRecord(bool BeforeRecord, const char* &End) APT_OVERRIDE; -}; - /** \class pkgTagFile reads and prepares a deb822 formatted file for parsing * via #pkgTagSection. The default mode tries to be as fast as possible and * assumes perfectly valid (machine generated) files like Packages. Support @@ -176,10 +194,6 @@ class pkgTagFile { pkgTagFilePrivate * const d; - APT_HIDDEN bool Fill(); - APT_HIDDEN bool Resize(); - APT_HIDDEN bool Resize(unsigned long long const newSize); - public: bool Step(pkgTagSection &Section); @@ -192,11 +206,11 @@ public: SUPPORT_COMMENTS = 1 << 0, }; - void Init(FileFd * const F, pkgTagFile::Flags const Flags, unsigned long long Size = 32*1024); - void Init(FileFd * const F,unsigned long long const Size = 32*1024); + void Init(FileFd * const F, pkgTagFile::Flags const Flags); + void Init(FileFd * const F); - pkgTagFile(FileFd * const F, pkgTagFile::Flags const Flags, unsigned long long Size = 32*1024); - pkgTagFile(FileFd * const F,unsigned long long Size = 32*1024); + pkgTagFile(FileFd * const F, pkgTagFile::Flags const Flags); + pkgTagFile(FileFd * const F); virtual ~pkgTagFile(); };