]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/pkgcache.h
Most interfaces (Maemo) need a high-level name :/.
[apt.git] / apt-pkg / pkgcache.h
index 7acfc01ba84408c28fb01378afce6f1f4e1bf65b..83bf8961def2b2d4afc835dff27e47f5d705575a 100644 (file)
 #include <time.h>
 #include <stdint.h>
 
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+#include <apt-pkg/string_view.h>
+#endif
+
 #ifndef APT_8_CLEANER_HEADERS
 using std::string;
 #endif
@@ -119,6 +123,7 @@ class pkgCache                                                              /*{{{*/
    struct StringItem;
    struct VerFile;
    struct DescFile;
+   struct Tag;
    
    // Iterators
    template<typename Str, typename Itr> class Iterator;
@@ -132,6 +137,7 @@ class pkgCache                                                              /*{{{*/
    class PkgFileIterator;
    class VerFileIterator;
    class DescFileIterator;
+   class TagIterator;
    
    class Namespace;
    
@@ -193,7 +199,9 @@ class pkgCache                                                              /*{{{*/
    // Memory mapped cache file
    std::string CacheFile;
    MMap &Map;
-
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+   APT_HIDDEN map_id_t sHash(APT::StringView S) const APT_PURE;
+#endif
    map_id_t sHash(const std::string &S) const APT_PURE;
    map_id_t sHash(const char *S) const APT_PURE;
    
@@ -208,6 +216,7 @@ class pkgCache                                                              /*{{{*/
    ReleaseFile *RlsFileP;
    PackageFile *PkgFileP;
    Version *VerP;
+   Tag *TagP;
    Description *DescP;
    Provides *ProvideP;
    Dependency *DepP;
@@ -221,6 +230,9 @@ class pkgCache                                                              /*{{{*/
    inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();}
       
    // String hashing function (512 range)
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+   APT_HIDDEN inline map_id_t Hash(APT::StringView S) const {return sHash(S);}
+#endif
    inline map_id_t Hash(const std::string &S) const {return sHash(S);}
    inline map_id_t Hash(const char *S) const {return sHash(S);}
 
@@ -230,6 +242,22 @@ class pkgCache                                                             /*{{{*/
    static const char *Priority(unsigned char Priority);
    
    // Accessors
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+   APT_HIDDEN GrpIterator FindGrp(APT::StringView Name);
+   APT_HIDDEN PkgIterator FindPkg(APT::StringView Name);
+   APT_HIDDEN PkgIterator FindPkg(APT::StringView Name, APT::StringView Arch);
+#endif
+
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+   APT::StringView ViewString(map_stringitem_t idx) const
+   {
+      char *name = StrP + idx;
+      uint16_t len = *reinterpret_cast<const uint16_t*>(name - sizeof(uint16_t));
+      return APT::StringView(name, len);
+   }
+#endif
+
+
    GrpIterator FindGrp(const std::string &Name);
    PkgIterator FindPkg(const std::string &Name);
    PkgIterator FindPkg(const std::string &Name, const std::string &Arch);
@@ -295,6 +323,7 @@ struct pkgCache::Header
    map_number_t ReleaseFileSz;
    map_number_t PackageFileSz;
    map_number_t VersionSz;
+   map_number_t TagSz;
    map_number_t DescriptionSz;
    map_number_t DependencySz;
    map_number_t DependencyDataSz;
@@ -310,6 +339,7 @@ struct pkgCache::Header
    map_id_t GroupCount;
    map_id_t PackageCount;
    map_id_t VersionCount;
+   map_id_t TagCount;
    map_id_t DescriptionCount;
    map_id_t DependsCount;
    map_id_t DependsDataCount;
@@ -560,6 +590,16 @@ struct pkgCache::VerFile
    map_filesize_t Size;
 };
                                                                        /*}}}*/
+// TagFile structure                                                   /*{{{*/
+/** \brief associates a tag with something */
+struct pkgCache::Tag
+{
+   /** \brief name of this tag */
+   map_stringitem_t Name;
+   /** \brief next step in the linked list */
+   map_pointer_t NextTag;       // Tag
+};
+                                                                       /*}}}*/
 // DescFile structure                                                  /*{{{*/
 /** \brief associates a description with a Translation file */
 struct pkgCache::DescFile
@@ -587,6 +627,8 @@ struct pkgCache::Version
    map_stringitem_t VerStr;
    /** \brief section this version is filled in */
    map_stringitem_t Section;
+   /** \brief high-level name used to display package */
+   map_stringitem_t Display;
    /** \brief source package name this version comes from
       Always contains the name, even if it is the same as the binary name */
    map_stringitem_t SourcePkgName;
@@ -631,6 +673,8 @@ struct pkgCache::Version
    map_pointer_t ParentPkg;         // Package
    /** \brief list of pkgCache::Provides */
    map_pointer_t ProvidesList;      // Provides
+   /** \brief list of pkgCache::Tag */
+   map_pointer_t TagList;           // Tag
 
    /** \brief archive size for this version
 
@@ -783,6 +827,7 @@ class pkgCache::Namespace                                           /*{{{*/
    typedef pkgCache::GrpIterator GrpIterator;
    typedef pkgCache::PkgIterator PkgIterator;
    typedef pkgCache::VerIterator VerIterator;
+   typedef pkgCache::TagIterator TagIterator;
    typedef pkgCache::DescIterator DescIterator;
    typedef pkgCache::DepIterator DepIterator;
    typedef pkgCache::PrvIterator PrvIterator;