xref: /haiku/src/add-ons/kernel/file_systems/packagefs/util/Version.h (revision 9f81ca838ce7b92b5689e57d3f86765db4705a7b)
1 /*
2  * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef VERSION_H
6 #define VERSION_H
7 
8 
9 #include <package/PackageResolvableOperator.h>
10 #include <SupportDefs.h>
11 
12 #include "String.h"
13 
14 
15 using namespace BPackageKit;
16 
17 
18 class Version {
19 public:
20 								Version();
21 								~Version();
22 
23 			status_t			Init(const char* major, const char* minor,
24 									const char* micro, const char* preRelease,
25 									uint32 revision);
26 
27 	static	status_t			Create(const char* major, const char* minor,
28 									const char* micro, const char* preRelease,
29 									uint32 revision, Version*& _version);
30 
31 			int					Compare(const Version& other) const;
32 			bool				Compare(BPackageResolvableOperator op,
33 									const Version& other) const;
34 
35 			size_t				ToString(char* buffer, size_t bufferSize) const;
36 									// returns how big the buffer should have
37 									// been (excluding the terminating null)
38 
39 private:
40 			String				fMajor;
41 			String				fMinor;
42 			String				fMicro;
43 			String				fPreRelease;
44 			uint32				fRevision;
45 };
46 
47 
48 #endif	// VERSION_H
49