xref: /haiku/headers/os/package/PackageVersion.h (revision 98057dd02a2411868fd4c35f7a48d20acfd92c23)
1 /*
2  * Copyright 2011, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__PACKAGE_VERSION_H_
6 #define _PACKAGE__PACKAGE_VERSION_H_
7 
8 
9 #include <String.h>
10 
11 
12 namespace BPackageKit {
13 
14 
15 namespace BHPKG {
16 	class BPackageVersionData;
17 }
18 using BHPKG::BPackageVersionData;
19 
20 
21 class BPackageVersion {
22 public:
23 								BPackageVersion();
24 								BPackageVersion(
25 									const BPackageVersionData& data);
26 								BPackageVersion(const BString& major,
27 									const BString& minor, const BString& micro,
28 									const BString& preRelease, uint8 release);
29 
30 			status_t			InitCheck() const;
31 
32 			const BString&		Major() const;
33 			const BString&		Minor() const;
34 			const BString&		Micro() const;
35 			const BString&		PreRelease() const;
36 									// "alpha3", "beta2", "rc1" or "" if final
37 			uint8				Release() const;
38 
39 			BString				ToString() const;
40 
41 			void				SetTo(const BString& major,
42 									const BString& minor, const BString& micro,
43 									const BString& preRelease, uint8 release);
44 			void				Clear();
45 
46 			int					Compare(const BPackageVersion& other) const;
47 									// does a natural compare over major, minor
48 									// and micro, finally comparing release
49 
50 private:
51 			BString				fMajor;
52 			BString				fMinor;
53 			BString				fMicro;
54 			BString				fPreRelease;
55 			uint8				fRelease;
56 };
57 
58 
59 }	// namespace BPackageKit
60 
61 
62 #endif	// _PACKAGE__PACKAGE_VERSION_H_
63