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