Use BStringList in package kit

Replace all instances of BObjectList<BString> by BStringList.
This commit is contained in:
Ingo Weinhold 2011-07-16 16:36:36 +02:00
parent 7de6af25e9
commit 9968845d69
12 changed files with 89 additions and 125 deletions

View File

@ -8,6 +8,7 @@
#include <ObjectList.h> #include <ObjectList.h>
#include <String.h> #include <String.h>
#include <StringList.h>
#include <package/PackageArchitecture.h> #include <package/PackageArchitecture.h>
#include <package/PackageFlags.h> #include <package/PackageFlags.h>
@ -68,10 +69,10 @@ public:
const BPackageVersion& Version() const; const BPackageVersion& Version() const;
const BObjectList<BString>& CopyrightList() const; const BStringList& CopyrightList() const;
const BObjectList<BString>& LicenseList() const; const BStringList& LicenseList() const;
const BObjectList<BString>& URLList() const; const BStringList& URLList() const;
const BObjectList<BString>& SourceURLList() const; const BStringList& SourceURLList() const;
const BObjectList<BPackageResolvable>& ProvidesList() const; const BObjectList<BPackageResolvable>& ProvidesList() const;
const BObjectList<BPackageResolvableExpression>& const BObjectList<BPackageResolvableExpression>&
@ -82,7 +83,7 @@ public:
ConflictsList() const; ConflictsList() const;
const BObjectList<BPackageResolvableExpression>& const BObjectList<BPackageResolvableExpression>&
FreshensList() const; FreshensList() const;
const BObjectList<BString>& ReplacesList() const; const BStringList& ReplacesList() const;
void SetName(const BString& name); void SetName(const BString& name);
void SetSummary(const BString& summary); void SetSummary(const BString& summary);
@ -159,10 +160,10 @@ private:
BPackageVersion fVersion; BPackageVersion fVersion;
BObjectList<BString> fCopyrightList; BStringList fCopyrightList;
BObjectList<BString> fLicenseList; BStringList fLicenseList;
BObjectList<BString> fURLList; BStringList fURLList;
BObjectList<BString> fSourceURLList; BStringList fSourceURLList;
BObjectList<BPackageResolvable> fProvidesList; BObjectList<BPackageResolvable> fProvidesList;
@ -173,7 +174,7 @@ private:
BObjectList<BPackageResolvableExpression> fFreshensList; BObjectList<BPackageResolvableExpression> fFreshensList;
BObjectList<BString> fReplacesList; BStringList fReplacesList;
BString fChecksum; BString fChecksum;
BString fInstallPath; BString fInstallPath;

View File

@ -11,7 +11,7 @@
#include <Path.h> #include <Path.h>
template <class T> class BObjectList; class BStringList;
namespace BPackageKit { namespace BPackageKit {
@ -45,7 +45,7 @@ public:
status_t GetUserRepositoryConfigPath(BPath* path, status_t GetUserRepositoryConfigPath(BPath* path,
bool create = false) const; bool create = false) const;
status_t GetRepositoryNames(BObjectList<BString>& names); status_t GetRepositoryNames(BStringList& names);
status_t VisitCommonRepositoryConfigs( status_t VisitCommonRepositoryConfigs(
BRepositoryConfigVisitor& visitor); BRepositoryConfigVisitor& visitor);

View File

@ -8,7 +8,7 @@
#include <Archivable.h> #include <Archivable.h>
#include <Entry.h> #include <Entry.h>
#include <ObjectList.h> #include <StringList.h>
#include <String.h> #include <String.h>
#include <package/PackageArchitecture.h> #include <package/PackageArchitecture.h>
@ -38,8 +38,8 @@ public:
const BString& Summary() const; const BString& Summary() const;
uint8 Priority() const; uint8 Priority() const;
BPackageArchitecture Architecture() const; BPackageArchitecture Architecture() const;
const BObjectList<BString>& LicenseNames() const; const BStringList& LicenseNames() const;
const BObjectList<BString>& LicenseTexts() const; const BStringList& LicenseTexts() const;
void SetName(const BString& name); void SetName(const BString& name);
void SetOriginalBaseURL(const BString& url); void SetOriginalBaseURL(const BString& url);
@ -75,8 +75,8 @@ private:
BString fSummary; BString fSummary;
uint8 fPriority; uint8 fPriority;
BPackageArchitecture fArchitecture; BPackageArchitecture fArchitecture;
BObjectList<BString> fLicenseNames; BStringList fLicenseNames;
BObjectList<BString> fLicenseTexts; BStringList fLicenseTexts;
}; };

