Files
haiku-beta6/headers/os/package/PackageVersion.h
T

116 lines
2.6 KiB
C++
Raw Normal View History

2011-01-29 17:59:58 +00:00
/*
* Copyright 2011, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _PACKAGE__PACKAGE_VERSION_H_
#define _PACKAGE__PACKAGE_VERSION_H_
#include <String.h>
namespace BPackageKit {
2011-02-09 19:11:23 +00:00
namespace BHPKG {
2018-08-18 11:20:04 +09:00
struct BPackageVersionData;
2011-02-09 19:11:23 +00:00
}
using BHPKG::BPackageVersionData;
2011-01-29 17:59:58 +00:00
class BPackageVersion {
public:
BPackageVersion();
2011-02-09 19:11:23 +00:00
BPackageVersion(
const BPackageVersionData& data);
explicit BPackageVersion(const BString& versionString,
bool revisionIsOptional = true);
2011-01-29 17:59:58 +00:00
BPackageVersion(const BString& major,
const BString& minor, const BString& micro,
const BString& preRelease, uint32 revision);
2011-01-29 17:59:58 +00:00
status_t InitCheck() const;
const BString& Major() const;
const BString& Minor() const;
const BString& Micro() const;
2011-06-27 01:53:01 +02:00
const BString& PreRelease() const;
// "alpha3", "beta2", "rc1" or "" if final
uint32 Revision() const;
BString ToString() const;
2011-01-29 17:59:58 +00:00
void SetTo(const BString& major,
const BString& minor, const BString& micro,
const BString& preRelease, uint32 revision);
2013-04-03 02:06:26 +00:00
status_t SetTo(const BString& versionString,
bool revisionIsOptional = true);
2011-01-29 17:59:58 +00:00
void Clear();
int Compare(const BPackageVersion& other) const;
// does a natural compare over major, minor
// and micro, finally comparing revision
2011-01-29 17:59:58 +00:00
2013-11-27 15:32:39 +01:00
inline bool operator==(const BPackageVersion& other) const;
inline bool operator!=(const BPackageVersion& other) const;
inline bool operator<(const BPackageVersion& other) const;
inline bool operator>(const BPackageVersion& other) const;
inline bool operator<=(const BPackageVersion& other) const;
inline bool operator>=(const BPackageVersion& other) const;
2011-01-29 17:59:58 +00:00
private:
BString fMajor;
BString fMinor;
BString fMicro;
2011-06-27 01:53:01 +02:00
BString fPreRelease;
uint32 fRevision;
2011-01-29 17:59:58 +00:00
};
2013-11-27 15:32:39 +01:00
inline bool
BPackageVersion::operator==(const BPackageVersion& other) const
{
return Compare(other) == 0;
}
inline bool
BPackageVersion::operator!=(const BPackageVersion& other) const
{
return Compare(other) != 0;
}
inline bool
BPackageVersion::operator<(const BPackageVersion& other) const
{
return Compare(other) < 0;
}
inline bool
BPackageVersion::operator>(const BPackageVersion& other) const
{
return Compare(other) > 0;
}
inline bool
BPackageVersion::operator<=(const BPackageVersion& other) const
{
return Compare(other) <= 0;
}
inline bool
BPackageVersion::operator>=(const BPackageVersion& other) const
{
return Compare(other) >= 0;
}
2011-01-29 17:59:58 +00:00
} // namespace BPackageKit
#endif // _PACKAGE__PACKAGE_VERSION_H_