BLowLevelPackageContentHandler interface extension

HandleAttributeDone(): Add parentToken parameter.
This commit is contained in:
Ingo Weinhold 2011-07-02 02:29:40 +02:00
parent 37880dd0a7
commit 2fce201893
4 changed files with 12 additions and 8 deletions

View File

@ -32,7 +32,7 @@ public:
virtual status_t HandleAttributeDone(
BHPKGAttributeID attributeID,
const BPackageAttributeValue& value,
void* token) = 0;
void* parentToken, void* token) = 0;
virtual void HandleErrorOccurred() = 0;

View File

@ -145,7 +145,8 @@ protected:
struct LowLevelAttributeHandler : AttributeHandler {
LowLevelAttributeHandler();
LowLevelAttributeHandler(uint8 id,
const BPackageAttributeValue& value, void* token);
const BPackageAttributeValue& value, void* parentToken,
void* token);
virtual status_t HandleAttribute(
AttributeHandlerContext* context, uint8 id,
@ -153,6 +154,7 @@ protected:
virtual status_t Delete(AttributeHandlerContext* context);
private:
void* fParentToken;
void* fToken;
uint8 fID;
AttributeValue fValue;

View File

@ -50,7 +50,7 @@ struct PackageContentDumpHandler : BLowLevelPackageContentHandler {
}
virtual status_t HandleAttributeDone(BHPKGAttributeID attributeID,
const BPackageAttributeValue& value, void* token)
const BPackageAttributeValue& value, void* parentToken, void* token)
{
if (fErrorOccurred)
return B_OK;

View File

@ -463,6 +463,7 @@ ReaderImplBase::PackageAttributeHandler::HandleAttribute(
ReaderImplBase::LowLevelAttributeHandler::LowLevelAttributeHandler()
:
fParentToken(NULL),
fToken(NULL),
fID(B_HPKG_ATTRIBUTE_ID_ENUM_COUNT)
{
@ -470,8 +471,9 @@ ReaderImplBase::LowLevelAttributeHandler::LowLevelAttributeHandler()
ReaderImplBase::LowLevelAttributeHandler::LowLevelAttributeHandler(uint8 id,
const BPackageAttributeValue& value, void* token)
const BPackageAttributeValue& value, void* parentToken, void* token)
:
fParentToken(NULL),
fToken(token),
fID(id),
fValue(value)
@ -494,10 +496,10 @@ ReaderImplBase::LowLevelAttributeHandler::HandleAttribute(
// create a subhandler for the attribute, if it has children
if (_handler != NULL) {
*_handler = new(std::nothrow) LowLevelAttributeHandler(id, value,
token);
fToken, token);
if (*_handler == NULL) {
context->lowLevelHandler->HandleAttributeDone((BHPKGAttributeID)id,
value, token);
value, fToken, token);
return B_NO_MEMORY;
}
return B_OK;
@ -505,7 +507,7 @@ ReaderImplBase::LowLevelAttributeHandler::HandleAttribute(
// no children -- just call the done hook
return context->lowLevelHandler->HandleAttributeDone((BHPKGAttributeID)id,
value, token);
value, fToken, token);
}
@ -516,7 +518,7 @@ ReaderImplBase::LowLevelAttributeHandler::Delete(
status_t error = B_OK;
if (fID != B_HPKG_ATTRIBUTE_ID_ENUM_COUNT) {
error = context->lowLevelHandler->HandleAttributeDone(
(BHPKGAttributeID)fID, fValue, fToken);
(BHPKGAttributeID)fID, fValue, fParentToken, fToken);
}
delete this;