xref: /haiku/headers/os/package/hpkg/v1/PackageContentHandler.h (revision 7c234361eb70458273aba20f16643d7514536f1c)
1 /*
2  * Copyright 2009,2011, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__HPKG__V1__PACKAGE_CONTENT_HANDLER_H_
6 #define _PACKAGE__HPKG__V1__PACKAGE_CONTENT_HANDLER_H_
7 
8 
9 #include <SupportDefs.h>
10 
11 #include <package/hpkg/v1/HPKGDefs.h>
12 
13 
14 namespace BPackageKit {
15 
16 namespace BHPKG {
17 
18 
19 struct BPackageInfoAttributeValue;
20 
21 
22 namespace V1 {
23 
24 
25 struct BPackageAttributeValue;
26 class BPackageEntry;
27 class BPackageEntryAttribute;
28 
29 
30 class BLowLevelPackageContentHandler {
31 public:
32 	virtual						~BLowLevelPackageContentHandler();
33 
34 	virtual	status_t			HandleSectionStart(
35 									BHPKGPackageSectionID sectionID,
36 									bool& _handleSection) = 0;
37 	virtual	status_t			HandleSectionEnd(
38 									BHPKGPackageSectionID sectionID) = 0;
39 
40 	virtual	status_t			HandleAttribute(BHPKGAttributeID attributeID,
41 									const BPackageAttributeValue& value,
42 									void* parentToken, void*& _token) = 0;
43 	virtual	status_t			HandleAttributeDone(
44 									BHPKGAttributeID attributeID,
45 									const BPackageAttributeValue& value,
46 									void* parentToken, void* token) = 0;
47 
48 	virtual	void				HandleErrorOccurred() = 0;
49 
50 protected:
51 	static	const char*			AttributeNameForID(uint8 id);
52 };
53 
54 
55 class BPackageContentHandler {
56 public:
57 	virtual						~BPackageContentHandler();
58 
59 	virtual	status_t			HandleEntry(BPackageEntry* entry) = 0;
60 	virtual	status_t			HandleEntryAttribute(BPackageEntry* entry,
61 									BPackageEntryAttribute* attribute) = 0;
62 	virtual	status_t			HandleEntryDone(BPackageEntry* entry) = 0;
63 
64 	virtual	status_t			HandlePackageAttribute(
65 									const BPackageInfoAttributeValue& value
66 									) = 0;
67 
68 	virtual	void				HandleErrorOccurred() = 0;
69 };
70 
71 
72 }	// namespace V1
73 
74 }	// namespace BHPKG
75 
76 }	// namespace BPackageKit
77 
78 
79 #endif	// _PACKAGE__HPKG__V1__PACKAGE_CONTENT_HANDLER_H_
80