View File

@ -214,11 +214,11 @@ struct RepositoryContentListHandler : BRepositoryContentHandler {
printf("\tpriority: %u\n", repositoryInfo.Priority()); printf("\tpriority: %u\n", repositoryInfo.Priority());
printf("\tarchitecture: %s\n", printf("\tarchitecture: %s\n",
BPackageInfo::kArchitectureNames[repositoryInfo.Architecture()]); BPackageInfo::kArchitectureNames[repositoryInfo.Architecture()]);
const BObjectList<BString> licenseNames = repositoryInfo.LicenseNames(); const BStringList licenseNames = repositoryInfo.LicenseNames();
if (!licenseNames.IsEmpty()) { if (!licenseNames.IsEmpty()) {
printf("\tlicenses:\n"); printf("\tlicenses:\n");
for (int i = 0; i < licenseNames.CountItems(); ++i) for (int i = 0; i < licenseNames.CountStrings(); ++i)
printf("\t\t%s\n", licenseNames.ItemAt(i)->String()); printf("\t\t%s\n", licenseNames.StringAt(i).String());
} }
return B_OK; return B_OK;

View File

@ -82,14 +82,14 @@ command_list_repos(int argc, const char* const* argv)
if (argc != optind) if (argc != optind)
print_command_usage_and_exit(true); print_command_usage_and_exit(true);
BObjectList<BString> repositoryNames(20, true); BStringList repositoryNames(20);
BPackageRoster roster; BPackageRoster roster;
status_t result = roster.GetRepositoryNames(repositoryNames); status_t result = roster.GetRepositoryNames(repositoryNames);
if (result != B_OK) if (result != B_OK)
DIE(result, "can't collect repository names"); DIE(result, "can't collect repository names");
for (int i = 0; i < repositoryNames.CountItems(); ++i) { for (int i = 0; i < repositoryNames.CountStrings(); ++i) {
const BString& repoName = *(repositoryNames.ItemAt(i)); const BString& repoName = repositoryNames.StringAt(i);
BRepositoryConfig repoConfig; BRepositoryConfig repoConfig;
result = roster.GetRepositoryConfig(repoName, &repoConfig); result = roster.GetRepositoryConfig(repoName, &repoConfig);
if (result != B_OK) { if (result != B_OK) {

View File

@ -9,7 +9,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <Errors.h> #include <Errors.h>
#include <SupportDefs.h> #include <StringList.h>
#include <package/Context.h> #include <package/Context.h>
#include <package/RefreshRepositoryRequest.h> #include <package/RefreshRepositoryRequest.h>
@ -74,7 +74,7 @@ command_refresh(int argc, const char* const* argv)
JobStateListener listener; JobStateListener listener;
BContext context(decisionProvider, listener); BContext context(decisionProvider, listener);
BObjectList<BString> repositoryNames(20, true); BStringList repositoryNames(20);
BPackageRoster roster; BPackageRoster roster;
if (nameCount == 0) { if (nameCount == 0) {
@ -83,16 +83,14 @@ command_refresh(int argc, const char* const* argv)
DIE(result, "can't collect repository names"); DIE(result, "can't collect repository names");
} else { } else {
for (int i = 0; i < nameCount; ++i) { for (int i = 0; i < nameCount; ++i) {
BString* repoName = new (std::nothrow) BString(repoArgs[i]); if (!repositoryNames.Add(repoArgs[i]))
if (repoName == NULL)
DIE(B_NO_MEMORY, "can't allocate repository name"); DIE(B_NO_MEMORY, "can't allocate repository name");
repositoryNames.AddItem(repoName);
} }
} }
status_t result; status_t result;
for (int i = 0; i < repositoryNames.CountItems(); ++i) { for (int i = 0; i < repositoryNames.CountStrings(); ++i) {
const BString& repoName = *(repositoryNames.ItemAt(i)); const BString& repoName = repositoryNames.StringAt(i);
BRepositoryConfig repoConfig; BRepositoryConfig repoConfig;
result = roster.GetRepositoryConfig(repoName, &repoConfig); result = roster.GetRepositoryConfig(repoName, &repoConfig);
if (result != B_OK) { if (result != B_OK) {

View File

@ -81,7 +81,7 @@ private:
bool releaseIsOptional); bool releaseIsOptional);
void _ParseList(ListElementParser& elementParser, void _ParseList(ListElementParser& elementParser,
bool allowSingleNonListElement); bool allowSingleNonListElement);
void _ParseStringList(BObjectList<BString>* value, void _ParseStringList(BStringList* value,
bool allowQuotedStrings = true, bool allowQuotedStrings = true,
bool convertToLowerCase = false); bool convertToLowerCase = false);
void _ParseResolvableList( void _ParseResolvableList(
@ -449,15 +449,15 @@ BPackageInfo::Parser::_ParseList(ListElementParser& elementParser,
void void
BPackageInfo::Parser::_ParseStringList(BObjectList<BString>* value, BPackageInfo::Parser::_ParseStringList(BStringList* value,
bool allowQuotedStrings, bool convertToLowerCase) bool allowQuotedStrings, bool convertToLowerCase)
{ {
struct StringParser : public ListElementParser { struct StringParser : public ListElementParser {
BObjectList<BString>* value; BStringList* value;
bool allowQuotedStrings; bool allowQuotedStrings;
bool convertToLowerCase; bool convertToLowerCase;
StringParser(BObjectList<BString>* value, bool allowQuotedStrings, StringParser(BStringList* value, bool allowQuotedStrings,
bool convertToLowerCase) bool convertToLowerCase)
: :
value(value), value(value),
@ -479,11 +479,11 @@ BPackageInfo::Parser::_ParseStringList(BObjectList<BString>* value,
throw ParseError("expected word", token.pos); throw ParseError("expected word", token.pos);
} }
BString* element = new BString(token.text); BString element(token.text);
if (convertToLowerCase) if (convertToLowerCase)
element->ToLower(); element.ToLower();
value->AddItem(element); value->Add(element);
} }
} stringParser(value, allowQuotedStrings, convertToLowerCase); } stringParser(value, allowQuotedStrings, convertToLowerCase);
@ -831,16 +831,16 @@ BPackageInfo::BPackageInfo()
: :
fFlags(0), fFlags(0),
fArchitecture(B_PACKAGE_ARCHITECTURE_ENUM_COUNT), fArchitecture(B_PACKAGE_ARCHITECTURE_ENUM_COUNT),
fCopyrightList(5, true), fCopyrightList(5),
fLicenseList(5, true), fLicenseList(5),
fURLList(5, true), fURLList(5),
fSourceURLList(5, true), fSourceURLList(5),
fProvidesList(20, true), fProvidesList(20, true),
fRequiresList(20, true), fRequiresList(20, true),
fSupplementsList(20, true), fSupplementsList(20, true),
fConflictsList(5, true), fConflictsList(5, true),
fFreshensList(5, true), fFreshensList(5, true),
fReplacesList(5, true) fReplacesList(5)
{ {
} }
@ -989,28 +989,28 @@ BPackageInfo::Version() const
} }
const BObjectList<BString>& const BStringList&
BPackageInfo::CopyrightList() const BPackageInfo::CopyrightList() const
{ {
return fCopyrightList; return fCopyrightList;
} }
const BObjectList<BString>& const BStringList&
BPackageInfo::LicenseList() const BPackageInfo::LicenseList() const
{ {
return fLicenseList; return fLicenseList;
} }
const BObjectList<BString>& const BStringList&
BPackageInfo::URLList() const BPackageInfo::URLList() const
{ {
return fURLList; return fURLList;
} }
const BObjectList<BString>& const BStringList&
BPackageInfo::SourceURLList() const BPackageInfo::SourceURLList() const
{ {
return fSourceURLList; return fSourceURLList;
@ -1052,7 +1052,7 @@ BPackageInfo::FreshensList() const
} }
const BObjectList<BString>& const BStringList&
BPackageInfo::ReplacesList() const BPackageInfo::ReplacesList() const
{ {
return fReplacesList; return fReplacesList;
@ -1140,11 +1140,7 @@ BPackageInfo::ClearCopyrightList()
status_t status_t
BPackageInfo::AddCopyright(const BString& copyright) BPackageInfo::AddCopyright(const BString& copyright)
{ {
BString* newCopyright = new (std::nothrow) BString(copyright); return fCopyrightList.Add(copyright) ? B_OK : B_ERROR;
if (newCopyright == NULL)
return B_NO_MEMORY;
return fCopyrightList.AddItem(newCopyright) ? B_OK : B_ERROR;
} }
@ -1158,11 +1154,7 @@ BPackageInfo::ClearLicenseList()
status_t status_t
BPackageInfo::AddLicense(const BString& license) BPackageInfo::AddLicense(const BString& license)
{ {
BString* newLicense = new (std::nothrow) BString(license); return fLicenseList.Add(license) ? B_OK : B_ERROR;
if (newLicense == NULL)
return B_NO_MEMORY;
return fLicenseList.AddItem(newLicense) ? B_OK : B_ERROR;
} }
@ -1176,11 +1168,7 @@ BPackageInfo::ClearURLList()
status_t status_t
BPackageInfo::AddURL(const BString& url) BPackageInfo::AddURL(const BString& url)
{ {
BString* newURL = new (std::nothrow) BString(url); return fURLList.Add(url) ? B_OK : B_NO_MEMORY;
if (newURL == NULL)
return B_NO_MEMORY;
return fURLList.AddItem(newURL) ? B_OK : B_NO_MEMORY;
} }
@ -1194,11 +1182,7 @@ BPackageInfo::ClearSourceURLList()
status_t status_t
BPackageInfo::AddSourceURL(const BString& url) BPackageInfo::AddSourceURL(const BString& url)
{ {
BString* newURL = new (std::nothrow) BString(url); return fSourceURLList.Add(url) ? B_OK : B_NO_MEMORY;
if (newURL == NULL)
return B_NO_MEMORY;
return fSourceURLList.AddItem(newURL) ? B_OK : B_NO_MEMORY;
} }
@ -1307,12 +1291,7 @@ BPackageInfo::ClearReplacesList()
status_t status_t
BPackageInfo::AddReplaces(const BString& replaces) BPackageInfo::AddReplaces(const BString& replaces)
{ {
BString* newReplaces = new (std::nothrow) BString(replaces); return fReplacesList.Add(BString(replaces).ToLower()) ? B_OK : B_ERROR;
if (newReplaces == NULL)
return B_NO_MEMORY;
newReplaces->ToLower();
return fReplacesList.AddItem(newReplaces) ? B_OK : B_ERROR;
} }

View File

@ -14,9 +14,9 @@
#include <Directory.h> #include <Directory.h>
#include <Entry.h> #include <Entry.h>
#include <ObjectList.h>
#include <Path.h> #include <Path.h>
#include <String.h> #include <String.h>
#include <StringList.h>
#include <package/RepositoryCache.h> #include <package/RepositoryCache.h>
#include <package/RepositoryConfig.h> #include <package/RepositoryConfig.h>
@ -89,10 +89,10 @@ BPackageRoster::VisitUserRepositoryConfigs(BRepositoryConfigVisitor& visitor)
status_t status_t
BPackageRoster::GetRepositoryNames(BObjectList<BString>& names) BPackageRoster::GetRepositoryNames(BStringList& names)
{ {
struct RepositoryNameCollector : public BRepositoryConfigVisitor { struct RepositoryNameCollector : public BRepositoryConfigVisitor {
RepositoryNameCollector(BObjectList<BString>& _names) RepositoryNameCollector(BStringList& _names)
: names(_names) : names(_names)
{ {
} }
@ -102,15 +102,15 @@ BPackageRoster::GetRepositoryNames(BObjectList<BString>& names)
status_t result = entry.GetName(name); status_t result = entry.GetName(name);
if (result != B_OK) if (result != B_OK)
return result; return result;
int32 count = names.CountItems(); int32 count = names.CountStrings();
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
if (names.ItemAt(i)->Compare(name) == 0) if (names.StringAt(i).Compare(name) == 0)
return B_OK; return B_OK;
} }
names.AddItem(new (std::nothrow) BString(name)); names.Add(name);
return B_OK; return B_OK;
} }
BObjectList<BString>& names; BStringList& names;
}; };
RepositoryNameCollector repositoryNameCollector(names); RepositoryNameCollector repositoryNameCollector(names);
status_t result = VisitUserRepositoryConfigs(repositoryNameCollector); status_t result = VisitUserRepositoryConfigs(repositoryNameCollector);

View File

@ -47,7 +47,7 @@ BRepositoryInfo::BRepositoryInfo()
BRepositoryInfo::BRepositoryInfo(BMessage* data) BRepositoryInfo::BRepositoryInfo(BMessage* data)
: :
inherited(data), inherited(data),
fLicenseTexts(5, true) fLicenseTexts(5)
{ {
fInitStatus = SetTo(data); fInitStatus = SetTo(data);
} }
@ -94,13 +94,13 @@ BRepositoryInfo::Archive(BMessage* data, bool deep) const
return result; return result;
if ((result = data->AddUInt8(kArchitectureField, fArchitecture)) != B_OK) if ((result = data->AddUInt8(kArchitectureField, fArchitecture)) != B_OK)
return result; return result;
for (int i = 0; i < fLicenseNames.CountItems(); ++i) { for (int i = 0; i < fLicenseNames.CountStrings(); ++i) {
result = data->AddString(kLicenseNameField, *fLicenseNames.ItemAt(i)); result = data->AddString(kLicenseNameField, fLicenseNames.StringAt(i));
if (result != B_OK) if (result != B_OK)
return result; return result;
} }
for (int i = 0; i < fLicenseTexts.CountItems(); ++i) { for (int i = 0; i < fLicenseTexts.CountStrings(); ++i) {
result = data->AddString(kLicenseTextField, *fLicenseTexts.ItemAt(i)); result = data->AddString(kLicenseTextField, fLicenseTexts.StringAt(i));
if (result != B_OK) if (result != B_OK)
return result; return result;
} }
@ -146,11 +146,7 @@ BRepositoryInfo::SetTo(const BMessage* data)
data->FindString(kLicenseNameField, i, &licenseName) == B_OK data->FindString(kLicenseNameField, i, &licenseName) == B_OK
&& data->FindString(kLicenseTextField, i, &licenseText) == B_OK; && data->FindString(kLicenseTextField, i, &licenseText) == B_OK;
++i) { ++i) {
BString* newLicenseName = new (std::nothrow) BString(licenseName); if (!fLicenseNames.Add(licenseName) || !fLicenseTexts.Add(licenseText))
if (newLicenseName == NULL || !fLicenseNames.AddItem(newLicenseName))
return B_NO_MEMORY;
BString* newLicenseText = new (std::nothrow) BString(licenseText);
if (newLicenseText == NULL || !fLicenseTexts.AddItem(newLicenseText))
return B_NO_MEMORY; return B_NO_MEMORY;
} }
@ -269,14 +265,14 @@ BRepositoryInfo::Architecture() const
} }
const BObjectList<BString>& const BStringList&
BRepositoryInfo::LicenseNames() const BRepositoryInfo::LicenseNames() const
{ {
return fLicenseNames; return fLicenseNames;
} }
const BObjectList<BString>& const BStringList&
BRepositoryInfo::LicenseTexts() const BRepositoryInfo::LicenseTexts() const
{ {
return fLicenseTexts; return fLicenseTexts;
@ -329,12 +325,7 @@ status_t
BRepositoryInfo::AddLicense(const BString& licenseName, BRepositoryInfo::AddLicense(const BString& licenseName,
const BString& licenseText) const BString& licenseText)
{ {
BString* newLicenseName = new (std::nothrow) BString(licenseName); if (!fLicenseNames.Add(licenseName) || !fLicenseTexts.Add(licenseText))
if (newLicenseName == NULL || !fLicenseNames.AddItem(newLicenseName))
return B_NO_MEMORY;
BString* newLicenseText = new (std::nothrow) BString(licenseText);
if (newLicenseText == NULL || !fLicenseTexts.AddItem(newLicenseText))
return B_NO_MEMORY; return B_NO_MEMORY;
return B_OK; return B_OK;

View File

@ -681,9 +681,9 @@ PackageWriterImpl::_CheckLicenses()
BDirectory systemLicenseDir(systemLicensePath.Path()); BDirectory systemLicenseDir(systemLicensePath.Path());
const BObjectList<BString>& licenseList = fPackageInfo.LicenseList(); const BStringList& licenseList = fPackageInfo.LicenseList();
for (int i = 0; i < licenseList.CountItems(); ++i) { for (int i = 0; i < licenseList.CountStrings(); ++i) {
const BString& licenseName = *licenseList.ItemAt(i); const BString& licenseName = licenseList.StringAt(i);
if (licenseName == kPublicDomainLicenseName) if (licenseName == kPublicDomainLicenseName)
continue; continue;

View File

@ -119,10 +119,9 @@ struct PackageContentHandler : public BPackageContentHandler {
return B_OK; return B_OK;
// check if license already is in repository // check if license already is in repository
const BObjectList<BString>& licenseNames const BStringList& licenseNames = fRepositoryInfo->LicenseNames();
= fRepositoryInfo->LicenseNames(); for (int i = 0; i < licenseNames.CountStrings(); ++i) {
for (int i = 0; i < licenseNames.CountItems(); ++i) { if (licenseNames.StringAt(i).ICompare(entry->Name()) == 0) {
if (licenseNames.ItemAt(i)->ICompare(entry->Name()) == 0) {
// license already exists // license already exists
return B_OK; return B_OK;
} }
@ -365,7 +364,7 @@ RepositoryWriterImpl::_Finish()
sizeof(header) + infoLengthCompressed, packagesLengthCompressed); sizeof(header) + infoLengthCompressed, packagesLengthCompressed);
fListener->OnRepositoryDone(sizeof(header), infoLengthCompressed, fListener->OnRepositoryDone(sizeof(header), infoLengthCompressed,
fRepositoryInfo->LicenseNames().CountItems(), fPackageCount, fRepositoryInfo->LicenseNames().CountStrings(), fPackageCount,
packagesLengthCompressed, totalSize); packagesLengthCompressed, totalSize);
// general // general

View File

@ -417,46 +417,43 @@ WriterImplBase::RegisterPackageInfo(PackageAttributeList& attributeList,
RegisterPackageVersion(attributeList, packageInfo.Version()); RegisterPackageVersion(attributeList, packageInfo.Version());
// copyright list // copyright list
const BObjectList<BString>& copyrightList = packageInfo.CopyrightList(); const BStringList& copyrightList = packageInfo.CopyrightList();
for (int i = 0; i < copyrightList.CountItems(); ++i) { for (int i = 0; i < copyrightList.CountStrings(); ++i) {
PackageAttribute* copyright = new PackageAttribute( PackageAttribute* copyright = new PackageAttribute(
B_HPKG_ATTRIBUTE_ID_PACKAGE_COPYRIGHT, B_HPKG_ATTRIBUTE_TYPE_STRING, B_HPKG_ATTRIBUTE_ID_PACKAGE_COPYRIGHT, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE); B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE);
copyright->string copyright->string = fPackageStringCache.Get(copyrightList.StringAt(i));
= fPackageStringCache.Get(copyrightList.ItemAt(i)->String());
attributeList.Add(copyright); attributeList.Add(copyright);
} }
// license list // license list
const BObjectList<BString>& licenseList = packageInfo.LicenseList(); const BStringList& licenseList = packageInfo.LicenseList();
for (int i = 0; i < licenseList.CountItems(); ++i) { for (int i = 0; i < licenseList.CountStrings(); ++i) {
PackageAttribute* license = new PackageAttribute( PackageAttribute* license = new PackageAttribute(
B_HPKG_ATTRIBUTE_ID_PACKAGE_LICENSE, B_HPKG_ATTRIBUTE_TYPE_STRING, B_HPKG_ATTRIBUTE_ID_PACKAGE_LICENSE, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE); B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE);
license->string license->string = fPackageStringCache.Get(licenseList.StringAt(i));
= fPackageStringCache.Get(licenseList.ItemAt(i)->String());
attributeList.Add(license); attributeList.Add(license);
} }
// URL list // URL list
const BObjectList<BString>& urlList = packageInfo.URLList(); const BStringList& urlList = packageInfo.URLList();
for (int i = 0; i < urlList.CountItems(); ++i) { for (int i = 0; i < urlList.CountStrings(); ++i) {
PackageAttribute* url = new PackageAttribute( PackageAttribute* url = new PackageAttribute(
B_HPKG_ATTRIBUTE_ID_PACKAGE_URL, B_HPKG_ATTRIBUTE_TYPE_STRING, B_HPKG_ATTRIBUTE_ID_PACKAGE_URL, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE); B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE);
url->string = fPackageStringCache.Get(urlList.ItemAt(i)->String()); url->string = fPackageStringCache.Get(urlList.StringAt(i));
attributeList.Add(url); attributeList.Add(url);
} }
// source URL list // source URL list
const BObjectList<BString>& sourceURLList = packageInfo.SourceURLList(); const BStringList& sourceURLList = packageInfo.SourceURLList();
for (int i = 0; i < sourceURLList.CountItems(); ++i) { for (int i = 0; i < sourceURLList.CountStrings(); ++i) {
PackageAttribute* url = new PackageAttribute( PackageAttribute* url = new PackageAttribute(
B_HPKG_ATTRIBUTE_ID_PACKAGE_SOURCE_URL, B_HPKG_ATTRIBUTE_ID_PACKAGE_SOURCE_URL,
B_HPKG_ATTRIBUTE_TYPE_STRING, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE); B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE);
url->string = fPackageStringCache.Get( url->string = fPackageStringCache.Get(sourceURLList.StringAt(i));
sourceURLList.ItemAt(i)->String());
attributeList.Add(url); attributeList.Add(url);
} }
@ -508,13 +505,12 @@ WriterImplBase::RegisterPackageInfo(PackageAttributeList& attributeList,
packageInfo.FreshensList(), B_HPKG_ATTRIBUTE_ID_PACKAGE_FRESHENS); packageInfo.FreshensList(), B_HPKG_ATTRIBUTE_ID_PACKAGE_FRESHENS);
// replaces list // replaces list
const BObjectList<BString>& replacesList = packageInfo.ReplacesList(); const BStringList& replacesList = packageInfo.ReplacesList();
for (int i = 0; i < replacesList.CountItems(); ++i) { for (int i = 0; i < replacesList.CountStrings(); ++i) {
PackageAttribute* replaces = new PackageAttribute( PackageAttribute* replaces = new PackageAttribute(
B_HPKG_ATTRIBUTE_ID_PACKAGE_REPLACES, B_HPKG_ATTRIBUTE_TYPE_STRING, B_HPKG_ATTRIBUTE_ID_PACKAGE_REPLACES, B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE); B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE);
replaces->string replaces->string = fPackageStringCache.Get(replacesList.StringAt(i));
= fPackageStringCache.Get(replacesList.ItemAt(i)->String());
attributeList.Add(replaces); attributeList.Add(replaces);
} }