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