BPicture: Fix archive constructor.
[haiku.git] / src / kits / package / PackageResolvable.cpp
blobb604303b5fbc95a9e51ebadccf5c456a5246083f
1 /*
2 * Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
3 * Distributed under the terms of the MIT License.
4 */
7 #include <package/PackageResolvable.h>
9 #include <package/hpkg/PackageInfoAttributeValue.h>
12 namespace BPackageKit {
15 BPackageResolvable::BPackageResolvable()
20 BPackageResolvable::BPackageResolvable(const BPackageResolvableData& data)
22 fName(data.name),
23 fVersion(data.version),
24 fCompatibleVersion(data.compatibleVersion)
29 BPackageResolvable::BPackageResolvable(const BString& name,
30 const BPackageVersion& version, const BPackageVersion& compatibleVersion)
32 fName(name),
33 fVersion(version),
34 fCompatibleVersion(compatibleVersion)
36 fName.ToLower();
40 status_t
41 BPackageResolvable::InitCheck() const
43 return fName.Length() > 0 ? B_OK : B_NO_INIT;
47 const BString&
48 BPackageResolvable::Name() const
50 return fName;
54 const BPackageVersion&
55 BPackageResolvable::Version() const
57 return fVersion;
61 const BPackageVersion&
62 BPackageResolvable::CompatibleVersion() const
64 return fCompatibleVersion;
68 BString
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();
80 return string;
84 void
85 BPackageResolvable::SetTo(const BString& name, const BPackageVersion& version,
86 const BPackageVersion& compatibleVersion)
88 fName = name;
89 fVersion = version;
90 fCompatibleVersion = compatibleVersion;
92 fName.ToLower();
96 void
97 BPackageResolvable::Clear()
99 fName.Truncate(0);
100 fVersion.Clear();
101 fCompatibleVersion.Clear();
105 } // namespace BPackageKit