libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / apps / deskbar / ResourceSet.h
blobc79bf2d30aaea1630661763e30e1e9874e980e25
1 /*
2 Open Tracker License
4 Terms and Conditions
6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
30 trademarks of Be Incorporated in the United States and other countries. Other
31 brand product names are registered trademarks or trademarks of their respective
32 holders.
33 All rights reserved.
35 #ifndef _T_RESOURCE_SET_H
36 #define _T_RESOURCE_SET_H
39 #include <List.h>
40 #include <Locker.h>
41 #include <SupportDefs.h>
44 class BBitmap;
45 class BResources;
46 class BDataIO;
47 class BString;
49 namespace TResourcePrivate {
50 class TypeItem;
51 class TypeList;
54 using namespace TResourcePrivate;
56 const uint32 B_STRING_BLOCK_TYPE = 'SBLK';
58 class TStringBlock {
59 public:
60 TStringBlock(BDataIO* data);
61 TStringBlock(const void* block, size_t size);
62 virtual ~TStringBlock();
64 const char* String(size_t index) const;
66 private:
67 size_t PreIndex(char* strings, ssize_t len);
68 void MakeIndex(const char* strings, ssize_t len, size_t indexLen,
69 size_t* outIndex);
71 size_t fNumEntries;
72 size_t* fIndex;
73 char* fStrings;
74 bool fOwnData;
77 class TResourceSet {
78 public:
79 TResourceSet();
80 virtual ~TResourceSet();
82 status_t AddResources(BResources* resources);
83 status_t AddDirectory(const char* fullPath);
84 status_t AddEnvDirectory(const char* envPath,
85 const char* defaultValue = NULL);
87 const void* FindResource(type_code type, int32 id, size_t* outSize);
88 const void* FindResource(type_code type, const char* name, size_t* outSize);
90 const BBitmap* FindBitmap(type_code type, int32 id);
91 const BBitmap* FindBitmap(type_code type, const char* name);
93 const TStringBlock* FindStringBlock(type_code type, int32 id);
94 const TStringBlock* FindStringBlock(type_code type, const char* name);
96 const char* FindString(type_code type, int32 id, uint32 index);
97 const char* FindString(type_code type, const char* name, uint32 index);
99 private:
100 status_t ExpandString(BString* out, const char* in);
101 TypeList* FindTypeList(type_code type);
103 TypeItem* FindItemID(type_code type, int32 id);
104 TypeItem* FindItemName(type_code type, const char* name);
106 TypeItem* LoadResource(type_code type, int32 id, const char* name,
107 TypeList** inoutList = NULL);
109 BBitmap* ReturnBitmapItem(type_code type, TypeItem* from);
110 TStringBlock* ReturnStringBlockItem(TypeItem* from);
112 BLocker fLock; // access control.
113 BList fResources; // containing BResources objects.
114 BList fDirectories; // containing BPath objects.
115 BList fTypes; // containing TypeList objects.
118 TResourceSet* AppResSet();
121 #endif /* _T_RESOURCE_SET_H */