BPackageResolvable: Add compatibleVersion property

This commit is contained in:
Ingo Weinhold 2011-06-27 03:48:00 +02:00
parent ea754ce710
commit 4438ef7a2c
2 changed files with 30 additions and 8 deletions

View File

@ -23,10 +23,11 @@ using BHPKG::BPackageResolvableData;
/*
* Defines a resolvable (something other packages can depend upon).
* Each resolvable is defined as a name (with an optional type prefix)
* and an optional version.
* Each resolvable is defined as a name (with an optional type prefix),
* an optional version, and an optional compatibility version (the least
* version the resolvable is backwards compatible with).
*
* resolvable ::= <name>['='<version>]
* resolvable ::= <name>['='<version>]['compat' '>=' <version>]
* name ::= [<type>':']<word>
* type ::= 'lib' | 'cmd' | 'app' | 'add_on'
*
@ -39,7 +40,7 @@ using BHPKG::BPackageResolvableData;
* String examples:
* haiku=r1
* lib:libssl=0.9.8i
* subversion=1.5
* subversion=1.5 compat>=1.0
* cmd:svn
*/
class BPackageResolvable {
@ -51,6 +52,8 @@ public:
BPackageResolvableType type
= B_PACKAGE_RESOLVABLE_TYPE_DEFAULT,
const BPackageVersion& version
= BPackageVersion(),
const BPackageVersion& compatibleVersion
= BPackageVersion());
status_t InitCheck() const;
@ -58,6 +61,7 @@ public:
const BString& Name() const;
BPackageResolvableType Type() const;
const BPackageVersion& Version() const;
const BPackageVersion& CompatibleVersion() const;
BString ToString() const;
@ -65,6 +69,8 @@ public:
BPackageResolvableType type
= B_PACKAGE_RESOLVABLE_TYPE_DEFAULT,
const BPackageVersion& version
= BPackageVersion(),
const BPackageVersion& compatibleVersion
= BPackageVersion());
void Clear();
@ -75,6 +81,7 @@ private:
BString fName;
BPackageResolvableType fType;
BPackageVersion fVersion;
BPackageVersion fCompatibleVersion;
};

View File

@ -33,17 +33,20 @@ BPackageResolvable::BPackageResolvable(const BPackageResolvableData& data)
:
fName(data.name),
fType(data.type),
fVersion(data.version)
fVersion(data.version),
fCompatibleVersion(data.compatibleVersion)
{
}
BPackageResolvable::BPackageResolvable(const BString& name,
BPackageResolvableType type, const BPackageVersion& version)
BPackageResolvableType type, const BPackageVersion& version,
const BPackageVersion& compatibleVersion)
:
fName(name),
fType(type),
fVersion(version)
fVersion(version),
fCompatibleVersion(compatibleVersion)
{
}
@ -76,6 +79,13 @@ BPackageResolvable::Version() const
}
const BPackageVersion&
BPackageResolvable::CompatibleVersion() const
{
return fCompatibleVersion;
}
BString
BPackageResolvable::ToString() const
{
@ -85,17 +95,21 @@ BPackageResolvable::ToString() const
if (fVersion.InitCheck() == B_OK)
string << '=' << fVersion.ToString();
if (fCompatibleVersion.InitCheck() == B_OK)
string << " compat>=" << fCompatibleVersion.ToString();
return string;
}
void
BPackageResolvable::SetTo(const BString& name, BPackageResolvableType type,
const BPackageVersion& version)
const BPackageVersion& version, const BPackageVersion& compatibleVersion)
{
fName = name;
fType = type;
fVersion = version;
fCompatibleVersion = compatibleVersion;
}
@ -104,6 +118,7 @@ BPackageResolvable::Clear()
{
fName.Truncate(0);
fVersion.Clear();
fCompatibleVersion.Clear();
}