haiku/headers/private/package/hpkg/v1/PackageReaderImpl.h
Ingo Weinhold 7575abbca2 Clone read support functionality for HPKG format version 1
It uses sub-namespace BPackage::BHPKG::V1. Unlike the one for the
current format version, the V1 version of BPackageInfoContentHandler
lives in BHPKG(::V1) sub-namespace and is private.
2013-05-25 01:12:22 +02:00

103 lines
1.9 KiB
C++

/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* Distributed under the terms of the MIT License.
*/
#ifndef _PACKAGE__HPKG__V1__PRIVATE__PACKAGE_READER_IMPL_H_
#define _PACKAGE__HPKG__V1__PRIVATE__PACKAGE_READER_IMPL_H_
#include <package/hpkg/v1/ReaderImplBase.h>
namespace BPackageKit {
namespace BHPKG {
namespace V1 {
class BPackageEntry;
class BPackageEntryAttribute;
namespace BPrivate {
class PackageReaderImpl : public ReaderImplBase {
typedef ReaderImplBase inherited;
public:
PackageReaderImpl(
BErrorOutput* errorOutput);
~PackageReaderImpl();
status_t Init(const char* fileName);
status_t Init(int fd, bool keepFD);
status_t ParseContent(
BPackageContentHandler* contentHandler);
status_t ParseContent(BLowLevelPackageContentHandler*
contentHandler);
int PackageFileFD() const;
uint64 HeapOffset() const;
uint64 HeapSize() const;
protected:
// from ReaderImplBase
virtual status_t ReadAttributeValue(uint8 type, uint8 encoding,
AttributeValue& _value);
private:
struct DataAttributeHandler;
struct AttributeAttributeHandler;
struct EntryAttributeHandler;
struct RootAttributeHandler;
private:
status_t _ParseTOC(AttributeHandlerContext* context,
AttributeHandler* rootAttributeHandler);
status_t _GetTOCBuffer(size_t size,
const void*& _buffer);
private:
uint64 fTotalSize;
uint64 fHeapOffset;
uint64 fHeapSize;
SectionInfo fTOCSection;
};
inline int
PackageReaderImpl::PackageFileFD() const
{
return FD();
}
inline uint64
PackageReaderImpl::HeapOffset() const
{
return fHeapOffset;
}
inline uint64
PackageReaderImpl::HeapSize() const
{
return fHeapSize;
}
} // namespace BPrivate
} // namespace V1
} // namespace BHPKG
} // namespace BPackageKit
#endif // _PACKAGE__HPKG__V1__PRIVATE__PACKAGE_READER_IMPL_H_