]> git.saurik.com Git - apt.git/commitdiff
* ABI/API change: add "VerIterator::TranslatedDescription()" method to make the life...
authorMichael Vogt <michael.vogt@ubuntu.com>
Fri, 21 Oct 2005 19:51:41 +0000 (19:51 +0000)
committerMichael Vogt <michael.vogt@ubuntu.com>
Fri, 21 Oct 2005 19:51:41 +0000 (19:51 +0000)
apt-pkg/cacheiterators.h
apt-pkg/pkgcache.cc
cmdline/apt-cache.cc

index f0aafb52df1b7092b36a8544a166958c058c19be..64fa4636ea27fedf612e5f1acba3f1a1eb1d43c8 100644 (file)
@@ -129,6 +129,7 @@ class pkgCache::VerIterator
    inline const char *Arch() const {return Ver->Arch == 0?0:Owner->StrP + Ver->Arch;};
    inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Ver->ParentPkg);};
    inline DescIterator DescriptionList() const;
+   DescIterator TranslatedDescription() const;
    inline DepIterator DependsList() const;
    inline PrvIterator ProvidesList() const;
    inline VerFileIterator FileList() const;
index f76afb9357acc94e034f5002f539473b0084fcad..4452079a2ee62cd4f067180010bee3a7a8287f4e 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 */
@@ -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;
+};
+
+                                                                       /*}}}*/
index 810dbe7b021d8d07747a739372c74442ba226ce7..cb1aeb514f4184ffb55479765bc89e62da27c8c9 100644 (file)
@@ -1237,13 +1237,7 @@ bool DisplayRecord(pkgCache::VerIterator V)
 
    // Show the right description
    pkgRecords Recs(*GCache);
-   pkgCache::DescIterator DescDefault = V.DescriptionList();
-   pkgCache::DescIterator Desc = DescDefault;
-   for (; Desc.end() == false; Desc++)
-      if (pkgIndexFile::LanguageCode() == Desc.LanguageCode())
-        break;
-   if (Desc.end() == true) Desc = DescDefault;
-
+   pkgCache::DescIterator Desc = V.TranslatedDescription();
    pkgRecords::Parser &P = Recs.Lookup(Desc.FileList());
    cout << "Description" << ( (strcmp(Desc.LanguageCode(),"") != 0) ? "-" : "" ) << Desc.LanguageCode() << ": " << P.LongDesc();