Add BLowLevelPackageContentHandler section hooks

* Add hooks HandleSectionStart() and HandleSectionEnd(). They are
  invoked to bracket package file section, so the handler can
  discriminate which section the attributes belong to.
  HandleSectionStart() features a return parameter _handleSection, which
  allows to handler to pick which sections it wants to handle.
* "package dump" does now print the section names.
This commit is contained in:
Ingo Weinhold
2011-11-25 06:18:55 +01:00
parent f9caa05c2a
commit 78811461b1
6 changed files with 122 additions and 20 deletions
@@ -26,6 +26,12 @@ class BLowLevelPackageContentHandler {
public:
virtual ~BLowLevelPackageContentHandler();
virtual status_t HandleSectionStart(
BHPKGPackageSectionID sectionID,
bool& _handleSection) = 0;
virtual status_t HandleSectionEnd(
BHPKGPackageSectionID sectionID) = 0;
virtual status_t HandleAttribute(BHPKGAttributeID attributeID,
const BPackageAttributeValue& value,
void* parentToken, void*& _token) = 0;
+12 -4
View File
@@ -51,11 +51,15 @@ protected:
uint64 heapOffset;
uint64 heapSize;
AttributeHandlerContext(BErrorOutput* errorOutput,
BPackageContentHandler* packageContentHandler);
BHPKGPackageSectionID section;
AttributeHandlerContext(BErrorOutput* errorOutput,
BLowLevelPackageContentHandler* lowLevelHandler);
BPackageContentHandler* packageContentHandler,
BHPKGPackageSectionID section);
AttributeHandlerContext(BErrorOutput* errorOutput,
BLowLevelPackageContentHandler* lowLevelHandler,
BHPKGPackageSectionID section);
void ErrorOccurred();
};
@@ -200,7 +204,8 @@ protected:
AttributeHandlerContext* context,
AttributeHandler* rootAttributeHandler);
status_t ParseAttributeTree(
AttributeHandlerContext* context);
AttributeHandlerContext* context,
bool& _sectionHandled);
virtual status_t ReadAttributeValue(uint8 type, uint8 encoding,
AttributeValue& _value);
@@ -225,6 +230,9 @@ protected:
SectionInfo fPackageAttributesSection;
private:
status_t _ParseAttributeTree(
AttributeHandlerContext* context);
template<typename Type>
inline status_t _Read(Type& _value);