1/*
2 * Copyright 2009,2011, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _PACKAGE__HPKG__V1__PACKAGE_DATA_H_
6#define _PACKAGE__HPKG__V1__PACKAGE_DATA_H_
7
8
9#include <package/hpkg/v1/HPKGDefs.h>
10
11
12namespace BPackageKit {
13
14namespace BHPKG {
15
16namespace V1 {
17
18
19class BPackageData {
20public:
21								BPackageData();
22
23			uint64				CompressedSize() const
24									{ return fCompressedSize; }
25			uint64				UncompressedSize() const
26									{ return fUncompressedSize; }
27			uint64				Offset() const
28									{ return fEncodedInline ? 0 : fOffset; }
29			uint32				Compression() const		{ return fCompression; }
30			uint32				ChunkSize() const		{ return fChunkSize; }
31
32			bool				IsEncodedInline() const
33									{ return fEncodedInline; }
34			const uint8*		InlineData() const		{ return fInlineData; }
35
36			void				SetData(uint64 size, uint64 offset);
37			void				SetData(uint8 size, const void* data);
38
39			void				SetCompression(uint32 compression)
40									{ fCompression = compression; }
41			void				SetUncompressedSize(uint64 size)
42									{ fUncompressedSize = size; }
43			void				SetChunkSize(uint32 size)
44									{ fChunkSize = size; }
45
46private:
47			uint64				fCompressedSize;
48			uint64				fUncompressedSize;
49			union {
50				uint64			fOffset;
51				uint8			fInlineData[B_HPKG_MAX_INLINE_DATA_SIZE];
52			};
53			uint32				fChunkSize;
54			uint32				fCompression;
55			bool				fEncodedInline;
56};
57
58
59}	// namespace V1
60
61}	// namespace BHPKG
62
63}	// namespace BPackageKit
64
65
66#endif	// _PACKAGE__HPKG__V1__PACKAGE_DATA_H_
67