1 /* 2 ** Copyright 2009, Adrien Destugues, pulkomandy@gmail.com. 3 ** Distributed under the terms of the MIT License. 4 */ 5 #ifndef _DEFAULT_CATALOG_H_ 6 #define _DEFAULT_CATALOG_H_ 7 8 9 #include <DataIO.h> 10 #include <HashMapCatalog.h> 11 #include <String.h> 12 13 14 class BFile; 15 16 namespace BPrivate { 17 18 19 /* 20 * The implementation of the Locale Kit's standard catalog-type. 21 * Currently it only maps CatKey to a BString (the translated string), 22 * but the value-type might change to add support for shortcuts and/or 23 * graphical data (button-images and the like). 24 */ 25 class DefaultCatalog : public BHashMapCatalog { 26 public: 27 DefaultCatalog(const char *signature, const char *language, 28 uint32 fingerprint); 29 // constructor for normal use 30 DefaultCatalog(entry_ref *appOrAddOnRef); 31 // constructor for embedded catalog 32 DefaultCatalog(const char *path, const char *signature, 33 const char *language); 34 // constructor for editor-app 35 36 ~DefaultCatalog(); 37 38 39 // implementation for editor-interface: 40 status_t ReadFromFile(const char *path = NULL); 41 status_t ReadFromAttribute(entry_ref *appOrAddOnRef); 42 status_t ReadFromResource(entry_ref *appOrAddOnRef); 43 status_t WriteToFile(const char *path = NULL); 44 status_t WriteToAttribute(entry_ref *appOrAddOnRef); 45 status_t WriteToResource(entry_ref *appOrAddOnRef); 46 47 static BCatalogAddOn *Instantiate(const char *signature, 48 const char *language, uint32 fingerprint); 49 static BCatalogAddOn *InstantiateEmbedded(entry_ref *appOrAddOnRef); 50 static BCatalogAddOn *Create(const char *signature, 51 const char *language); 52 53 static const uint8 kDefaultCatalogAddOnPriority; 54 static const char *kCatMimeType; 55 56 private: 57 status_t Flatten(BDataIO *dataIO); 58 status_t Unflatten(BDataIO *dataIO); 59 void UpdateAttributes(BFile& catalogFile); 60 61 mutable BString fPath; 62 }; 63 64 65 } // namespace BPrivate 66 67 using namespace BPrivate; 68 69 #endif /* _DEFAULT_CATALOG_H_ */ 70