]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/pkgcache.cc
* merged with apt--debian-sid--0
[apt.git] / apt-pkg / pkgcache.cc
index 2189d5111cfb7b575ef63be80a3418d0aa2df57b..162ab4f279f4e3e90d7f700389eb98befeb64ec7 100644 (file)
@@ -26,6 +26,7 @@
 #endif 
 
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/indexfile.h>
 #include <apt-pkg/version.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/strutl.h>
@@ -43,6 +44,7 @@
 
 using std::string;
 
+
 // Cache::Header::Header - Constructor                                 /*{{{*/
 // ---------------------------------------------------------------------
 /* Simply initialize the header */
@@ -162,7 +164,7 @@ bool pkgCache::ReMap()
 /* This is used to generate the hash entries for the HashTable. With my
    package list from bo this function gets 94% table usage on a 512 item
    table (480 used items) */
-unsigned long pkgCache::sHash(string Str) const
+unsigned long pkgCache::sHash(const string &Str) const
 {
    unsigned long Hash = 0;
    for (string::const_iterator I = Str.begin(); I != Str.end(); I++)
@@ -182,7 +184,7 @@ unsigned long pkgCache::sHash(const char *Str) const
 // Cache::FindPkg - Locate a package by name                           /*{{{*/
 // ---------------------------------------------------------------------
 /* Returns 0 on error, pointer to the package otherwise */
-pkgCache::PkgIterator pkgCache::FindPkg(string Name)
+pkgCache::PkgIterator pkgCache::FindPkg(const string &Name)
 {
    // Look at the hash bucket
    Package *Pkg = PkgP + HeaderP->HashTable[Hash(Name)];
@@ -244,11 +246,11 @@ const char *pkgCache::Priority(unsigned char Prio)
    return 0;
 }
                                                                        /*}}}*/
-
 // Bases for iterator classes                                          /*{{{*/
 void pkgCache::VerIterator::_dummy() {}
 void pkgCache::DepIterator::_dummy() {}
 void pkgCache::PrvIterator::_dummy() {}
+void pkgCache::DescIterator::_dummy() {}
                                                                        /*}}}*/
 // PkgIterator::operator ++ - Postfix incr                             /*{{{*/
 // ---------------------------------------------------------------------
@@ -608,3 +610,20 @@ string pkgCache::PkgFileIterator::RelStr()
    return Res;
 }
                                                                        /*}}}*/
+// VerIterator::TranslatedDescription - Return the a DescIter for locale/*{{{*/
+// ---------------------------------------------------------------------
+/* return a DescIter for the current locale or the default if none is 
+ * found
+ */
+pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const
+{
+   pkgCache::DescIterator DescDefault = DescriptionList();
+   pkgCache::DescIterator Desc = DescDefault;
+   for (; Desc.end() == false; Desc++)
+      if (pkgIndexFile::LanguageCode() == Desc.LanguageCode())
+        break;
+   if (Desc.end() == true) Desc = DescDefault;
+   return Desc;
+};
+
+                                                                       /*}}}*/