2 * Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
3 * Distributed under the terms of the MIT License.
7 #include <package/PackageResolvable.h>
9 #include <package/hpkg/PackageInfoAttributeValue.h>
12 namespace BPackageKit
{
15 BPackageResolvable::BPackageResolvable()
20 BPackageResolvable::BPackageResolvable(const BPackageResolvableData
& data
)
23 fVersion(data
.version
),
24 fCompatibleVersion(data
.compatibleVersion
)
29 BPackageResolvable::BPackageResolvable(const BString
& name
,
30 const BPackageVersion
& version
, const BPackageVersion
& compatibleVersion
)
34 fCompatibleVersion(compatibleVersion
)
41 BPackageResolvable::InitCheck() const
43 return fName
.Length() > 0 ? B_OK
: B_NO_INIT
;
48 BPackageResolvable::Name() const
54 const BPackageVersion
&
55 BPackageResolvable::Version() const
61 const BPackageVersion
&
62 BPackageResolvable::CompatibleVersion() const
64 return fCompatibleVersion
;
69 BPackageResolvable::ToString() const
71 // the type is part of the name
72 BString string
= fName
;
74 if (fVersion
.InitCheck() == B_OK
)
75 string
<< '=' << fVersion
.ToString();
77 if (fCompatibleVersion
.InitCheck() == B_OK
)
78 string
<< " compat>=" << fCompatibleVersion
.ToString();
85 BPackageResolvable::SetTo(const BString
& name
, const BPackageVersion
& version
,
86 const BPackageVersion
& compatibleVersion
)
90 fCompatibleVersion
= compatibleVersion
;
97 BPackageResolvable::Clear()
101 fCompatibleVersion
.Clear();
105 } // namespace BPackageKit