xref: /haiku/headers/private/support/Uuid.h (revision 21258e2674226d6aa732321b6f8494841895af5f)
1 /*
2  * Copyright 2013, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _UUID_H_
6 #define _UUID_H_
7 
8 
9 #include <String.h>
10 
11 
12 namespace BPrivate {
13 
14 
15 class BUuid {
16 public:
17 								BUuid();
18 								BUuid(const BUuid& other);
19 								~BUuid();
20 
21 			bool				IsNil() const;
22 
23 			BUuid&				SetToRandom();
24 
25 			BString				ToString() const;
26 
27 			int					Compare(const BUuid& other) const;
28 
29 	inline	bool				operator==(const BUuid& other) const;
30 	inline	bool				operator!=(const BUuid& other) const;
31 
32 	inline	bool				operator<(const BUuid& other) const;
33 	inline	bool				operator>(const BUuid& other) const;
34 	inline	bool				operator<=(const BUuid& other) const;
35 	inline	bool				operator>=(const BUuid& other) const;
36 
37 			BUuid&				operator=(const BUuid& other);
38 
39 private:
40 			bool				_SetToDevRandom();
41 			void				_SetToRandomFallback();
42 
43 private:
44 			uint8				fValue[16];
45 };
46 
47 
48 inline bool
49 BUuid::operator==(const BUuid& other) const
50 {
51 	return Compare(other) == 0;
52 }
53 
54 
55 inline bool
56 BUuid::operator!=(const BUuid& other) const
57 {
58 	return Compare(other) != 0;
59 }
60 
61 
62 inline bool
63 BUuid::operator<(const BUuid& other) const
64 {
65 	return Compare(other) < 0;
66 }
67 
68 
69 inline bool
70 BUuid::operator>(const BUuid& other) const
71 {
72 	return Compare(other) > 0;
73 }
74 
75 
76 inline bool
77 BUuid::operator<=(const BUuid& other) const
78 {
79 	return Compare(other) <= 0;
80 }
81 
82 
83 inline bool
84 BUuid::operator>=(const BUuid& other) const
85 {
86 	return Compare(other) >= 0;
87 }
88 
89 
90 }	// namespace BPrivate
91 
92 
93 using BPrivate::BUuid;
94 
95 
96 #endif	// _UUID_H_
97