Fix FreeBSD build.
[haiku.git] / headers / os / locale / CatalogData.h
blobf371f87b04c76774eade9124f026e3d0c31b90a3
1 /*
2 * Copyright 2003-2012, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _CATALOG_DATA_H_
6 #define _CATALOG_DATA_H_
9 #include <SupportDefs.h>
10 #include <String.h>
13 class BCatalog;
14 class BMessage;
15 struct entry_ref;
18 /**
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.
27 class BCatalogData {
28 public:
29 BCatalogData(const char* signature,
30 const char* language,
31 uint32 fingerprint);
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;
40 BCatalogData* Next();
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
44 // a feature:
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);
76 protected:
77 virtual void UpdateFingerprint();
79 protected:
80 friend class BCatalog;
81 friend status_t get_add_on_catalog(BCatalog*, const char*);
83 status_t fInitCheck;
84 BString fSignature;
85 BString fLanguageName;
86 uint32 fFingerprint;
87 BCatalogData* fNext;
91 inline BCatalogData*
92 BCatalogData::Next()
94 return fNext;
98 // every catalog-add-on should export the following three symbols:
100 // 1. the function that instantiates a catalog for this add-on-type
101 extern "C"
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
106 extern "C"
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_ */