2 * Copyright 2003-2012, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
5 #ifndef _CATALOG_DATA_H_
6 #define _CATALOG_DATA_H_
9 #include <SupportDefs.h>
19 * Base class for the catalog-data provided by every catalog add-on. An instance
20 * of this class represents (the data of) a single catalog. Several of these
21 * catalog data objects may be chained together in order to represent
22 * variations of a specific language. If for instance the catalog data 'en_uk'
23 * is chained to the data for 'en', a BCatalog using this catalog data chain
24 * will prefer any entries in the 'en_uk' catalog, but fallback onto 'en' for
25 * entries missing in the former.
29 BCatalogData(const char* signature
,
32 virtual ~BCatalogData();
34 virtual const char* GetString(const char* string
,
35 const char* context
= NULL
,
36 const char* comment
= NULL
) = 0;
37 virtual const char* GetString(uint32 id
) = 0;
39 status_t
InitCheck() const;
42 // the following could be used to localize non-textual data (e.g.
43 // icons), but these will only be implemented if there's demand for such
45 virtual bool CanHaveData() const;
46 virtual status_t
GetData(const char* name
, BMessage
* msg
);
47 virtual status_t
GetData(uint32 id
, BMessage
* msg
);
49 // interface for catalog-editor-app and testing apps:
50 virtual status_t
SetString(const char* string
,
51 const char* translated
,
52 const char* context
= NULL
,
53 const char* comment
= NULL
);
54 virtual status_t
SetString(int32 id
, const char* translated
);
56 virtual bool CanWriteData() const;
57 virtual status_t
SetData(const char* name
, BMessage
* msg
);
58 virtual status_t
SetData(uint32 id
, BMessage
* msg
);
60 virtual status_t
ReadFromFile(const char* path
= NULL
);
61 virtual status_t
ReadFromAttribute(
62 const entry_ref
& appOrAddOnRef
);
63 virtual status_t
ReadFromResource(
64 const entry_ref
& appOrAddOnRef
);
65 virtual status_t
WriteToFile(const char* path
= NULL
);
66 virtual status_t
WriteToAttribute(
67 const entry_ref
& appOrAddOnRef
);
68 virtual status_t
WriteToResource(
69 const entry_ref
& appOrAddOnRef
);
71 virtual void MakeEmpty();
72 virtual int32
CountItems() const;
74 void SetNext(BCatalogData
* next
);
77 virtual void UpdateFingerprint();
80 friend class BCatalog
;
81 friend status_t
get_add_on_catalog(BCatalog
*, const char*);
85 BString fLanguageName
;
98 // every catalog-add-on should export the following three symbols:
100 // 1. the function that instantiates a catalog for this add-on-type
102 BCatalogData
* instantiate_catalog(const entry_ref
& signature
,
103 const char* language
, uint32 fingerprint
);
105 // 2. the function that creates an empty catalog for this add-on-type
107 BCatalogData
* create_catalog(const char* signature
, const char* language
);
109 // 3. the priority which will be used to order the catalog add-ons
110 extern uint8 gCatalogAddOnPriority
;
113 #endif /* _CATALOG_DATA_H_ */