2011-01-29 20:59:58 +03: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 22:11:23 +03:00
|
|
|
namespace BHPKG {
|
|
|
|
class BPackageVersionData;
|
|
|
|
}
|
|
|
|
using BHPKG::BPackageVersionData;
|
|
|
|
|
|
|
|
|
2011-01-29 20:59:58 +03:00
|
|
|
class BPackageVersion {
|
|
|
|
public:
|
|
|
|
BPackageVersion();
|
2011-02-09 22:11:23 +03:00
|
|
|
BPackageVersion(
|
|
|
|
const BPackageVersionData& data);
|
2013-04-11 02:36:10 +04:00
|
|
|
explicit BPackageVersion(const BString& versionString,
|
2013-04-16 02:05:19 +04:00
|
|
|
bool revisionIsOptional = true);
|
2011-01-29 20:59:58 +03:00
|
|
|
BPackageVersion(const BString& major,
|
|
|
|
const BString& minor, const BString& micro,
|
2013-04-16 02:05:19 +04:00
|
|
|
const BString& preRelease, uint32 revision);
|
2011-01-29 20:59:58 +03:00
|
|
|
|
|
|
|
status_t InitCheck() const;
|
|
|
|
|
2011-02-02 01:01:17 +03:00
|
|
|
const BString& Major() const;
|
|
|
|
const BString& Minor() const;
|
|
|
|
const BString& Micro() const;
|
2011-06-27 03:53:01 +04:00
|
|
|
const BString& PreRelease() const;
|
|
|
|
// "alpha3", "beta2", "rc1" or "" if final
|
2013-04-16 02:05:19 +04:00
|
|
|
uint32 Revision() const;
|
2011-02-02 01:01:17 +03:00
|
|
|
|
2011-02-04 20:53:54 +03:00
|
|
|
BString ToString() const;
|
2011-01-29 20:59:58 +03:00
|
|
|
|
|
|
|
void SetTo(const BString& major,
|
|
|
|
const BString& minor, const BString& micro,
|
2013-04-16 02:05:19 +04:00
|
|
|
const BString& preRelease, uint32 revision);
|
2013-04-03 06:06:26 +04:00
|
|
|
status_t SetTo(const BString& versionString,
|
2013-04-16 02:05:19 +04:00
|
|
|
bool revisionIsOptional = true);
|
2011-01-29 20:59:58 +03:00
|
|
|
void Clear();
|
|
|
|
|
|
|
|
int Compare(const BPackageVersion& other) const;
|
|
|
|
// does a natural compare over major, minor
|
2013-04-16 02:05:19 +04:00
|
|
|
// and micro, finally comparing revision
|
2011-01-29 20:59:58 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
BString fMajor;
|
|
|
|
BString fMinor;
|
|
|
|
BString fMicro;
|
2011-06-27 03:53:01 +04:00
|
|
|
BString fPreRelease;
|
2013-04-16 02:05:19 +04:00
|
|
|
uint32 fRevision;
|
2011-01-29 20:59:58 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _PACKAGE__PACKAGE_VERSION_H_
|