2010-05-06 19:42:48 +04:00
|
|
|
/*
|
2010-07-26 02:47:39 +04:00
|
|
|
* Copyright 2003-2010, Haiku, Inc.
|
2009-09-19 16:19:46 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2009-05-01 23:23:59 +04:00
|
|
|
#ifndef _CATALOG_H_
|
|
|
|
#define _CATALOG_H_
|
|
|
|
|
2010-07-20 15:38:34 +04:00
|
|
|
#include <LocaleRoster.h>
|
2009-05-01 23:23:59 +04:00
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
|
|
|
class BCatalogAddOn;
|
|
|
|
class BLocale;
|
|
|
|
class BMessage;
|
|
|
|
struct entry_ref;
|
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
class BCatalog {
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
BCatalog();
|
|
|
|
BCatalog(const char *signature, const char *language = NULL,
|
2009-09-19 02:23:34 +04:00
|
|
|
uint32 fingerprint = 0);
|
2009-05-01 23:23:59 +04:00
|
|
|
virtual ~BCatalog();
|
|
|
|
|
|
|
|
const char *GetString(const char *string, const char *context = NULL,
|
|
|
|
const char *comment = NULL);
|
|
|
|
const char *GetString(uint32 id);
|
|
|
|
|
2010-07-26 02:47:39 +04:00
|
|
|
const char *GetNoAutoCollectString(const char *string,
|
|
|
|
const char *context = NULL, const char *comment = NULL);
|
|
|
|
const char *GetNoAutoCollectString(uint32 id);
|
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
status_t GetData(const char *name, BMessage *msg);
|
|
|
|
status_t GetData(uint32 id, BMessage *msg);
|
|
|
|
|
|
|
|
status_t GetSignature(BString *sig);
|
|
|
|
status_t GetLanguage(BString *lang);
|
2009-09-19 02:23:34 +04:00
|
|
|
status_t GetFingerprint(uint32 *fp);
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-07-01 15:54:09 +04:00
|
|
|
status_t SetCatalog(const char* signature, uint32 fingerprint);
|
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
status_t InitCheck() const;
|
|
|
|
int32 CountItems() const;
|
|
|
|
|
|
|
|
BCatalogAddOn *CatalogAddOn();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
BCatalog(const BCatalog&);
|
|
|
|
const BCatalog& operator= (const BCatalog&);
|
|
|
|
// hide assignment and copy-constructor
|
|
|
|
|
|
|
|
BCatalogAddOn *fCatalog;
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class BLocale;
|
|
|
|
friend status_t get_add_on_catalog(BCatalog*, const char *);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-07-26 02:47:39 +04:00
|
|
|
#ifndef B_COLLECTING_CATKEYS
|
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
#ifndef B_AVOID_TRANSLATION_MACROS
|
|
|
|
// macros for easy catalog-access, define B_AVOID_TRANSLATION_MACROS if
|
2010-07-26 02:47:39 +04:00
|
|
|
// you don't want these (in which case you need to collect the catalog keys
|
|
|
|
// manually, as collectcatkeys won't do it for you):
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-05-08 02:59:42 +04:00
|
|
|
#undef B_TRANSLATE_CONTEXT
|
2009-05-02 01:56:16 +04:00
|
|
|
// In a single application, several strings (e.g. 'Ok') will be used
|
|
|
|
// more than once, in different contexts.
|
2009-05-01 23:23:59 +04:00
|
|
|
// As the application programmer can not know if all translations of
|
|
|
|
// this string will be the same for all languages, each occurrence of
|
|
|
|
// the string must be translated on its own.
|
|
|
|
// Specifying the context explicitly with each string allows the person
|
|
|
|
// translating a catalog to separate these different occurrences of the
|
2009-05-02 01:56:16 +04:00
|
|
|
// same string and tell which strings appears in what context of the
|
2009-05-01 23:23:59 +04:00
|
|
|
// application.
|
|
|
|
// In order to give the translator a useful hint, the application
|
2010-05-08 02:59:42 +04:00
|
|
|
// programmer needs to define B_TRANSLATE_CONTEXT with the context he'd
|
|
|
|
// like to be associated with the strings used in this specifc source file.
|
2009-05-01 23:23:59 +04:00
|
|
|
// example:
|
2010-05-08 02:59:42 +04:00
|
|
|
// #define B_TRANSLATE_CONTEXT "Folder-Window"
|
2009-05-02 01:56:16 +04:00
|
|
|
// Tip: Use a descriptive name of the class implemented in that
|
|
|
|
// source-file.
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
// Translation macros which may be used to shorten translation requests:
|
2010-05-10 18:44:54 +04:00
|
|
|
#undef B_TRANSLATE
|
2010-07-01 15:54:09 +04:00
|
|
|
#define B_TRANSLATE(str) \
|
2010-07-20 15:38:34 +04:00
|
|
|
be_locale_roster->GetCatalog()->GetString((str), B_TRANSLATE_CONTEXT)
|
2010-07-01 15:54:09 +04:00
|
|
|
|
|
|
|
#undef B_TRANSLATE_COMMENT
|
|
|
|
#define B_TRANSLATE_COMMENT(str, cmt) \
|
2010-07-20 15:38:34 +04:00
|
|
|
be_locale_roster->GetCatalog()->GetString((str), B_TRANSLATE_CONTEXT, (cmt))
|
2010-07-01 15:54:09 +04:00
|
|
|
|
|
|
|
#undef B_TRANSLATE_ALL
|
|
|
|
#define B_TRANSLATE_ALL(str, ctx, cmt) \
|
2010-07-20 15:38:34 +04:00
|
|
|
be_locale_roster->GetCatalog()->GetString((str), (ctx), (cmt))
|
2010-07-01 15:54:09 +04:00
|
|
|
|
|
|
|
#undef B_TRANSLATE_ID
|
|
|
|
#define B_TRANSLATE_ID(id) \
|
2010-07-20 15:38:34 +04:00
|
|
|
be_locale_roster->GetCatalog()->GetString((id))
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
// Translation markers which can be used to mark static strings/IDs which
|
|
|
|
// are used as key for translation requests (at other places in the code):
|
|
|
|
/* example:
|
2010-05-08 02:59:42 +04:00
|
|
|
#define B_TRANSLATE_CONTEXT "MyDecentApp-Menu"
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
static const char *choices[] = {
|
2010-05-10 18:44:54 +04:00
|
|
|
B_TRANSLATE_MARK("left"),
|
|
|
|
B_TRANSLATE_MARK("right"),
|
|
|
|
B_TRANSLATE_MARK("up"),
|
|
|
|
B_TRANSLATE_MARK("down")
|
2009-05-01 23:23:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
void MyClass::AddChoices(BMenu *menu) {
|
|
|
|
for (char **ch = choices; *ch; ch++) {
|
|
|
|
menu->AddItem(
|
|
|
|
new BMenuItem(
|
2010-05-10 18:44:54 +04:00
|
|
|
B_TRANSLATE(*ch),
|
2009-05-01 23:23:59 +04:00
|
|
|
new BMessage(...)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2010-05-10 18:44:54 +04:00
|
|
|
#undef B_TRANSLATE_MARK
|
2010-05-06 19:42:48 +04:00
|
|
|
#define B_TRANSLATE_MARK(str) \
|
2010-05-08 02:59:42 +04:00
|
|
|
BCatalogAddOn::MarkForTranslation((str), B_TRANSLATE_CONTEXT, "")
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-05-10 18:44:54 +04:00
|
|
|
#undef B_TRANSLATE_MARK_COMMENT
|
2010-05-06 19:42:48 +04:00
|
|
|
#define B_TRANSLATE_MARK_COMMENT(str, cmt) \
|
2010-05-08 02:59:42 +04:00
|
|
|
BCatalogAddOn::MarkForTranslation((str), B_TRANSLATE_CONTEXT, (cmt))
|
2009-05-01 23:23:59 +04:00
|
|
|
|
2010-05-10 18:44:54 +04:00
|
|
|
#undef B_TRANSLATE_MARK_ALL
|
2010-05-06 19:42:48 +04:00
|
|
|
#define B_TRANSLATE_MARK_ALL(str, ctx, cmt) \
|
|
|
|
BCatalogAddOn::MarkForTranslation((str), (ctx), (cmt))
|
2009-05-02 01:56:16 +04:00
|
|
|
|
2010-05-10 18:44:54 +04:00
|
|
|
#undef B_TRANSLATE_MARK_ID
|
2010-05-06 19:42:48 +04:00
|
|
|
#define B_TRANSLATE_MARK_ID(id) \
|
|
|
|
BCatalogAddOn::MarkForTranslation((id))
|
2009-05-02 01:56:16 +04:00
|
|
|
|
2010-07-26 02:47:39 +04:00
|
|
|
// Translation macros which do not let collectcatkeys try to collect the key
|
|
|
|
// (useful in combination with the marking macros above):
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT
|
|
|
|
#define B_TRANSLATE_NOCOLLECT(str) \
|
|
|
|
B_TRANSLATE(str)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT_COMMENT
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_COMMENT(str, cmt) \
|
|
|
|
B_TRANSLATE_COMMENT(str, cmt)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT_ALL
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_ALL(str, ctx, cmt) \
|
|
|
|
B_TRANSLATE_ALL(str, ctx, cmt)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT_ID
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_ID(id) \
|
|
|
|
B_TRANSLATE_ID(id)
|
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
#endif /* B_AVOID_TRANSLATION_MACROS */
|
|
|
|
|
2010-07-26 02:47:39 +04:00
|
|
|
#else /* B_COLLECTING_CATKEYS */
|
|
|
|
|
|
|
|
// Translation macros used when executing collectcatkeys
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_CONTEXT
|
|
|
|
|
|
|
|
#undef B_TRANSLATE
|
|
|
|
#define B_TRANSLATE(str) \
|
|
|
|
B_CATKEY((str), B_TRANSLATE_CONTEXT)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_COMMENT
|
|
|
|
#define B_TRANSLATE_COMMENT(str, cmt) \
|
|
|
|
B_CATKEY((str), B_TRANSLATE_CONTEXT, (cmt))
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_ALL
|
|
|
|
#define B_TRANSLATE_ALL(str, ctx, cmt) \
|
|
|
|
B_CATKEY((str), (ctx), (cmt))
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_ID
|
|
|
|
#define B_TRANSLATE_ID(id) \
|
|
|
|
B_CATKEY((id))
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_MARK
|
|
|
|
#define B_TRANSLATE_MARK(str) \
|
|
|
|
B_CATKEY((str), B_TRANSLATE_CONTEXT)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_MARK_COMMENT
|
|
|
|
#define B_TRANSLATE_MARK_COMMENT(str, cmt) \
|
|
|
|
B_CATKEY((str), B_TRANSLATE_CONTEXT, (cmt))
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_MARK_ALL
|
|
|
|
#define B_TRANSLATE_MARK_ALL(str, ctx, cmt) \
|
|
|
|
B_CATKEY((str), (ctx), (cmt))
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_MARK_ID
|
|
|
|
#define B_TRANSLATE_MARK_ID(id) \
|
|
|
|
B_CATKEY((id))
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT
|
|
|
|
#define B_TRANSLATE_NOCOLLECT(str) \
|
|
|
|
(void)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT_COMMENT
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_COMMENT(str, cmt) \
|
|
|
|
(void)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT_ALL
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_ALL(str, ctx, cmt) \
|
|
|
|
(void)
|
|
|
|
|
|
|
|
#undef B_TRANSLATE_NOCOLLECT_ID
|
|
|
|
#define B_TRANSLATE_NOCOLLECT_ID(id) \
|
|
|
|
(void)
|
|
|
|
|
|
|
|
#endif /* B_COLLECTING_CATKEYS */
|
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
// For BCatalog add-on implementations:
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
class BCatalogAddOn {
|
2009-05-01 23:23:59 +04:00
|
|
|
friend class BLocaleRoster;
|
|
|
|
public:
|
|
|
|
BCatalogAddOn(const char *signature, const char *language,
|
2009-09-20 21:57:06 +04:00
|
|
|
uint32 fingerprint);
|
2009-05-01 23:23:59 +04:00
|
|
|
virtual ~BCatalogAddOn();
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
virtual const char *GetString(const char *string,
|
2009-09-20 21:57:06 +04:00
|
|
|
const char *context = NULL,
|
|
|
|
const char *comment = NULL) = 0;
|
2009-05-01 23:23:59 +04:00
|
|
|
virtual const char *GetString(uint32 id) = 0;
|
|
|
|
|
|
|
|
status_t InitCheck() const;
|
|
|
|
BCatalogAddOn *Next();
|
|
|
|
|
2009-09-20 21:57:06 +04:00
|
|
|
// the following could be used to localize non-textual data (e.g.
|
|
|
|
// icons), but these will only be implemented if there's demand for such
|
|
|
|
// a feature:
|
2009-05-01 23:23:59 +04:00
|
|
|
virtual bool CanHaveData() const;
|
|
|
|
virtual status_t GetData(const char *name, BMessage *msg);
|
|
|
|
virtual status_t GetData(uint32 id, BMessage *msg);
|
|
|
|
|
|
|
|
// interface for catalog-editor-app and testing apps:
|
2009-05-02 01:56:16 +04:00
|
|
|
virtual status_t SetString(const char *string,
|
2009-05-01 23:23:59 +04:00
|
|
|
const char *translated,
|
2009-09-20 21:57:06 +04:00
|
|
|
const char *context = NULL,
|
|
|
|
const char *comment = NULL);
|
2009-05-01 23:23:59 +04:00
|
|
|
virtual status_t SetString(int32 id, const char *translated);
|
2010-05-06 19:42:48 +04:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
virtual bool CanWriteData() const;
|
|
|
|
virtual status_t SetData(const char *name, BMessage *msg);
|
|
|
|
virtual status_t SetData(uint32 id, BMessage *msg);
|
2010-05-06 19:42:48 +04:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
virtual status_t ReadFromFile(const char *path = NULL);
|
|
|
|
virtual status_t ReadFromAttribute(entry_ref *appOrAddOnRef);
|
|
|
|
virtual status_t ReadFromResource(entry_ref *appOrAddOnRef);
|
|
|
|
virtual status_t WriteToFile(const char *path = NULL);
|
|
|
|
virtual status_t WriteToAttribute(entry_ref *appOrAddOnRef);
|
|
|
|
virtual status_t WriteToResource(entry_ref *appOrAddOnRef);
|
2010-05-06 19:42:48 +04:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
virtual void MakeEmpty();
|
|
|
|
virtual int32 CountItems() const;
|
|
|
|
|
|
|
|
// magic marker functions which are used to mark a string/id
|
|
|
|
// which will be translated elsewhere in the code (where it can
|
|
|
|
// not be found since it is references by a variable):
|
2009-05-02 01:56:16 +04:00
|
|
|
static const char *MarkForTranslation(const char *str, const char *ctx,
|
2009-05-01 23:23:59 +04:00
|
|
|
const char *cmt);
|
|
|
|
static int32 MarkForTranslation(int32 id);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void UpdateFingerprint();
|
|
|
|
|
|
|
|
status_t fInitCheck;
|
|
|
|
BString fSignature;
|
|
|
|
BString fLanguageName;
|
2009-09-19 02:23:34 +04:00
|
|
|
uint32 fFingerprint;
|
2009-05-01 23:23:59 +04:00
|
|
|
BCatalogAddOn *fNext;
|
2009-05-02 01:56:16 +04:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
friend class BCatalog;
|
|
|
|
friend status_t get_add_on_catalog(BCatalog*, const char *);
|
|
|
|
};
|
|
|
|
|
|
|
|
// every catalog-add-on should export these symbols...
|
|
|
|
// ...the function that instantiates a catalog for this add-on-type...
|
2009-05-02 01:56:16 +04:00
|
|
|
extern "C"
|
2009-05-01 23:23:59 +04:00
|
|
|
BCatalogAddOn *instantiate_catalog(const char *signature,
|
2009-09-19 02:23:34 +04:00
|
|
|
const char *language, uint32 fingerprint);
|
2009-05-01 23:23:59 +04:00
|
|
|
// ...the function that creates an empty catalog for this add-on-type...
|
2009-05-02 01:56:16 +04:00
|
|
|
extern "C"
|
2009-05-01 23:23:59 +04:00
|
|
|
BCatalogAddOn *create_catalog(const char *signature,
|
|
|
|
const char *language);
|
|
|
|
// ...and the priority which will be used to order the catalog-add-ons:
|
2009-05-02 01:56:16 +04:00
|
|
|
extern uint8 gCatalogAddOnPriority;
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BCatalog - inlines for trivial accessors:
|
|
|
|
*/
|
|
|
|
inline status_t
|
2009-05-02 01:56:16 +04:00
|
|
|
BCatalog::GetSignature(BString *sig)
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
if (!sig)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (!fCatalog)
|
|
|
|
return B_NO_INIT;
|
|
|
|
*sig = fCatalog->fSignature;
|
|
|
|
return B_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline status_t
|
|
|
|
BCatalog::GetLanguage(BString *lang)
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
if (!lang)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (!fCatalog)
|
|
|
|
return B_NO_INIT;
|
|
|
|
*lang = fCatalog->fLanguageName;
|
|
|
|
return B_OK;
|
2009-05-02 01:56:16 +04:00
|
|
|
}
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline status_t
|
2009-09-19 02:23:34 +04:00
|
|
|
BCatalog::GetFingerprint(uint32 *fp)
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
if (!fp)
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
if (!fCatalog)
|
|
|
|
return B_NO_INIT;
|
|
|
|
*fp = fCatalog->fFingerprint;
|
|
|
|
return B_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-26 02:47:39 +04:00
|
|
|
inline const char *
|
|
|
|
BCatalog::GetNoAutoCollectString(const char *string, const char *context,
|
|
|
|
const char *comment)
|
|
|
|
{
|
|
|
|
return GetString(string, context, comment);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline const char *
|
|
|
|
BCatalog::GetNoAutoCollectString(uint32 id)
|
|
|
|
{
|
|
|
|
return GetString(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
inline status_t
|
|
|
|
BCatalog::InitCheck() const
|
|
|
|
{
|
2009-05-02 01:56:16 +04:00
|
|
|
return fCatalog
|
|
|
|
? fCatalog->InitCheck()
|
2009-05-01 23:23:59 +04:00
|
|
|
: B_NO_INIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
inline int32
|
2009-05-01 23:23:59 +04:00
|
|
|
BCatalog::CountItems() const
|
|
|
|
{
|
|
|
|
if (!fCatalog)
|
|
|
|
return 0;
|
|
|
|
return fCatalog->CountItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline BCatalogAddOn *
|
2009-05-02 01:56:16 +04:00
|
|
|
BCatalog::CatalogAddOn()
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
return fCatalog;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BCatalogAddOn - inlines for trivial accessors:
|
|
|
|
*/
|
|
|
|
inline BCatalogAddOn *
|
2009-05-02 01:56:16 +04:00
|
|
|
BCatalogAddOn::Next()
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
return fNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const char *
|
2010-07-26 02:47:39 +04:00
|
|
|
BCatalogAddOn::MarkForTranslation(const char *str, const char *ctx,
|
2009-05-02 01:56:16 +04:00
|
|
|
const char *cmt)
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline int32
|
2010-07-26 02:47:39 +04:00
|
|
|
BCatalogAddOn::MarkForTranslation(int32 id)
|
2009-05-01 23:23:59 +04:00
|
|
|
{
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* EditableCatalog
|
|
|
|
*/
|
2009-05-02 01:56:16 +04:00
|
|
|
class EditableCatalog : public BCatalog {
|
2009-05-01 23:23:59 +04:00
|
|
|
|
|
|
|
public:
|
2009-05-02 01:56:16 +04:00
|
|
|
EditableCatalog(const char *type, const char *signature,
|
2009-05-01 23:23:59 +04:00
|
|
|
const char *language);
|
|
|
|
~EditableCatalog();
|
|
|
|
|
2009-05-02 01:56:16 +04:00
|
|
|
status_t SetString(const char *string,
|
2009-05-01 23:23:59 +04:00
|
|
|
const char *translated,
|
2009-09-20 21:57:06 +04:00
|
|
|
const char *context = NULL,
|
|
|
|
const char *comment = NULL);
|
2009-05-01 23:23:59 +04:00
|
|
|
status_t SetString(int32 id, const char *translated);
|
2010-05-06 19:42:48 +04:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
bool CanWriteData() const;
|
|
|
|
status_t SetData(const char *name, BMessage *msg);
|
|
|
|
status_t SetData(uint32 id, BMessage *msg);
|
2010-05-06 19:42:48 +04:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
status_t ReadFromFile(const char *path = NULL);
|
|
|
|
status_t ReadFromAttribute(entry_ref *appOrAddOnRef);
|
|
|
|
status_t ReadFromResource(entry_ref *appOrAddOnRef);
|
|
|
|
status_t WriteToFile(const char *path = NULL);
|
|
|
|
status_t WriteToAttribute(entry_ref *appOrAddOnRef);
|
|
|
|
status_t WriteToResource(entry_ref *appOrAddOnRef);
|
2010-05-06 19:42:48 +04:00
|
|
|
|
2009-05-01 23:23:59 +04:00
|
|
|
void MakeEmpty();
|
|
|
|
|
|
|
|
private:
|
|
|
|
EditableCatalog();
|
|
|
|
EditableCatalog(const EditableCatalog&);
|
|
|
|
const EditableCatalog& operator= (const EditableCatalog&);
|
|
|
|
// hide assignment, default- and copy-constructor
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
2009-09-20 21:57:06 +04:00
|
|
|
#endif /* _CATALOG_H_ */
|