1 //---------------------------------------------------------------------- 2 // This software is part of the OpenBeOS distribution and is covered 3 // by the OpenBeOS license. 4 //--------------------------------------------------------------------- 5 /*! 6 \file ResourceStrings.h 7 BResourceStrings interface declaration. 8 */ 9 10 #ifndef _RESOURCE_STRINGS_H 11 #define _RESOURCE_STRINGS_H 12 13 #include <Entry.h> 14 #include <Locker.h> 15 16 class BResources; 17 class BString; 18 19 /*! 20 \class BResourceStrings 21 \brief Simple class to access the string resources in a file. 22 23 A BResourceStrings object reads the string type resources from a given 24 resource file and provides fast read only access to them. 25 26 \author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a> 27 28 \version 0.0.0 29 */ 30 class BResourceStrings { 31 public: 32 BResourceStrings(); 33 BResourceStrings(const entry_ref &ref); 34 virtual ~BResourceStrings(); 35 36 status_t InitCheck(); 37 virtual BString *NewString(int32 id); 38 virtual const char *FindString(int32 id); 39 40 virtual status_t SetStringFile(const entry_ref *ref); 41 status_t GetStringFile(entry_ref *outRef); 42 43 public: 44 enum { 45 RESOURCE_TYPE = 'CSTR' 46 }; 47 48 protected: 49 struct _string_id_hash { 50 _string_id_hash(); 51 ~_string_id_hash(); 52 void assign_string(const char *str, bool makeCopy); 53 _string_id_hash *next; 54 int32 id; 55 char *data; 56 bool data_alloced; 57 bool _reserved1[3]; 58 uint32 _reserved2; 59 }; 60 61 protected: 62 BLocker _string_lock; 63 status_t _init_error; 64 65 private: 66 entry_ref fFileRef; 67 BResources *fResources; 68 _string_id_hash **fHashTable; 69 int32 fHashTableSize; 70 int32 fStringCount; 71 uint32 _reserved[16]; // FBC 72 73 private: 74 void _Cleanup(); 75 void _MakeEmpty(); 76 status_t _Rehash(int32 newSize); 77 _string_id_hash *_AddString(char *str, int32 id, bool wasMalloced); 78 79 virtual _string_id_hash *_FindString(int32 id); 80 81 // FBC 82 virtual status_t _Reserved_ResourceStrings_0(void *); 83 virtual status_t _Reserved_ResourceStrings_1(void *); 84 virtual status_t _Reserved_ResourceStrings_2(void *); 85 virtual status_t _Reserved_ResourceStrings_3(void *); 86 virtual status_t _Reserved_ResourceStrings_4(void *); 87 virtual status_t _Reserved_ResourceStrings_5(void *); 88 }; 89 90 #endif // _RESOURCE_STRINGS_H 91 92 93