From 012b102ad1baf9f24601cbec6365fe43aad2d521 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 21 Oct 2005 19:51:41 +0000 Subject: * ABI/API change: add "VerIterator::TranslatedDescription()" method to make the life of the api user easier --- apt-pkg/cacheiterators.h | 1 + apt-pkg/pkgcache.cc | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index f0aafb52d..64fa4636e 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -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; diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index f76afb935..4452079a2 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -26,6 +26,7 @@ #endif #include +#include #include #include #include @@ -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; +}; + + /*}}}*/ -- cgit v1.2.3 From 960d4d245dfecab6fd41ab82b59b2e10c0a40946 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 22 Oct 2005 21:48:27 +0000 Subject: * revert patch from patch-59, causes all sorts of trouble --- apt-pkg/pkgrecords.cc | 5 +---- apt-pkg/pkgrecords.h | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc index 1d71d3e2f..9c2655d6a 100644 --- a/apt-pkg/pkgrecords.cc +++ b/apt-pkg/pkgrecords.cc @@ -42,9 +42,6 @@ pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0) if (Files[I->ID] == 0) return; } - // We store that to make sure that the destructor won't segfault, - // even if the Cache object was destructed before this instance. - PackageFileCount = Cache.HeaderP->PackageFileCount; } /*}}}*/ // Records::~pkgRecords - Destructor /*{{{*/ @@ -52,7 +49,7 @@ pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0) /* */ pkgRecords::~pkgRecords() { - for (unsigned I = 0; I != PackageFileCount; I++) + for (unsigned I = 0; I != Cache.HeaderP->PackageFileCount; I++) delete Files[I]; delete [] Files; } diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h index f31e83afe..08f004414 100644 --- a/apt-pkg/pkgrecords.h +++ b/apt-pkg/pkgrecords.h @@ -33,7 +33,6 @@ class pkgRecords pkgCache &Cache; Parser **Files; - int PackageFileCount; public: -- cgit v1.2.3