xref: /haiku/headers/os/package/hpkg/PackageInfoAttributeValue.h (revision a5a3b2d9a3d95cbae71eaf371708c73a1780ac0d)
1 /*
2  * Copyright 2009,2011, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__HPKG__PACKAGE_INFO_ATTRIBUTE_VALUE_H_
6 #define _PACKAGE__HPKG__PACKAGE_INFO_ATTRIBUTE_VALUE_H_
7 
8 
9 #include <SupportDefs.h>
10 
11 #include <string.h>
12 
13 #include <package/PackageArchitecture.h>
14 #include <package/PackageInfoAttributes.h>
15 #include <package/PackageResolvableOperator.h>
16 #include <package/WritableFileUpdateType.h>
17 
18 
19 namespace BPackageKit {
20 
21 namespace BHPKG {
22 
23 
24 struct BPackageVersionData {
25 			const char*			major;
26 			const char*			minor;
27 			const char*			micro;
28 			const char*			preRelease;
29 			uint32				revision;
30 };
31 
32 
33 struct BPackageResolvableData {
34 			const char*			name;
35 			bool				haveVersion;
36 			bool				haveCompatibleVersion;
37 			BPackageVersionData	version;
38 			BPackageVersionData	compatibleVersion;
39 };
40 
41 
42 struct BPackageResolvableExpressionData {
43 			const char*			name;
44 			bool				haveOpAndVersion;
45 			BPackageResolvableOperator	op;
46 			BPackageVersionData	version;
47 };
48 
49 
50 struct BGlobalWritableFileInfoData {
51 	const char*				path;
52 	BWritableFileUpdateType	updateType;
53 	bool					isDirectory;
54 };
55 
56 
57 struct BUserSettingsFileInfoData {
58 	const char*	path;
59 	const char*	templatePath;
60 	bool		isDirectory;
61 };
62 
63 
64 struct BUserData {
65 	const char*			name;
66 	const char*			realName;
67 	const char*			home;
68 	const char*			shell;
69 	const char* const*	groups;
70 	size_t				groupCount;
71 };
72 
73 
74 struct BPackageInfoAttributeValue {
75 			union {
76 				uint64			unsignedInt;
77 				const char*		string;
78 				BPackageVersionData version;
79 				BPackageResolvableData resolvable;
80 				BPackageResolvableExpressionData resolvableExpression;
81 				BGlobalWritableFileInfoData globalWritableFileInfo;
82 				BUserSettingsFileInfoData userSettingsFileInfo;
83 				BUserData		user;
84 			};
85 			BPackageInfoAttributeID	attributeID;
86 
87 public:
88 								BPackageInfoAttributeValue();
89 
90 			void				SetTo(BPackageInfoAttributeID id,
91 									uint8 value);
92 			void				SetTo(BPackageInfoAttributeID id,
93 									const char* value);
94 
95 			void				Clear();
96 };
97 
98 
99 inline
100 BPackageInfoAttributeValue::BPackageInfoAttributeValue()
101 {
102 	Clear();
103 }
104 
105 
106 inline void
107 BPackageInfoAttributeValue::SetTo(BPackageInfoAttributeID id, uint8 value)
108 {
109 	attributeID = id;
110 	unsignedInt = value;
111 }
112 
113 
114 inline void
115 BPackageInfoAttributeValue::SetTo(BPackageInfoAttributeID id,
116 	const char* value)
117 {
118 	attributeID = id;
119 	string = value;
120 }
121 
122 
123 inline void
124 BPackageInfoAttributeValue::Clear()
125 {
126 	memset(this, 0, sizeof(BPackageInfoAttributeValue));
127 	attributeID = B_PACKAGE_INFO_ENUM_COUNT;
128 }
129 
130 
131 }	// namespace BHPKG
132 
133 }	// namespace BPackageKit
134 
135 
136 #endif	// _PACKAGE__HPKG__PACKAGE_ATTRIBUTE_VALUE_H_
137