xref: /haiku/src/apps/haikudepot/model/IconTarPtr.h (revision f0e491d390a4514633f1af4da4c46a7dad67ebec)
1*f0e491d3SAndrew Lindesay /*
2*f0e491d3SAndrew Lindesay  * Copyright 2020, Andrew Lindesay <apl@lindesay.co.nz>.
3*f0e491d3SAndrew Lindesay  * All rights reserved. Distributed under the terms of the MIT License.
4*f0e491d3SAndrew Lindesay  */
5*f0e491d3SAndrew Lindesay #ifndef ICON_TAR_PTR_H
6*f0e491d3SAndrew Lindesay #define ICON_TAR_PTR_H
7*f0e491d3SAndrew Lindesay 
8*f0e491d3SAndrew Lindesay #include <stdlib.h>
9*f0e491d3SAndrew Lindesay 
10*f0e491d3SAndrew Lindesay #include <Referenceable.h>
11*f0e491d3SAndrew Lindesay #include <String.h>
12*f0e491d3SAndrew Lindesay 
13*f0e491d3SAndrew Lindesay #include "HaikuDepotConstants.h"
14*f0e491d3SAndrew Lindesay 
15*f0e491d3SAndrew Lindesay 
16*f0e491d3SAndrew Lindesay /*!	The tar icon repository is able to find the icons for each package by
17*f0e491d3SAndrew Lindesay 	scanning the tar file for suitable icon files and recording the offsets into
18*f0e491d3SAndrew Lindesay 	the tar file when it does find a suitable icon file.  This class is used
19*f0e491d3SAndrew Lindesay 	to return the offsets for a given package.
20*f0e491d3SAndrew Lindesay */
21*f0e491d3SAndrew Lindesay 
22*f0e491d3SAndrew Lindesay class IconTarPtr : public BReferenceable {
23*f0e491d3SAndrew Lindesay public:
24*f0e491d3SAndrew Lindesay 								IconTarPtr(const BString& name);
25*f0e491d3SAndrew Lindesay 	virtual						~IconTarPtr();
26*f0e491d3SAndrew Lindesay 
27*f0e491d3SAndrew Lindesay 	const	BString&			Name() const;
28*f0e491d3SAndrew Lindesay 			bool				HasOffset(BitmapSize size) const;
29*f0e491d3SAndrew Lindesay 			off_t				Offset(BitmapSize size) const;
30*f0e491d3SAndrew Lindesay 			void				SetOffset(BitmapSize size, off_t value);
31*f0e491d3SAndrew Lindesay 
32*f0e491d3SAndrew Lindesay private:
33*f0e491d3SAndrew Lindesay 			BString				fName;
34*f0e491d3SAndrew Lindesay 			uint8				fOffsetsMask;
35*f0e491d3SAndrew Lindesay 			off_t				fOffsets[5];
36*f0e491d3SAndrew Lindesay };
37*f0e491d3SAndrew Lindesay 
38*f0e491d3SAndrew Lindesay #endif // ICON_TAR_PTR_H