BPackageInfo: Add Matches()

Checks whether the package satisfies the given
BPackageResolvableExpression.
This commit is contained in:
Ingo Weinhold 2013-08-28 00:12:11 +02:00
parent 48e17c15bc
commit bc0491ae52
2 changed files with 24 additions and 0 deletions

View File

@ -105,6 +105,9 @@ public:
BString CanonicalFileName() const;
bool Matches(const BPackageResolvableExpression&
expression) const;
void SetName(const BString& name);
void SetSummary(const BString& summary);
void SetDescription(const BString& description);

View File

@ -582,6 +582,27 @@ BPackageInfo::CanonicalFileName() const
}
bool
BPackageInfo::Matches(const BPackageResolvableExpression& expression) const
{
// check for an explicit match on the package
if (expression.Name().StartsWith("pkg:")) {
return fName == expression.Name().String() + 4
&& expression.Matches(fVersion, fVersion);
}
// search for a matching provides
int32 count = fProvidesList.CountItems();
for (int32 i = 0; i < count; i++) {
const BPackageResolvable* provides = fProvidesList.ItemAt(i);
if (expression.Matches(*provides))
return true;
}
return false;
}
void
BPackageInfo::SetName(const BString& name)
{