* Copied imported OpenTracker Locale Kit files from the vendor branch
into their new homes (at least for now, might need some adjustment). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30540 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,350 @@
|
||||
#ifndef _CATALOG_H_
|
||||
#define _CATALOG_H_
|
||||
|
||||
#include <LocaleBuild.h>
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <String.h>
|
||||
|
||||
class BCatalogAddOn;
|
||||
class BLocale;
|
||||
class BMessage;
|
||||
struct entry_ref;
|
||||
|
||||
|
||||
class _IMPEXP_LOCALE BCatalog {
|
||||
|
||||
public:
|
||||
BCatalog();
|
||||
BCatalog(const char *signature, const char *language = NULL,
|
||||
int32 fingerprint = 0);
|
||||
virtual ~BCatalog();
|
||||
|
||||
const char *GetString(const char *string, const char *context = NULL,
|
||||
const char *comment = NULL);
|
||||
const char *GetString(uint32 id);
|
||||
|
||||
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);
|
||||
status_t GetFingerprint(int32 *fp);
|
||||
|
||||
status_t InitCheck() const;
|
||||
int32 CountItems() const;
|
||||
|
||||
BCatalogAddOn *CatalogAddOn();
|
||||
|
||||
protected:
|
||||
BCatalog(const BCatalog&);
|
||||
const BCatalog& operator= (const BCatalog&);
|
||||
// hide assignment and copy-constructor
|
||||
|
||||
static status_t GetAppCatalog(BCatalog*);
|
||||
|
||||
BCatalogAddOn *fCatalog;
|
||||
|
||||
private:
|
||||
friend class BLocale;
|
||||
friend status_t get_add_on_catalog(BCatalog*, const char *);
|
||||
};
|
||||
|
||||
|
||||
extern _IMPEXP_LOCALE BCatalog* be_catalog;
|
||||
extern _IMPEXP_LOCALE BCatalog* be_app_catalog;
|
||||
|
||||
|
||||
#ifndef B_AVOID_TRANSLATION_MACROS
|
||||
// macros for easy catalog-access, define B_AVOID_TRANSLATION_MACROS if
|
||||
// you don't want these:
|
||||
|
||||
#undef TR_CONTEXT
|
||||
// In a single application, several strings (e.g. 'Ok') will be used
|
||||
// more than once, in different contexts.
|
||||
// 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
|
||||
// same string and tell which strings appears in what context of the
|
||||
// application.
|
||||
// In order to give the translator a useful hint, the application
|
||||
// programmer needs to define TR_CONTEXT with the context he'd like
|
||||
// to be associated with the strings used in this specifc source file.
|
||||
// example:
|
||||
// #define TR_CONTEXT "Folder-Window"
|
||||
// Tip: Use a descriptive name of the class implemented in that
|
||||
// source-file.
|
||||
|
||||
|
||||
// Translation macros which may be used to shorten translation requests:
|
||||
#undef TR
|
||||
#define TR(str) \
|
||||
be_catalog->GetString((str), TR_CONTEXT)
|
||||
|
||||
#undef TR_CMT
|
||||
#define TR_CMT(str,cmt) \
|
||||
be_catalog->GetString((str), TR_CONTEXT, (cmt))
|
||||
|
||||
#undef TR_ALL
|
||||
#define TR_ALL(str,ctx,cmt) \
|
||||
be_catalog->GetString((str), (ctx), (cmt))
|
||||
|
||||
#undef TR_ID
|
||||
#define TR_ID(id) \
|
||||
be_catalog->GetString((id))
|
||||
|
||||
|
||||
// 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:
|
||||
#define TR_CONTEXT "MyDecentApp-Menu"
|
||||
|
||||
static const char *choices[] = {
|
||||
TR_MARK("left"),
|
||||
TR_MARK("right"),
|
||||
TR_MARK("up"),
|
||||
TR_MARK("down")
|
||||
};
|
||||
|
||||
void MyClass::AddChoices(BMenu *menu) {
|
||||
for (char **ch = choices; *ch; ch++) {
|
||||
menu->AddItem(
|
||||
new BMenuItem(
|
||||
TR(*ch),
|
||||
new BMessage(...)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
*/
|
||||
#undef TR_MARK
|
||||
#define TR_MARK(str) \
|
||||
BCatalogAddOn::MarkForTranslation((str), TR_CONTEXT, "")
|
||||
|
||||
#undef TR_MARK_CMT
|
||||
#define TR_MARK_CMT(str,cmt) \
|
||||
BCatalogAddOn::MarkForTranslation((str), TR_CONTEXT, (cmt))
|
||||
|
||||
#undef TR_MARK_ALL
|
||||
#define TR_MARK_ALL(str,ctx,cmt) \
|
||||
BCatalogAddOn::MarkForTranslation((str), (ctx), (cmt))
|
||||
|
||||
#undef TR_MARK_ID
|
||||
#define TR_MARK_ID(id) \
|
||||
BCatalogAddOn::MarkForTranslation((id))
|
||||
|
||||
#endif /* B_AVOID_TRANSLATION_MACROS */
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
// For BCatalog add-on implementations:
|
||||
|
||||
class _IMPEXP_LOCALE BCatalogAddOn {
|
||||
friend class BLocaleRoster;
|
||||
public:
|
||||
BCatalogAddOn(const char *signature, const char *language,
|
||||
int32 fingerprint);
|
||||
virtual ~BCatalogAddOn();
|
||||
|
||||
virtual const char *GetString(const char *string,
|
||||
const char *context=NULL,
|
||||
const char *comment=NULL) = 0;
|
||||
virtual const char *GetString(uint32 id) = 0;
|
||||
|
||||
status_t InitCheck() const;
|
||||
BCatalogAddOn *Next();
|
||||
|
||||
// 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:
|
||||
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:
|
||||
virtual status_t SetString(const char *string,
|
||||
const char *translated,
|
||||
const char *context=NULL,
|
||||
const char *comment=NULL);
|
||||
virtual status_t SetString(int32 id, const char *translated);
|
||||
//
|
||||
virtual bool CanWriteData() const;
|
||||
virtual status_t SetData(const char *name, BMessage *msg);
|
||||
virtual status_t SetData(uint32 id, BMessage *msg);
|
||||
//
|
||||
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);
|
||||
//
|
||||
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):
|
||||
static const char *MarkForTranslation(const char *str, const char *ctx,
|
||||
const char *cmt);
|
||||
static int32 MarkForTranslation(int32 id);
|
||||
|
||||
protected:
|
||||
virtual void UpdateFingerprint();
|
||||
|
||||
status_t fInitCheck;
|
||||
BString fSignature;
|
||||
BString fLanguageName;
|
||||
int32 fFingerprint;
|
||||
BCatalogAddOn *fNext;
|
||||
|
||||
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...
|
||||
extern "C" _IMPEXP_LOCALE
|
||||
BCatalogAddOn *instantiate_catalog(const char *signature,
|
||||
const char *language, int32 fingerprint);
|
||||
// ...the function that creates an empty catalog for this add-on-type...
|
||||
extern "C" _IMPEXP_LOCALE
|
||||
BCatalogAddOn *create_catalog(const char *signature,
|
||||
const char *language);
|
||||
// ...and the priority which will be used to order the catalog-add-ons:
|
||||
extern _IMPEXP_LOCALE uint8 gCatalogAddOnPriority;
|
||||
|
||||
|
||||
/*
|
||||
* BCatalog - inlines for trivial accessors:
|
||||
*/
|
||||
inline status_t
|
||||
BCatalog::GetSignature(BString *sig)
|
||||
{
|
||||
if (!sig)
|
||||
return B_BAD_VALUE;
|
||||
if (!fCatalog)
|
||||
return B_NO_INIT;
|
||||
*sig = fCatalog->fSignature;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
BCatalog::GetLanguage(BString *lang)
|
||||
{
|
||||
if (!lang)
|
||||
return B_BAD_VALUE;
|
||||
if (!fCatalog)
|
||||
return B_NO_INIT;
|
||||
*lang = fCatalog->fLanguageName;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
BCatalog::GetFingerprint(int32 *fp)
|
||||
{
|
||||
if (!fp)
|
||||
return B_BAD_VALUE;
|
||||
if (!fCatalog)
|
||||
return B_NO_INIT;
|
||||
*fp = fCatalog->fFingerprint;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
BCatalog::InitCheck() const
|
||||
{
|
||||
return fCatalog
|
||||
? fCatalog->InitCheck()
|
||||
: B_NO_INIT;
|
||||
}
|
||||
|
||||
|
||||
inline int32
|
||||
BCatalog::CountItems() const
|
||||
{
|
||||
if (!fCatalog)
|
||||
return 0;
|
||||
return fCatalog->CountItems();
|
||||
}
|
||||
|
||||
|
||||
inline BCatalogAddOn *
|
||||
BCatalog::CatalogAddOn()
|
||||
{
|
||||
return fCatalog;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* BCatalogAddOn - inlines for trivial accessors:
|
||||
*/
|
||||
inline BCatalogAddOn *
|
||||
BCatalogAddOn::Next()
|
||||
{
|
||||
return fNext;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
BCatalogAddOn::MarkForTranslation(const char *str, const char *ctx,
|
||||
const char *cmt)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
inline int32
|
||||
BCatalogAddOn::MarkForTranslation(int32 id)
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
/*
|
||||
* EditableCatalog
|
||||
*/
|
||||
class _IMPEXP_LOCALE EditableCatalog : public BCatalog {
|
||||
|
||||
public:
|
||||
EditableCatalog(const char *type, const char *signature,
|
||||
const char *language);
|
||||
~EditableCatalog();
|
||||
|
||||
status_t SetString(const char *string,
|
||||
const char *translated,
|
||||
const char *context=NULL,
|
||||
const char *comment=NULL);
|
||||
status_t SetString(int32 id, const char *translated);
|
||||
//
|
||||
bool CanWriteData() const;
|
||||
status_t SetData(const char *name, BMessage *msg);
|
||||
status_t SetData(uint32 id, BMessage *msg);
|
||||
//
|
||||
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);
|
||||
//
|
||||
void MakeEmpty();
|
||||
|
||||
private:
|
||||
EditableCatalog();
|
||||
EditableCatalog(const EditableCatalog&);
|
||||
const EditableCatalog& operator= (const EditableCatalog&);
|
||||
// hide assignment, default- and copy-constructor
|
||||
|
||||
};
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
#endif /* _CATALOG_H_ */
|
||||
@@ -0,0 +1,120 @@
|
||||
#ifndef _CATALOG_IN_ADD_ON_H_
|
||||
#define _CATALOG_IN_ADD_ON_H_
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <Entry.h>
|
||||
#include <Locale.h>
|
||||
#include <LocaleRoster.h>
|
||||
#include <Node.h>
|
||||
#include <TypeConstants.h>
|
||||
|
||||
/*
|
||||
* This header file is somewhat special...
|
||||
*
|
||||
* Since the TR-macros are referencing be_catalog, we want each add-on
|
||||
* to have its own be_catalog (instead of sharing the one from the lib).
|
||||
* In order to do so, we define another be_catalog in this file, which
|
||||
* will override the one from liblocale.so.
|
||||
* This way we implement something like add-on-local storage. It would
|
||||
* be desirable to find a better way, so please tell us if you know one!
|
||||
*
|
||||
* Every add-on that wants to use the Locale Kit needs to include this
|
||||
* file once (no more, exactly once!).
|
||||
* You have to include it in the source-file that loads the add-on's
|
||||
* catalog (by use of get_add_on_catalog().
|
||||
*
|
||||
*/
|
||||
|
||||
BCatalog *be_catalog = NULL;
|
||||
// global that points to this add-on's catalog
|
||||
|
||||
|
||||
/*
|
||||
* utility function which determines the entry-ref for "this" add-on:
|
||||
*/
|
||||
static status_t
|
||||
get_add_on_ref(entry_ref *ref)
|
||||
{
|
||||
if (!ref)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
image_info imageInfo;
|
||||
int32 cookie = 0;
|
||||
status_t res = B_ERROR;
|
||||
void *dataPtr = static_cast<void*>(&be_catalog);
|
||||
while ((res = get_next_image_info(0, &cookie, &imageInfo)) == B_OK) {
|
||||
char *dataStart = static_cast<char*>(imageInfo.data);
|
||||
if (imageInfo.type == B_ADD_ON_IMAGE && dataStart <= dataPtr
|
||||
&& dataStart+imageInfo.data_size > dataPtr) {
|
||||
get_ref_for_path(imageInfo.name, ref);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Every add-on should load its catalog through this function, since
|
||||
* it does not only load the add-on's catalog, but it does several
|
||||
* other useful things:
|
||||
* - be_catalog (the one belonging to this add-on) is initialized
|
||||
* such that the TR-macros use the add-on's catalog.
|
||||
* - if givenSig is empty (NULL or "") the add-on's signature is
|
||||
* used to determine the catalog-sig.
|
||||
* - if the add-on's executable contains an embedded catalog, that
|
||||
* one is loaded, too.
|
||||
*/
|
||||
status_t
|
||||
get_add_on_catalog(BCatalog* cat, const char *givenSig)
|
||||
{
|
||||
if (!cat)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// determine entry-ref of the add-on this code lives in:
|
||||
entry_ref ref;
|
||||
status_t res = get_add_on_ref(&ref);
|
||||
if (res == B_OK) {
|
||||
// ok, we have found the entry-ref for our add-on,
|
||||
// so we try to fetch the fingerprint from our add-on-file:
|
||||
int32 fp = 0;
|
||||
BNode addOnNode(&ref);
|
||||
addOnNode.ReadAttr(BLocaleRoster::kCatFingerprintAttr,
|
||||
B_INT32_TYPE, 0, &fp, sizeof(int32));
|
||||
BString sig(givenSig);
|
||||
if (sig.Length() == 0) {
|
||||
res = addOnNode.ReadAttrString("BEOS:MIME", &sig);
|
||||
if (res == B_OK) {
|
||||
// drop supertype from mimetype (should be "application/"):
|
||||
int32 pos = sig.FindFirst('/');
|
||||
if (pos >= 0)
|
||||
sig.Remove(0, pos+1);
|
||||
}
|
||||
}
|
||||
if (res == B_OK) {
|
||||
// try to load it's catalog...
|
||||
cat->fCatalog
|
||||
= be_locale_roster->LoadCatalog(sig.String(), NULL, fp);
|
||||
// ...and try to load an embedded catalog, too (if that exists):
|
||||
BCatalogAddOn *embeddedCatalog
|
||||
= be_locale_roster->LoadEmbeddedCatalog(&ref);
|
||||
if (embeddedCatalog) {
|
||||
if (!cat->fCatalog)
|
||||
// embedded catalog is the only catalog that was found:
|
||||
cat->fCatalog = embeddedCatalog;
|
||||
else {
|
||||
// append embedded catalog to list of loaded catalogs:
|
||||
BCatalogAddOn *currCat = cat->fCatalog;
|
||||
while (currCat->fNext)
|
||||
currCat = currCat->fNext;
|
||||
currCat->fNext = embeddedCatalog;
|
||||
}
|
||||
}
|
||||
be_catalog = cat;
|
||||
}
|
||||
}
|
||||
return cat->InitCheck();
|
||||
}
|
||||
|
||||
|
||||
#endif /* _CATALOG_IN_ADD_ON_H_ */
|
||||
@@ -0,0 +1,119 @@
|
||||
#ifndef _COLLATOR_H_
|
||||
#define _COLLATOR_H_
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <Archivable.h>
|
||||
|
||||
#include <LocaleBuild.h>
|
||||
|
||||
class BString;
|
||||
class BCollatorAddOn;
|
||||
|
||||
|
||||
enum collator_strengths {
|
||||
B_COLLATE_DEFAULT = -1,
|
||||
|
||||
B_COLLATE_PRIMARY = 1, // e.g.: no diacritical differences, e = é
|
||||
B_COLLATE_SECONDARY, // diacritics are different from their base characters, a != ä
|
||||
B_COLLATE_TERTIARY, // case sensitive comparison
|
||||
B_COLLATE_QUATERNARY,
|
||||
|
||||
B_COLLATE_IDENTICAL = 127 // Unicode value
|
||||
};
|
||||
|
||||
|
||||
class _IMPEXP_LOCALE BCollator : public BArchivable {
|
||||
public:
|
||||
BCollator();
|
||||
BCollator(BCollatorAddOn *collator, int8 strength, bool ignorePunctuation);
|
||||
BCollator(BMessage *archive);
|
||||
~BCollator();
|
||||
|
||||
void SetDefaultStrength(int8 strength);
|
||||
int8 DefaultStrength() const;
|
||||
|
||||
void SetIgnorePunctuation(bool ignore);
|
||||
bool IgnorePunctuation() const;
|
||||
|
||||
status_t GetSortKey(const char *string, BString *key, int8 strength = B_COLLATE_DEFAULT);
|
||||
|
||||
int Compare(const char *, const char *, int32 len = -1, int8 strength = B_COLLATE_DEFAULT);
|
||||
bool Equal(const char *, const char *, int32 len = -1, int8 strength = B_COLLATE_DEFAULT);
|
||||
bool Greater(const char *, const char *, int32 len = -1, int8 strength = B_COLLATE_DEFAULT);
|
||||
bool GreaterOrEqual(const char *, const char *, int32 len = -1, int8 strength = B_COLLATE_DEFAULT);
|
||||
|
||||
// (un-)archiving API
|
||||
status_t Archive(BMessage *archive, bool deep) const;
|
||||
static BArchivable *Instantiate(BMessage *archive);
|
||||
|
||||
private:
|
||||
BCollatorAddOn *fCollator;
|
||||
image_id fCollatorImage;
|
||||
int8 fStrength;
|
||||
bool fIgnorePunctuation;
|
||||
};
|
||||
|
||||
|
||||
inline bool
|
||||
BCollator::Equal(const char *s1, const char *s2, int32 len, int8 strength)
|
||||
{
|
||||
return Compare(s1, s2, len, strength) == 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
BCollator::Greater(const char *s1, const char *s2, int32 len, int8 strength)
|
||||
{
|
||||
return Compare(s1, s2, len, strength) > 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
BCollator::GreaterOrEqual(const char *s1, const char *s2, int32 len, int8 strength)
|
||||
{
|
||||
return Compare(s1, s2, len, strength) >= 0;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
// For BCollator add-on implementations:
|
||||
|
||||
class _IMPEXP_LOCALE BCollatorAddOn : public BArchivable {
|
||||
public:
|
||||
BCollatorAddOn();
|
||||
BCollatorAddOn(BMessage *archive);
|
||||
virtual ~BCollatorAddOn();
|
||||
|
||||
virtual status_t GetSortKey(const char *string, BString *key, int8 strength,
|
||||
bool ignorePunctuation);
|
||||
virtual int Compare(const char *a, const char *b, int32 length, int8 strength,
|
||||
bool ignorePunctuation);
|
||||
|
||||
// (un-)archiving API
|
||||
virtual status_t Archive(BMessage *archive, bool deep) const;
|
||||
static BArchivable *Instantiate(BMessage *archive);
|
||||
|
||||
protected:
|
||||
struct input_context {
|
||||
input_context(bool ignorePunctuation);
|
||||
|
||||
bool ignore_punctuation;
|
||||
uint32 next_char;
|
||||
int32 reserved1;
|
||||
int32 reserved2;
|
||||
};
|
||||
|
||||
virtual uint32 GetNextChar(const char **string, input_context &context);
|
||||
virtual size_t PrimaryKeyLength(size_t length);
|
||||
virtual char *PutPrimaryKey(const char *string, char *buffer, int32 length,
|
||||
bool ignorePunctuation);
|
||||
};
|
||||
|
||||
// If your add-on should work with the standard tool to create a language, it
|
||||
// should export that function. However, once the language file has been written
|
||||
// only the archived collator is used, and that function won't be called anymore.
|
||||
extern "C" _IMPEXP_LOCALE BCollatorAddOn *instantiate_collator(void);
|
||||
|
||||
#endif /* _COLLATOR_H_ */
|
||||
@@ -0,0 +1,75 @@
|
||||
#ifndef _COUNTRY_H_
|
||||
#define _COUNTRY_H_
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <LocaleBuild.h>
|
||||
#include <LocaleStrings.h>
|
||||
#include <String.h>
|
||||
|
||||
enum {
|
||||
B_METRIC = 0,
|
||||
B_US
|
||||
};
|
||||
|
||||
|
||||
class _IMPEXP_LOCALE BCountry {
|
||||
public:
|
||||
BCountry();
|
||||
virtual ~BCountry();
|
||||
|
||||
virtual const char *Name() const;
|
||||
|
||||
// see definitions below
|
||||
const char *GetString(uint32 id) const;
|
||||
|
||||
// date & time
|
||||
|
||||
virtual void FormatDate(char *string,size_t maxSize,time_t time,bool longFormat);
|
||||
virtual void FormatDate(BString *string,time_t time,bool longFormat);
|
||||
virtual void FormatTime(char *string,size_t maxSize,time_t time,bool longFormat);
|
||||
virtual void FormatTime(BString *string,time_t time,bool longFormat);
|
||||
|
||||
const char *DateFormat(bool longFormat) const;
|
||||
const char *TimeFormat(bool longFormat) const;
|
||||
const char *DateSeparator() const;
|
||||
const char *TimeSeparator() const;
|
||||
|
||||
// numbers
|
||||
|
||||
virtual void FormatNumber(char *string,size_t maxSize,double value);
|
||||
virtual void FormatNumber(BString *string,double value);
|
||||
virtual void FormatNumber(char *string,size_t maxSize,int32 value);
|
||||
virtual void FormatNumber(BString *string,int32 value);
|
||||
|
||||
const char *DecimalPoint() const;
|
||||
const char *ThousandsSeparator() const;
|
||||
const char *Grouping() const;
|
||||
|
||||
const char *PositiveSign() const;
|
||||
const char *NegativeSign() const;
|
||||
|
||||
// measurements
|
||||
|
||||
virtual int8 Measurement() const;
|
||||
|
||||
// monetary
|
||||
|
||||
virtual ssize_t FormatMonetary(char *string,size_t maxSize,char *format, ...);
|
||||
virtual ssize_t FormatMonetary(BString *string,char *format, ...);
|
||||
|
||||
const char *CurrencySymbol() const;
|
||||
const char *InternationalCurrencySymbol() const;
|
||||
const char *MonDecimalPoint() const;
|
||||
const char *MonThousandsSeparator() const;
|
||||
const char *MonGrouping() const;
|
||||
virtual int32 MonFracDigits() const;
|
||||
|
||||
protected:
|
||||
BCountry(const char **strings);
|
||||
|
||||
private:
|
||||
const char **fStrings;
|
||||
};
|
||||
|
||||
#endif /* _COUNTRY_H_ */
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef _B_CURRENCY_H_
|
||||
#define _B_CURRENCY_H_
|
||||
|
||||
#include <Archivable.h>
|
||||
#include <Message.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <LocaleBuild.h>
|
||||
|
||||
class BLocale;
|
||||
|
||||
class _IMPEXP_LOCALE BCurrency : public BArchivable {
|
||||
public:
|
||||
BCurrency(const BCurrency &other);
|
||||
BCurrency(BMessage *archive);
|
||||
BCurrency(const char *currencyCode);
|
||||
~BCurrency();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
virtual status_t Archive(BMessage *archive, bool deep = true) const;
|
||||
static BArchivable *Instantiate(BMessage *archive);
|
||||
|
||||
const char *CurrencyCode() const;
|
||||
const char *DefaultSymbol() const;
|
||||
int32 DefaultFractionDigits() const;
|
||||
|
||||
status_t GetSymbol(char *symbol, size_t maxSize,
|
||||
BLocale *locale = NULL);
|
||||
status_t GetSymbol(BString *symbol, BLocale *locale = NULL);
|
||||
|
||||
BCurrency &operator=(const BCurrency &other);
|
||||
bool operator==(const BCurrency &other) const;
|
||||
bool operator!=(const BCurrency &other) const;
|
||||
|
||||
private:
|
||||
BCurrency();
|
||||
|
||||
bool _CheckData() const;
|
||||
void _Unset(status_t error);
|
||||
|
||||
BString fCurrencyCode;
|
||||
BString fDefaultSymbol;
|
||||
int32 fDefaultFractionDigits;
|
||||
};
|
||||
|
||||
#endif // _B_CURRENCY_H_
|
||||
@@ -0,0 +1,197 @@
|
||||
#ifndef _DEFAULT_CATALOG_H_
|
||||
#define _DEFAULT_CATALOG_H_
|
||||
|
||||
#ifdef __MWERKS__
|
||||
# include <hashmap.h>
|
||||
#else
|
||||
# include <hash_map>
|
||||
#endif
|
||||
|
||||
#include <LocaleBuild.h>
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <DataIO.h>
|
||||
#include <String.h>
|
||||
|
||||
class BFile;
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
struct CatKey;
|
||||
}
|
||||
|
||||
/*
|
||||
* the hash-access functor which is being used to access the hash-value
|
||||
* stored inside of each key.
|
||||
*/
|
||||
#ifdef __MWERKS__
|
||||
// Codewarrior doesn't provide this declaration, so we do:
|
||||
template <class T> struct hash : public unary_function<T,size_t> {
|
||||
size_t operator() (const T &key) const;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct hash<BPrivate::CatKey> {
|
||||
size_t operator() (const BPrivate::CatKey &key) const;
|
||||
};
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
/*
|
||||
* The key-type for the hash_map which maps native strings or IDs to
|
||||
* the corresponding translated string.
|
||||
* The key-type should be efficient to use if it is just created by an ID
|
||||
* but it should also support being created from up to three strings,
|
||||
* which as a whole specify the key to the translated string.
|
||||
*/
|
||||
struct _IMPEXP_LOCALE CatKey {
|
||||
BString fKey;
|
||||
// the key-string consists of three values separated by a special
|
||||
// token:
|
||||
// - the native string
|
||||
// - the context of the string's usage
|
||||
// - a comment that can be used to separate strings that
|
||||
// are identical otherwise (useful for the translator)
|
||||
size_t fHashVal;
|
||||
// the hash-value of fKey
|
||||
uint32 fFlags;
|
||||
// with respect to the catalog-editor, each translation can be
|
||||
// in different states (empty, unchecked, checked, etc.).
|
||||
// This state (and potential other flags) lives in the fFlags member.
|
||||
CatKey(const char *str, const char *ctx, const char *cmt);
|
||||
CatKey(uint32 id);
|
||||
CatKey();
|
||||
bool operator== (const CatKey& right) const;
|
||||
status_t GetStringParts(BString* str, BString* ctx, BString* cmt) const;
|
||||
static size_t HashFun(const char* s);
|
||||
};
|
||||
|
||||
/*
|
||||
* The implementation of the Locale Kit's standard catalog-type.
|
||||
* Currently it only maps CatKey to a BString (the translated string),
|
||||
* but the value-type might change to add support for shortcuts and/or
|
||||
* graphical data (button-images and the like).
|
||||
*/
|
||||
class _IMPEXP_LOCALE DefaultCatalog : public BCatalogAddOn {
|
||||
|
||||
public:
|
||||
DefaultCatalog(const char *signature, const char *language,
|
||||
int32 fingerprint);
|
||||
// constructor for normal use
|
||||
DefaultCatalog(entry_ref *appOrAddOnRef);
|
||||
// constructor for embedded catalog
|
||||
DefaultCatalog(const char *path, const char *signature,
|
||||
const char *language);
|
||||
// constructor for editor-app
|
||||
|
||||
~DefaultCatalog();
|
||||
|
||||
// overrides of BCatalogAddOn:
|
||||
const char *GetString(const char *string, const char *context = NULL,
|
||||
const char *comment = NULL);
|
||||
const char *GetString(uint32 id);
|
||||
const char *GetString(const CatKey& key);
|
||||
//
|
||||
status_t SetString(const char *string, const char *translated,
|
||||
const char *context = NULL, const char *comment = NULL);
|
||||
status_t SetString(int32 id, const char *translated);
|
||||
status_t SetString(const CatKey& key, const char *translated);
|
||||
void UpdateFingerprint();
|
||||
|
||||
// implementation for editor-interface:
|
||||
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);
|
||||
//
|
||||
void MakeEmpty();
|
||||
int32 CountItems() const;
|
||||
|
||||
static BCatalogAddOn *Instantiate(const char *signature,
|
||||
const char *language,
|
||||
int32 fingerprint);
|
||||
static BCatalogAddOn *InstantiateEmbedded(entry_ref *appOrAddOnRef);
|
||||
static BCatalogAddOn *Create(const char *signature,
|
||||
const char *language);
|
||||
static const uint8 kDefaultCatalogAddOnPriority;
|
||||
static const char *kCatMimeType;
|
||||
|
||||
private:
|
||||
status_t Flatten(BDataIO *dataIO);
|
||||
status_t Unflatten(BDataIO *dataIO);
|
||||
int32 ComputeFingerprint() const;
|
||||
void UpdateAttributes(BFile& catalogFile);
|
||||
|
||||
typedef hash_map<CatKey, BString, hash<CatKey>, equal_to<CatKey> > CatMap;
|
||||
CatMap fCatMap;
|
||||
mutable BString fPath;
|
||||
|
||||
public:
|
||||
/*
|
||||
* CatWalker
|
||||
*/
|
||||
class CatWalker {
|
||||
public:
|
||||
CatWalker() {}
|
||||
CatWalker(CatMap &catMap);
|
||||
bool AtEnd() const;
|
||||
const CatKey& GetKey() const;
|
||||
const char *GetValue() const;
|
||||
void Next();
|
||||
private:
|
||||
CatMap::iterator fPos;
|
||||
CatMap::iterator fEnd;
|
||||
};
|
||||
status_t GetWalker(CatWalker *walker);
|
||||
};
|
||||
|
||||
inline
|
||||
DefaultCatalog::CatWalker::CatWalker(CatMap &catMap)
|
||||
: fPos(catMap.begin()),
|
||||
fEnd(catMap.end())
|
||||
{
|
||||
}
|
||||
|
||||
inline bool
|
||||
DefaultCatalog::CatWalker::AtEnd() const
|
||||
{
|
||||
return fPos == fEnd;
|
||||
}
|
||||
|
||||
inline const CatKey &
|
||||
DefaultCatalog::CatWalker::GetKey() const
|
||||
{
|
||||
assert(fPos != fEnd);
|
||||
return fPos->first;
|
||||
}
|
||||
|
||||
inline const char *
|
||||
DefaultCatalog::CatWalker::GetValue() const
|
||||
{
|
||||
assert(fPos != fEnd);
|
||||
return fPos->second.String();
|
||||
}
|
||||
|
||||
inline void
|
||||
DefaultCatalog::CatWalker::Next()
|
||||
{
|
||||
++fPos;
|
||||
}
|
||||
|
||||
inline status_t
|
||||
DefaultCatalog::GetWalker(CatWalker *walker)
|
||||
{
|
||||
if (!walker)
|
||||
return B_BAD_VALUE;
|
||||
*walker = CatWalker(fCatMap);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
using namespace BPrivate;
|
||||
|
||||
#endif /* _DEFAULT_CATALOG_H_ */
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef _B_FLOAT_FORMAT_H_
|
||||
#define _B_FLOAT_FORMAT_H_
|
||||
|
||||
#include <NumberFormat.h>
|
||||
#include <FloatFormatParameters.h>
|
||||
|
||||
class BString;
|
||||
class BFloatFormatImpl;
|
||||
|
||||
class _IMPEXP_LOCALE BFloatFormat : public BNumberFormat, public BFloatFormatParameters {
|
||||
public:
|
||||
BFloatFormat(const BFloatFormat &other);
|
||||
~BFloatFormat();
|
||||
|
||||
// formatting
|
||||
|
||||
// no-frills version: Simply appends the formatted number to the
|
||||
// string buffer. Can fail only with B_NO_MEMORY or B_BAD_VALUE.
|
||||
status_t Format(double number, BString *buffer) const;
|
||||
|
||||
// Appends the formatted number to the string buffer. Additionally
|
||||
// one can get the positions of certain fields in the formatted
|
||||
// number by supplying format_field_position structures with the
|
||||
// field_type set respectively. Passing true for allFieldPositions
|
||||
// will make the method fill in a format_field_position structure for
|
||||
// each field it writes -- the field_type values will be ignored and
|
||||
// overwritten.
|
||||
// In fieldCount, in case it is non-null, the number of fields
|
||||
// written is returned.
|
||||
// B_BUFFER_OVERFLOW is returned, if allFieldPositions is true and
|
||||
// the positions buffer is too small (fieldCount will be set
|
||||
// nevertheless, so that the caller can adjust the buffer size to
|
||||
// make them all fit).
|
||||
status_t Format(double number, BString *buffer,
|
||||
format_field_position *positions,
|
||||
int32 positionCount = 1,
|
||||
int32 *fieldCount = NULL,
|
||||
bool allFieldPositions = false) const;
|
||||
|
||||
// TODO: Format() versions for (char* buffer, size_t bufferSize)
|
||||
// instead of BString*. And, of course, versions for the other
|
||||
// number types (float).
|
||||
|
||||
// parsing
|
||||
// TODO: ...
|
||||
|
||||
BFloatFormat &operator=(const BFloatFormat &other);
|
||||
|
||||
BFloatFormat(BFloatFormatImpl *impl); // conceptually private
|
||||
|
||||
private:
|
||||
inline BFloatFormatImpl *FloatFormatImpl() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // _B_FLOAT_FORMAT_H_
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef _B_FLOAT_FORMAT_IMPL_H_
|
||||
#define _B_FLOAT_FORMAT_IMPL_H_
|
||||
|
||||
#include <NumberFormatImpl.h>
|
||||
|
||||
struct format_field_position;
|
||||
class BFloatFormatParameters;
|
||||
class BString;
|
||||
|
||||
class _IMPEXP_LOCALE BFloatFormatImpl : public BNumberFormatImpl {
|
||||
public:
|
||||
BFloatFormatImpl();
|
||||
virtual ~BFloatFormatImpl();
|
||||
|
||||
// formatting
|
||||
|
||||
virtual status_t Format(const BFloatFormatParameters *parameters,
|
||||
double number, BString *buffer) const = 0;
|
||||
virtual status_t Format(const BFloatFormatParameters *parameters,
|
||||
double number, BString *buffer,
|
||||
format_field_position *positions,
|
||||
int32 positionCount = 1,
|
||||
int32 *fieldCount = NULL,
|
||||
bool allFieldPositions = false) const = 0;
|
||||
|
||||
// TODO: ...
|
||||
|
||||
|
||||
virtual BNumberFormatParameters *DefaultNumberFormatParameters();
|
||||
virtual const BNumberFormatParameters *DefaultNumberFormatParameters()
|
||||
const;
|
||||
|
||||
virtual BFloatFormatParameters *DefaultFloatFormatParameters() = 0;
|
||||
virtual const BFloatFormatParameters *DefaultFloatFormatParameters()
|
||||
const = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // _B_FLOAT_FORMAT_IMPL_H_
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef _B_FLOAT_FORMAT_PARAMETERS_H_
|
||||
#define _B_FLOAT_FORMAT_PARAMETERS_H_
|
||||
|
||||
#include <NumberFormatParameters.h>
|
||||
|
||||
enum float_format_type {
|
||||
B_FIXED_POINT_FLOAT_FORMAT,
|
||||
B_SCIENTIFIC_FLOAT_FORMAT,
|
||||
B_AUTO_FLOAT_FORMAT, // picks one of the above depending of the
|
||||
// number to be formatted
|
||||
};
|
||||
|
||||
class _IMPEXP_LOCALE BFloatFormatParameters : public BNumberFormatParameters {
|
||||
public:
|
||||
BFloatFormatParameters(const BFloatFormatParameters *parent = NULL);
|
||||
BFloatFormatParameters(const BFloatFormatParameters &other);
|
||||
~BFloatFormatParameters();
|
||||
|
||||
void SetMinimalFractionDigits(size_t minFractionDigits);
|
||||
size_t MinimalFractionDigits() const;
|
||||
|
||||
void SetMaximalFractionDigits(size_t maxFractionDigits);
|
||||
size_t MaximalFractionDigits() const;
|
||||
|
||||
void SetUseUpperCase(bool useCapitals);
|
||||
bool UseUpperCase() const;
|
||||
|
||||
void SetFloatFormatType(float_format_type type);
|
||||
float_format_type FloatFormatType() const;
|
||||
|
||||
void SetAlwaysUseFractionSeparator(bool alwaysUseFractionSeparator);
|
||||
bool AlwaysUseFractionSeparator() const;
|
||||
|
||||
void SetKeepTrailingFractionZeros(bool keepTrailingFractionZeros);
|
||||
bool KeepTrailingFractionZeros() const;
|
||||
|
||||
void SetParentFloatParameters(const BFloatFormatParameters *parent);
|
||||
const BFloatFormatParameters *ParentFloatParameters() const;
|
||||
|
||||
BFloatFormatParameters &operator=(
|
||||
const BFloatFormatParameters &other);
|
||||
|
||||
private:
|
||||
const BFloatFormatParameters *fParent;
|
||||
size_t fMinimalFractionDigits;
|
||||
size_t fMaximalFractionDigits;
|
||||
bool fUseUpperCase;
|
||||
float_format_type fFloatFormatType;
|
||||
bool fAlwaysUseFractionSeparator;
|
||||
bool fKeepTrailingFractionZeros;
|
||||
uint32 fFlags;
|
||||
};
|
||||
|
||||
#endif // _B_FLOAT_FORMAT_PARAMETERS_H_
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef _B_FORMAT_H_
|
||||
#define _B_FORMAT_H_
|
||||
|
||||
#include <FormatParameters.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
// types of fields contained in formatted strings
|
||||
enum {
|
||||
// number format fields
|
||||
B_CURRENCY_FIELD,
|
||||
B_DECIMAL_SEPARATOR_FIELD,
|
||||
B_EXPONENT_FIELD,
|
||||
B_EXPONENT_SIGN_FIELD,
|
||||
B_EXPONENT_SYMBOL_FIELD,
|
||||
B_FRACTION_FIELD,
|
||||
B_GROUPING_SEPARATOR_FIELD,
|
||||
B_INTEGER_FIELD,
|
||||
B_PERCENT_FIELD,
|
||||
B_PERMILLE_FIELD,
|
||||
B_SIGN_FIELD,
|
||||
|
||||
// date format fields
|
||||
// TODO: ...
|
||||
};
|
||||
|
||||
// structure filled in while formatting
|
||||
struct _IMPEXP_LOCALE format_field_position {
|
||||
uint32 field_type;
|
||||
int32 start;
|
||||
int32 length;
|
||||
};
|
||||
|
||||
class BFormatImpl;
|
||||
|
||||
class _IMPEXP_LOCALE BFormat {
|
||||
protected:
|
||||
BFormat(const BFormat &other);
|
||||
~BFormat();
|
||||
|
||||
BFormat &operator=(const BFormat &other);
|
||||
|
||||
BFormat(BFormatImpl *impl);
|
||||
|
||||
protected:
|
||||
BFormatImpl *fImpl;
|
||||
};
|
||||
|
||||
#endif // _B_FORMAT_H_
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef _B_FORMAT_IMPL_H_
|
||||
#define _B_FORMAT_IMPL_H_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <LocaleBuild.h>
|
||||
|
||||
class BFormatParameters;
|
||||
|
||||
class _IMPEXP_LOCALE BFormatImpl {
|
||||
public:
|
||||
BFormatImpl();
|
||||
virtual ~BFormatImpl();
|
||||
|
||||
virtual BFormatParameters *DefaultFormatParameters() = 0;
|
||||
virtual const BFormatParameters *DefaultFormatParameters()
|
||||
const = 0;
|
||||
};
|
||||
|
||||
#endif // _B_FORMAT_IMPL_H_
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef _B_FORMAT_PARAMETERS_H_
|
||||
#define _B_FORMAT_PARAMETERS_H_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <LocaleBuild.h>
|
||||
|
||||
enum format_alignment {
|
||||
B_ALIGN_FORMAT_LEFT, // reuse B_ALIGN_LEFT/B_ALIGN_RIGHT?
|
||||
B_ALIGN_FORMAT_RIGHT,
|
||||
};
|
||||
|
||||
class _IMPEXP_LOCALE BFormatParameters {
|
||||
public:
|
||||
BFormatParameters(const BFormatParameters *parent = NULL);
|
||||
BFormatParameters(const BFormatParameters &other);
|
||||
~BFormatParameters();
|
||||
|
||||
void SetAlignment(format_alignment alignment);
|
||||
format_alignment Alignment() const;
|
||||
|
||||
void SetFormatWidth(size_t width);
|
||||
size_t FormatWidth() const;
|
||||
|
||||
const BFormatParameters *ParentParameters() const;
|
||||
|
||||
BFormatParameters &operator=(const BFormatParameters &other);
|
||||
|
||||
protected:
|
||||
void SetParentParameters(const BFormatParameters *parent);
|
||||
|
||||
private:
|
||||
const BFormatParameters *fParent;
|
||||
format_alignment fAlignment;
|
||||
size_t fWidth;
|
||||
uint32 fFlags;
|
||||
};
|
||||
|
||||
#endif // _B_FORMAT_PARAMETERS_H_
|
||||
@@ -0,0 +1,160 @@
|
||||
#ifndef _B_GENERIC_NUMBER_FORMAT_H_
|
||||
#define _B_GENERIC_NUMBER_FORMAT_H_
|
||||
|
||||
#include <FloatFormatParameters.h>
|
||||
#include <IntegerFormatParameters.h>
|
||||
|
||||
class BString;
|
||||
struct format_field_position;
|
||||
|
||||
class _IMPEXP_LOCALE BGenericNumberFormat {
|
||||
public:
|
||||
BGenericNumberFormat();
|
||||
~BGenericNumberFormat();
|
||||
|
||||
status_t FormatInteger(const BIntegerFormatParameters *parameters,
|
||||
int64 number, BString *buffer,
|
||||
format_field_position *positions = NULL,
|
||||
int32 positionCount = 1,
|
||||
int32 *fieldCount = NULL,
|
||||
bool allFieldPositions = false) const;
|
||||
|
||||
status_t FormatInteger(const BIntegerFormatParameters *parameters,
|
||||
int64 number, char *buffer, size_t bufferSize,
|
||||
format_field_position *positions = NULL,
|
||||
int32 positionCount = 1,
|
||||
int32 *fieldCount = NULL,
|
||||
bool allFieldPositions = false) const;
|
||||
|
||||
status_t FormatInteger(const BIntegerFormatParameters *parameters,
|
||||
uint64 number, BString *buffer,
|
||||
format_field_position *positions = NULL,
|
||||
int32 positionCount = 1,
|
||||
int32 *fieldCount = NULL,
|
||||
bool allFieldPositions = false) const;
|
||||
|
||||
status_t FormatInteger(const BIntegerFormatParameters *parameters,
|
||||
uint64 number, char *buffer, size_t bufferSize,
|
||||
format_field_position *positions = NULL,
|
||||
int32 positionCount = 1,
|
||||
int32 *fieldCount = NULL,
|
||||
bool allFieldPositions = false) const;
|
||||
|
||||
status_t FormatFloat(const BFloatFormatParameters *parameters,
|
||||
double number, BString *buffer,
|
||||
format_field_position *positions = NULL,
|
||||
int32 positionCount = 1,
|
||||
int32 *fieldCount = NULL,
|
||||
bool allFieldPositions = false) const;
|
||||
|
||||
status_t FormatFloat(const BFloatFormatParameters *parameters,
|
||||
double number, char *buffer, size_t bufferSize,
|
||||
format_field_position *positions = NULL,
|
||||
int32 positionCount = 1,
|
||||
int32 *fieldCount = NULL,
|
||||
bool allFieldPositions = false) const;
|
||||
|
||||
// default number format parameters
|
||||
|
||||
status_t SetDefaultIntegerFormatParameters(
|
||||
const BIntegerFormatParameters *parameters);
|
||||
BIntegerFormatParameters *DefaultIntegerFormatParameters();
|
||||
const BIntegerFormatParameters *DefaultIntegerFormatParameters() const;
|
||||
|
||||
status_t SetDefaultFloatFormatParameters(
|
||||
const BFloatFormatParameters *parameters);
|
||||
BFloatFormatParameters *DefaultFloatFormatParameters();
|
||||
const BFloatFormatParameters *DefaultFloatFormatParameters() const;
|
||||
|
||||
// other parameters configuring the formatter
|
||||
|
||||
status_t SetDigitSymbols(const char **digits);
|
||||
status_t SetFractionSeparator(const char *decimalSeparator);
|
||||
status_t SetGroupingInfo(const char **groupingSeparators,
|
||||
size_t separatorCount, size_t *groupSizes, size_t sizeCount);
|
||||
status_t SetExponentSymbol(const char *exponentSymbol,
|
||||
const char *upperCaseExponentSymbol = NULL);
|
||||
status_t SetSpecialNumberSymbols(const char *nan,
|
||||
const char *infinity, const char *negativeInfinity = NULL,
|
||||
const char *upperCaseNaN = NULL,
|
||||
const char *upperCaseInfinity = NULL,
|
||||
const char *upperCaseNegativeInfinity = NULL);
|
||||
status_t SetSignSymbols(const char *plusPrefix,
|
||||
const char *minusPrefix, const char *padPlusPrefix,
|
||||
const char *noForcePlusPrefix = NULL, const char *plusSuffix = NULL,
|
||||
const char *minusSuffix = NULL, const char *padPlusSuffix = NULL,
|
||||
const char *noForcePlusSuffix = NULL);
|
||||
status_t SetMantissaSignSymbols(const char *plusPrefix,
|
||||
const char *minusPrefix, const char *padPlusPrefix,
|
||||
const char *noForcePlusPrefix = NULL, const char *plusSuffix = NULL,
|
||||
const char *minusSuffix = NULL, const char *padPlusSuffix = NULL,
|
||||
const char *noForcePlusSuffix = NULL);
|
||||
status_t SetExponentSignSymbols(const char *plusPrefix,
|
||||
const char *minusPrefix, const char *plusSuffix = NULL,
|
||||
const char *minusSuffix = NULL);
|
||||
// TODO: Support engineering representation of scientific format (exponent
|
||||
// is a multiple of 3), i.e. allow setting the number of which the exponent
|
||||
// must be a multiple of.
|
||||
|
||||
private:
|
||||
class BufferWriter;
|
||||
class Float;
|
||||
class GroupingInfo;
|
||||
class Integer;
|
||||
class SignSymbols;
|
||||
struct SpecialNumberSymbols;
|
||||
|
||||
struct Symbol {
|
||||
char *symbol;
|
||||
int length;
|
||||
int char_count;
|
||||
|
||||
Symbol(const char *symbol = NULL);
|
||||
~Symbol();
|
||||
|
||||
status_t SetTo(const char *symbol);
|
||||
void Unset() { SetTo(NULL); }
|
||||
};
|
||||
|
||||
status_t FormatInteger(const BIntegerFormatParameters *parameters,
|
||||
const Integer &integer, char *buffer,
|
||||
size_t bufferSize,
|
||||
format_field_position *positions = NULL,
|
||||
int32 positionCount = 1,
|
||||
int32 *fieldCount = NULL,
|
||||
bool allFieldPositions = false) const;
|
||||
|
||||
const Symbol *DigitSymbols() const;
|
||||
const Symbol *FractionSeparator() const;
|
||||
const GroupingInfo *GetGroupingInfo() const;
|
||||
const Symbol *ExponentSymbol(bool upperCase = false) const;
|
||||
const Symbol *NaNSymbol(bool upperCase = false) const;
|
||||
const Symbol *InfinitySymbol(bool upperCase = false) const;
|
||||
const Symbol *NegativeInfinitySymbol(bool upperCase = false) const;
|
||||
void GetSpecialNumberSymbols(bool upperCase,
|
||||
SpecialNumberSymbols *symbols) const;
|
||||
const SignSymbols *GetSignSymbols() const;
|
||||
const SignSymbols *MantissaSignSymbols() const;
|
||||
const SignSymbols *ExponentSignSymbols() const;
|
||||
|
||||
static status_t _SetSymbol(Symbol **symbol, const char *str);
|
||||
|
||||
BIntegerFormatParameters fIntegerParameters;
|
||||
BFloatFormatParameters fFloatParameters;
|
||||
Symbol *fDigitSymbols;
|
||||
Symbol *fFractionSeparator;
|
||||
GroupingInfo *fGroupingInfo;
|
||||
Symbol *fExponentSymbol;
|
||||
Symbol *fUpperCaseExponentSymbol;
|
||||
Symbol *fNaNSymbol;
|
||||
Symbol *fUpperCaseNaNSymbol;
|
||||
Symbol *fInfinitySymbol;
|
||||
Symbol *fUpperCaseInfinitySymbol;
|
||||
Symbol *fNegativeInfinitySymbol;
|
||||
Symbol *fUpperCaseNegativeInfinitySymbol;
|
||||
SignSymbols *fSignSymbols;
|
||||
SignSymbols *fMantissaSignSymbols;
|
||||
SignSymbols *fExponentSignSymbols;
|
||||
};
|
||||
|
||||
#endif // _B_GENERIC_NUMBER_FORMAT_H_
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef _B_INTEGER_FORMAT_H_
|
||||
#define _B_INTEGER_FORMAT_H_
|
||||
|
||||
#include <NumberFormat.h>
|
||||
#include <IntegerFormatParameters.h>
|
||||
|
||||
class BIntegerFormatImpl;
|
||||
class BString;
|
||||
|
||||
// Note: BIntegerFormat is derived from BIntegerFormatParameters only due
|
||||
// to my laziness. The parameters should probably be a private member
|
||||
// and this class (and its base classes) should mirror the parameters
|
||||
// classes' accessor methods.
|
||||
//
|
||||
class _IMPEXP_LOCALE BIntegerFormat : public BNumberFormat, public BIntegerFormatParameters {
|
||||
public:
|
||||
BIntegerFormat(const BIntegerFormat &other);
|
||||
~BIntegerFormat();
|
||||
|
||||
// formatting
|
||||
|
||||
// no-frills version: Simply appends the formatted number to the
|
||||
// string buffer. Can fail only with B_NO_MEMORY or B_BAD_VALUE.
|
||||
status_t Format(int64 number, BString *buffer) const;
|
||||
|
||||
// Appends the formatted number to the string buffer. Additionally
|
||||
// one can get the positions of certain fields in the formatted
|
||||
// number by supplying format_field_position structures with the
|
||||
// field_type set respectively. Passing true for allFieldPositions
|
||||
// will make the method fill in a format_field_position structure for
|
||||
// each field it writes -- the field_type values will be ignored and
|
||||
// overwritten.
|
||||
// In fieldCount, in case it is non-null, the number of fields
|
||||
// written is returned.
|
||||
// B_BUFFER_OVERFLOW is returned, if allFieldPositions is true and
|
||||
// the positions buffer is too small (fieldCount will be set
|
||||
// nevertheless, so that the caller can adjust the buffer size to
|
||||
// make them all fit).
|
||||
status_t Format(int64 number, BString *buffer,
|
||||
format_field_position *positions,
|
||||
int32 positionCount = 1,
|
||||
int32 *fieldCount = NULL,
|
||||
bool allFieldPositions = false) const;
|
||||
|
||||
// TODO: Format() versions for (char* buffer, size_t bufferSize)
|
||||
// instead of BString*. And, of course, versions for the other
|
||||
// number types (uint64, uint32,...).
|
||||
|
||||
// parsing
|
||||
// TODO: ...
|
||||
|
||||
BIntegerFormat &operator=(const BIntegerFormat &other);
|
||||
|
||||
BIntegerFormat(BIntegerFormatImpl *impl); // conceptually private
|
||||
|
||||
private:
|
||||
inline BIntegerFormatImpl *IntegerFormatImpl() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // _B_INTEGER_FORMAT_H_
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef _B_INTEGER_FORMAT_IMPL_H_
|
||||
#define _B_INTEGER_FORMAT_IMPL_H_
|
||||
|
||||
#include <NumberFormatImpl.h>
|
||||
|
||||
struct format_field_position;
|
||||
class BIntegerFormatParameters;
|
||||
class BString;
|
||||
|
||||
class _IMPEXP_LOCALE BIntegerFormatImpl : public BNumberFormatImpl {
|
||||
public:
|
||||
BIntegerFormatImpl();
|
||||
virtual ~BIntegerFormatImpl();
|
||||
|
||||
// formatting
|
||||
|
||||
virtual status_t Format(const BIntegerFormatParameters *parameters,
|
||||
int64 number, BString *buffer) const = 0;
|
||||
virtual status_t Format(const BIntegerFormatParameters *parameters,
|
||||
int64 number, BString *buffer,
|
||||
format_field_position *positions,
|
||||
int32 positionCount = 1,
|
||||
int32 *fieldCount = NULL,
|
||||
bool allFieldPositions = false) const = 0;
|
||||
|
||||
// TODO: ...
|
||||
|
||||
virtual BNumberFormatParameters *DefaultNumberFormatParameters();
|
||||
virtual const BNumberFormatParameters *DefaultNumberFormatParameters()
|
||||
const;
|
||||
|
||||
virtual BIntegerFormatParameters *DefaultIntegerFormatParameters() = 0;
|
||||
virtual const BIntegerFormatParameters *DefaultIntegerFormatParameters()
|
||||
const = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // _B_INTEGER_FORMAT_IMPL_H_
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef _B_INTEGER_FORMAT_PARAMETERS_H_
|
||||
#define _B_INTEGER_FORMAT_PARAMETERS_H_
|
||||
|
||||
#include <NumberFormatParameters.h>
|
||||
|
||||
class _IMPEXP_LOCALE BIntegerFormatParameters : public BNumberFormatParameters {
|
||||
public:
|
||||
BIntegerFormatParameters(const BIntegerFormatParameters *parent = NULL);
|
||||
BIntegerFormatParameters(const BIntegerFormatParameters &other);
|
||||
~BIntegerFormatParameters();
|
||||
|
||||
void SetParentIntegerParameters(const BIntegerFormatParameters *parent);
|
||||
const BIntegerFormatParameters *ParentIntegerParameters() const;
|
||||
|
||||
BIntegerFormatParameters &operator=(
|
||||
const BIntegerFormatParameters &other);
|
||||
|
||||
private:
|
||||
const BIntegerFormatParameters *fParent;
|
||||
};
|
||||
|
||||
#endif // _B_INTEGER_FORMAT_PARAMETERS_H_
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef _LANGUAGE_H_
|
||||
#define _LANGUAGE_H_
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <LocaleBuild.h>
|
||||
#include <LocaleStrings.h>
|
||||
|
||||
|
||||
enum script_direction {
|
||||
B_LEFT_TO_RIGHT = 0,
|
||||
B_RIGHT_TO_LEFT,
|
||||
B_TOP_TO_BOTTOM, // seems not to be supported anywhere else?
|
||||
};
|
||||
|
||||
|
||||
class _IMPEXP_LOCALE BLanguage {
|
||||
public:
|
||||
~BLanguage();
|
||||
|
||||
// language name, e.g. "english", "deutsch"
|
||||
const char *Name() const { return fName; }
|
||||
// ISO-639 language code, e.g. "en", "de"
|
||||
const char *Code() const { return fCode; }
|
||||
// ISO-639 language family, e.g. "germanic"
|
||||
const char *Family() const { return fFamily; }
|
||||
|
||||
uint8 Direction() const;
|
||||
|
||||
// see definitions below
|
||||
const char *GetString(uint32 id) const;
|
||||
|
||||
private:
|
||||
friend class BLocaleRoster;
|
||||
|
||||
BLanguage(const char *language);
|
||||
void Default();
|
||||
|
||||
char *fName, *fCode, *fFamily, *fStrings[B_NUM_LANGUAGE_STRINGS];
|
||||
uint8 fDirection;
|
||||
};
|
||||
|
||||
#endif /* _LANGUAGE_H_ */
|
||||
@@ -0,0 +1,113 @@
|
||||
#ifndef _B_LOCALE_H_
|
||||
#define _B_LOCALE_H_
|
||||
|
||||
|
||||
#include <LocaleBuild.h>
|
||||
|
||||
#include <Collator.h>
|
||||
#include <Language.h>
|
||||
#include <Country.h>
|
||||
|
||||
|
||||
class BCatalog;
|
||||
class BString;
|
||||
|
||||
|
||||
class _IMPEXP_LOCALE BLocale {
|
||||
public:
|
||||
BLocale();
|
||||
~BLocale();
|
||||
|
||||
BCollator *Collator() const { return fCollator; }
|
||||
BCountry *Country() const { return fCountry; }
|
||||
BLanguage *Language() const { return fLanguage; }
|
||||
|
||||
// see definitions in LocaleStrings.h
|
||||
const char *GetString(uint32 id);
|
||||
|
||||
void FormatString(char *target, size_t maxSize, char *fmt, ...);
|
||||
void FormatString(BString *, char *fmt, ...);
|
||||
void FormatDateTime(char *target, size_t maxSize, const char *fmt, time_t);
|
||||
void FormatDateTime(BString *, const char *fmt, time_t);
|
||||
|
||||
// Country short-hands
|
||||
|
||||
void FormatDate(char *target, size_t maxSize, time_t, bool longFormat);
|
||||
void FormatDate(BString *target, time_t, bool longFormat);
|
||||
void FormatTime(char *target, size_t maxSize, time_t, bool longFormat);
|
||||
void FormatTime(BString *target, time_t, bool longFormat);
|
||||
|
||||
// Collator short-hands
|
||||
|
||||
int StringCompare(const char *, const char *, int32 len = -1, int8 strength = B_COLLATE_DEFAULT) const;
|
||||
int StringCompare(const BString *, const BString *, int32 len = -1, int8 strength = B_COLLATE_DEFAULT) const;
|
||||
|
||||
void GetSortKey(const char *string, BString *key);
|
||||
|
||||
status_t GetAppCatalog(BCatalog *);
|
||||
|
||||
protected:
|
||||
BCollator *fCollator;
|
||||
BLanguage *fLanguage;
|
||||
BCountry *fCountry;
|
||||
};
|
||||
|
||||
// global objects
|
||||
extern _IMPEXP_LOCALE BLocale *be_locale;
|
||||
extern _IMPEXP_LOCALE BLocaleRoster *be_locale_roster;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//--- country short-hands inlines ---
|
||||
|
||||
inline void
|
||||
BLocale::FormatDate(char *target, size_t maxSize, time_t timer, bool longFormat)
|
||||
{
|
||||
fCountry->FormatDate(target, maxSize, timer, longFormat);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
BLocale::FormatDate(BString *target, time_t timer, bool longFormat)
|
||||
{
|
||||
fCountry->FormatDate(target, timer, longFormat);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
BLocale::FormatTime(char *target, size_t maxSize, time_t timer, bool longFormat)
|
||||
{
|
||||
fCountry->FormatTime(target, maxSize, timer, longFormat);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
BLocale::FormatTime(BString *target, time_t timer, bool longFormat)
|
||||
{
|
||||
fCountry->FormatTime(target, timer, longFormat);
|
||||
}
|
||||
|
||||
|
||||
//--- locale short-hands inlines ---
|
||||
// #pragma mark -
|
||||
|
||||
inline int
|
||||
BLocale::StringCompare(const char *string1, const char *string2, int32 length, int8 strength) const
|
||||
{
|
||||
return fCollator->Compare(string1, string2, length, strength);
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
BLocale::StringCompare(const BString *string1, const BString *string2, int32 length, int8 strength) const
|
||||
{
|
||||
return fCollator->Compare(string1->String(), string2->String(), length, strength);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
BLocale::GetSortKey(const char *string, BString *key)
|
||||
{
|
||||
fCollator->GetSortKey(string, key);
|
||||
}
|
||||
|
||||
#endif /* _B_LOCALE_H_ */
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef _B_LOCALE_BUILD_H_
|
||||
#define _B_LOCALE_BUILD_H_
|
||||
|
||||
#if _BUILDING_locale
|
||||
#define _IMPEXP_LOCALE __declspec(dllexport)
|
||||
#else
|
||||
#define _IMPEXP_LOCALE __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /* _B_LOCALE_BUILD_H_ */
|
||||
@@ -0,0 +1,84 @@
|
||||
#ifndef _LOCALE_ROSTER_H_
|
||||
#define _LOCALE_ROSTER_H_
|
||||
|
||||
#include <LocaleBuild.h>
|
||||
|
||||
#include <String.h>
|
||||
|
||||
class BLanguage;
|
||||
class BLocale;
|
||||
class BCollator;
|
||||
class BCountry;
|
||||
class BCatalog;
|
||||
class BCatalogAddOn;
|
||||
|
||||
namespace BPrivate {
|
||||
class EditableCatalog;
|
||||
};
|
||||
|
||||
enum {
|
||||
B_LOCALE_CHANGED = '_LCC',
|
||||
};
|
||||
|
||||
class _IMPEXP_LOCALE BLocaleRoster {
|
||||
|
||||
public:
|
||||
BLocaleRoster();
|
||||
~BLocaleRoster();
|
||||
|
||||
// status_t GetCatalog(BLocale *,const char *mimeType, BCatalog *catalog);
|
||||
// status_t GetCatalog(const char *mimeType, BCatalog *catalog);
|
||||
// status_t SetCatalog(BLocale *,const char *mimeType, BCatalog *catalog);
|
||||
|
||||
// status_t GetLocaleFor(const char *langCode,const char *countryCode);
|
||||
|
||||
status_t GetDefaultCollator(BCollator **) const;
|
||||
status_t GetDefaultLanguage(BLanguage **) const;
|
||||
status_t GetDefaultCountry(BCountry **) const;
|
||||
|
||||
status_t GetPreferredLanguages(BMessage *) const;
|
||||
status_t SetPreferredLanguages(BMessage *);
|
||||
// the message contains one or more 'language'-string-fields
|
||||
// which contain the language-name(s)
|
||||
|
||||
status_t GetInstalledLanguages(BMessage *) const;
|
||||
// the message contains one or more 'language'-string-fields
|
||||
// which contain the language-name(s)
|
||||
|
||||
status_t GetInstalledCatalogs(BMessage *,
|
||||
const char* sigPattern = NULL,
|
||||
const char* langPattern = NULL,
|
||||
int32 fingerprint = 0) const;
|
||||
// the message contains...
|
||||
|
||||
// status_t GetDefaultLanguage(BLanguage *);
|
||||
// status_t SetDefaultLanguage(BLanguage *);
|
||||
|
||||
static const char *kCatLangAttr;
|
||||
static const char *kCatSigAttr;
|
||||
static const char *kCatFingerprintAttr;
|
||||
//
|
||||
static const char *kCatManagerMimeType;
|
||||
static const char *kCatEditorMimeType;
|
||||
//
|
||||
static const char *kEmbeddedCatAttr;
|
||||
static int32 kEmbeddedCatResId;
|
||||
|
||||
private:
|
||||
|
||||
BCatalogAddOn* LoadCatalog(const char *signature,
|
||||
const char *language = NULL,
|
||||
int32 fingerprint = 0);
|
||||
BCatalogAddOn* LoadEmbeddedCatalog(entry_ref *appOrAddOnRef);
|
||||
status_t UnloadCatalog(BCatalogAddOn *addOn);
|
||||
//
|
||||
BCatalogAddOn* CreateCatalog(const char *type,
|
||||
const char *signature,
|
||||
const char *language);
|
||||
|
||||
friend class BCatalog;
|
||||
friend class BPrivate::EditableCatalog;
|
||||
friend status_t get_add_on_catalog(BCatalog*, const char *);
|
||||
};
|
||||
|
||||
#endif /* _LOCALE_ROSTER_H_ */
|
||||
@@ -0,0 +1,108 @@
|
||||
#ifndef _LOCALE_STRINGS_H_
|
||||
#define _LOCALE_STRINGS_H_
|
||||
|
||||
|
||||
enum country_strings {
|
||||
B_COUNTRY_STRINGS_BASE = 0,
|
||||
|
||||
B_DATE_TIME_FORMAT = B_COUNTRY_STRINGS_BASE,
|
||||
B_DATE_FORMAT,
|
||||
B_TIME_FORMAT,
|
||||
B_TIME_AM_PM_FORMAT,
|
||||
|
||||
B_SHORT_DATE_TIME_FORMAT,
|
||||
B_SHORT_DATE_FORMAT,
|
||||
B_SHORT_TIME_FORMAT,
|
||||
B_SHORT_TIME_AM_PM_FORMAT,
|
||||
|
||||
B_AM_STRING,
|
||||
B_PM_STRING,
|
||||
|
||||
B_DATE_SEPARATOR,
|
||||
B_TIME_SEPARATOR,
|
||||
B_GROUPING,
|
||||
B_DECIMAL_POINT,
|
||||
B_THOUSANDS_SEPARATOR,
|
||||
B_POSITIVE_SIGN,
|
||||
B_NEGATIVE_SIGN,
|
||||
|
||||
B_CURRENCY_SYMBOL,
|
||||
B_INT_CURRENCY_SYMBOL,
|
||||
B_MON_GROUPING,
|
||||
B_MON_DECIMAL_POINT,
|
||||
B_MON_THOUSANDS_SEPARATOR,
|
||||
|
||||
B_NUM_COUNTRY_STRINGS,
|
||||
};
|
||||
|
||||
enum language_strings {
|
||||
B_LANGUAGE_STRINGS_BASE = 100,
|
||||
|
||||
B_YESTERDAY_STRING = B_LANGUAGE_STRINGS_BASE,
|
||||
B_TODAY_STRING,
|
||||
B_TOMORROW_STRING,
|
||||
B_FUTURE_STRING,
|
||||
|
||||
B_DAY_1, // name of the first day of the week, e.g. Sunday
|
||||
B_DAY_2, // ...
|
||||
B_DAY_3, //
|
||||
B_DAY_4,
|
||||
B_DAY_5,
|
||||
B_DAY_6,
|
||||
B_DAY_7,
|
||||
|
||||
B_AB_DAY_1, // abbreviated weekday name, e.g. Sun
|
||||
B_AB_DAY_2, // ...
|
||||
B_AB_DAY_3,
|
||||
B_AB_DAY_4,
|
||||
B_AB_DAY_5,
|
||||
B_AB_DAY_6,
|
||||
B_AB_DAY_7,
|
||||
|
||||
B_MON_1, // name of the first month of the year, e.g. January
|
||||
B_MON_2, // ...
|
||||
B_MON_3,
|
||||
B_MON_4,
|
||||
B_MON_5,
|
||||
B_MON_6,
|
||||
B_MON_7,
|
||||
B_MON_8,
|
||||
B_MON_9,
|
||||
B_MON_10,
|
||||
B_MON_11,
|
||||
B_MON_12,
|
||||
|
||||
B_AB_MON_1, // abbreviated month name, e.g. Jan
|
||||
B_AB_MON_2, // ...
|
||||
B_AB_MON_3,
|
||||
B_AB_MON_4,
|
||||
B_AB_MON_5,
|
||||
B_AB_MON_6,
|
||||
B_AB_MON_7,
|
||||
B_AB_MON_8,
|
||||
B_AB_MON_9,
|
||||
B_AB_MON_10,
|
||||
B_AB_MON_11,
|
||||
B_AB_MON_12,
|
||||
|
||||
B_YES_EXPRESSION,
|
||||
B_NO_EXPRESSION,
|
||||
B_YES_STRING,
|
||||
B_NO_STRING,
|
||||
|
||||
B_NUM_LANGUAGE_STRINGS = B_AB_MON_12 - B_LANGUAGE_STRINGS_BASE,
|
||||
};
|
||||
|
||||
// specials for POSIX compatibility
|
||||
enum other_locale_strings {
|
||||
B_OTHER_STRINGS_BASE = 200,
|
||||
|
||||
B_CODESET = B_OTHER_STRINGS_BASE,
|
||||
B_ERA,
|
||||
B_ERA_DATE_FORMAT,
|
||||
B_ERA_DATE_TIME_FORMAT,
|
||||
B_ERA_TIME_FORMAT,
|
||||
B_ALT_DIGITS
|
||||
};
|
||||
|
||||
#endif /* _LOCALE_STRINGS_H_ */
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef _B_NUMBER_FORMAT_H_
|
||||
#define _B_NUMBER_FORMAT_H_
|
||||
|
||||
#include <Format.h>
|
||||
#include <NumberFormatParameters.h>
|
||||
|
||||
class BNumberFormatImpl;
|
||||
|
||||
class _IMPEXP_LOCALE BNumberFormat : public BFormat {
|
||||
protected:
|
||||
BNumberFormat(const BNumberFormat &other);
|
||||
~BNumberFormat();
|
||||
|
||||
BNumberFormat &operator=(const BNumberFormat &other);
|
||||
|
||||
BNumberFormat(BNumberFormatImpl *impl);
|
||||
|
||||
private:
|
||||
inline BNumberFormatImpl *NumberFormatImpl() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // _B_NUMBER_FORMAT_H_
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef _B_NUMBER_FORMAT_IMPL_H_
|
||||
#define _B_NUMBER_FORMAT_IMPL_H_
|
||||
|
||||
#include <FormatImpl.h>
|
||||
|
||||
struct format_field_position;
|
||||
class BNumberFormatParameters;
|
||||
|
||||
class _IMPEXP_LOCALE BNumberFormatImpl : public BFormatImpl {
|
||||
public:
|
||||
BNumberFormatImpl();
|
||||
virtual ~BNumberFormatImpl();
|
||||
|
||||
virtual BFormatParameters *DefaultFormatParameters();
|
||||
virtual const BFormatParameters *DefaultFormatParameters() const;
|
||||
|
||||
virtual BNumberFormatParameters *DefaultNumberFormatParameters() = 0;
|
||||
virtual const BNumberFormatParameters *DefaultNumberFormatParameters()
|
||||
const = 0;
|
||||
};
|
||||
|
||||
#endif // _B_NUMBER_FORMAT_IMPL_H_
|
||||
@@ -0,0 +1,66 @@
|
||||
#ifndef _B_NUMBER_FORMAT_PARAMETERS_H_
|
||||
#define _B_NUMBER_FORMAT_PARAMETERS_H_
|
||||
|
||||
#include <FormatParameters.h>
|
||||
|
||||
enum number_format_sign_policy {
|
||||
B_USE_NEGATIVE_SIGN_ONLY,
|
||||
B_USE_SPACE_FOR_POSITIVE_SIGN,
|
||||
B_USE_POSITIVE_SIGN,
|
||||
};
|
||||
|
||||
enum number_format_base {
|
||||
B_DEFAULT_BASE = -1, // locale default, usually decimal, but
|
||||
// may be something like roman as well
|
||||
B_FLEXIBLE_DECIMAL_BASE = 0, // same as B_DECIMAL_BASE when formatting,
|
||||
// but recognizes octal and hexadecimal
|
||||
// numbers by prefix when parsing
|
||||
B_OCTAL_BASE = 8,
|
||||
B_DECIMAL_BASE = 10,
|
||||
B_HEXADECIMAL_BASE = 16,
|
||||
};
|
||||
|
||||
class _IMPEXP_LOCALE BNumberFormatParameters : public BFormatParameters {
|
||||
public:
|
||||
BNumberFormatParameters(const BNumberFormatParameters *parent = NULL);
|
||||
BNumberFormatParameters(const BNumberFormatParameters &other);
|
||||
~BNumberFormatParameters();
|
||||
|
||||
void SetUseGrouping(bool useGrouping);
|
||||
bool UseGrouping() const;
|
||||
|
||||
void SetSignPolicy(number_format_sign_policy policy);
|
||||
number_format_sign_policy SignPolicy() const;
|
||||
|
||||
void SetBase(number_format_base base);
|
||||
number_format_base Base() const;
|
||||
|
||||
void SetUseBasePrefix(bool useBasePrefix);
|
||||
bool UseBasePrefix() const;
|
||||
|
||||
void SetMinimalIntegerDigits(size_t minIntegerDigits);
|
||||
size_t MinimalIntegerDigits() const;
|
||||
|
||||
void SetUseZeroPadding(bool zeroPadding);
|
||||
bool UseZeroPadding() const;
|
||||
|
||||
const BNumberFormatParameters *ParentNumberParameters() const;
|
||||
|
||||
BNumberFormatParameters &operator=(
|
||||
const BNumberFormatParameters &other);
|
||||
|
||||
protected:
|
||||
void SetParentNumberParameters(const BNumberFormatParameters *parent);
|
||||
|
||||
private:
|
||||
const BNumberFormatParameters *fParent;
|
||||
bool fUseGrouping;
|
||||
number_format_sign_policy fSignPolicy;
|
||||
number_format_base fBase;
|
||||
bool fUseBasePrefix;
|
||||
size_t fMinimalIntegerDigits;
|
||||
bool fUseZeroPadding;
|
||||
uint32 fFlags;
|
||||
};
|
||||
|
||||
#endif // _B_NUMBER_FORMAT_PARAMETERS_H_
|
||||
@@ -0,0 +1,235 @@
|
||||
#ifndef _UNICODE_CHAR_H_
|
||||
#define _UNICODE_CHAR_H_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <LocaleBuild.h>
|
||||
|
||||
enum unicode_char_category
|
||||
{
|
||||
// Non-category for unassigned and non-character code points.
|
||||
B_UNICODE_UNASSIGNED = 0,
|
||||
|
||||
B_UNICODE_UPPERCASE_LETTER = 1, // Lu
|
||||
B_UNICODE_LOWERCASE_LETTER = 2, // Ll
|
||||
B_UNICODE_TITLECASE_LETTER = 3, // Lt
|
||||
B_UNICODE_MODIFIER_LETTER = 4, // Lm
|
||||
B_UNICODE_OTHER_LETTER = 5, // Lo
|
||||
B_UNICODE_NON_SPACING_MARK = 6, // Mn
|
||||
B_UNICODE_ENCLOSING_MARK = 7, // Me
|
||||
B_UNICODE_COMBINING_SPACING_MARK = 8, // Mc
|
||||
B_UNICODE_DECIMAL_DIGIT_NUMBER = 9, // Nd
|
||||
B_UNICODE_LETTER_NUMBER = 10, // Nl
|
||||
B_UNICODE_OTHER_NUMBER = 11, // No
|
||||
B_UNICODE_SPACE_SEPARATOR = 12, // Zs
|
||||
B_UNICODE_LINE_SEPARATOR = 13, // Zl
|
||||
B_UNICODE_PARAGRAPH_SEPARATOR = 14, // Zp
|
||||
B_UNICODE_CONTROL_CHAR = 15, // Cc
|
||||
B_UNICODE_FORMAT_CHAR = 16, // Cf
|
||||
B_UNICODE_PRIVATE_USE_CHAR = 17, // Co
|
||||
B_UNICODE_SURROGATE = 18, // Cs
|
||||
B_UNICODE_DASH_PUNCTUATION = 19, // Pd
|
||||
B_UNICODE_START_PUNCTUATION = 20, // Ps
|
||||
B_UNICODE_END_PUNCTUATION = 21, // Pe
|
||||
B_UNICODE_CONNECTOR_PUNCTUATION = 22, // Pc
|
||||
B_UNICODE_OTHER_PUNCTUATION = 23, // Po
|
||||
B_UNICODE_MATH_SYMBOL = 24, // Sm
|
||||
B_UNICODE_CURRENCY_SYMBOL = 25, // Sc
|
||||
B_UNICODE_MODIFIER_SYMBOL = 26, // Sk
|
||||
B_UNICODE_OTHER_SYMBOL = 27, // So
|
||||
B_UNICODE_INITIAL_PUNCTUATION = 28, // Pi
|
||||
B_UNICODE_FINAL_PUNCTUATION = 29, // Pf
|
||||
B_UNICODE_GENERAL_OTHER_TYPES = 30, // Cn
|
||||
|
||||
B_UNICODE_CATEGORY_COUNT
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This specifies the language directional property of a character set.
|
||||
*/
|
||||
|
||||
enum unicode_char_direction {
|
||||
B_UNICODE_LEFT_TO_RIGHT = 0,
|
||||
B_UNICODE_RIGHT_TO_LEFT = 1,
|
||||
B_UNICODE_EUROPEAN_NUMBER = 2,
|
||||
B_UNICODE_EUROPEAN_NUMBER_SEPARATOR = 3,
|
||||
B_UNICODE_EUROPEAN_NUMBER_TERMINATOR = 4,
|
||||
B_UNICODE_ARABIC_NUMBER = 5,
|
||||
B_UNICODE_COMMON_NUMBER_SEPARATOR = 6,
|
||||
B_UNICODE_BLOCK_SEPARATOR = 7,
|
||||
B_UNICODE_SEGMENT_SEPARATOR = 8,
|
||||
B_UNICODE_WHITE_SPACE_NEUTRAL = 9,
|
||||
B_UNICODE_OTHER_NEUTRAL = 10,
|
||||
B_UNICODE_LEFT_TO_RIGHT_EMBEDDING = 11,
|
||||
B_UNICODE_LEFT_TO_RIGHT_OVERRIDE = 12,
|
||||
B_UNICODE_RIGHT_TO_LEFT_ARABIC = 13,
|
||||
B_UNICODE_RIGHT_TO_LEFT_EMBEDDING = 14,
|
||||
B_UNICODE_RIGHT_TO_LEFT_OVERRIDE = 15,
|
||||
B_UNICODE_POP_DIRECTIONAL_FORMAT = 16,
|
||||
B_UNICODE_DIR_NON_SPACING_MARK = 17,
|
||||
B_UNICODE_BOUNDARY_NEUTRAL = 18,
|
||||
|
||||
B_UNICODE_DIRECTION_COUNT
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Script range as defined in the Unicode standard.
|
||||
*/
|
||||
|
||||
enum unicode_char_script {
|
||||
// Script names
|
||||
B_UNICODE_BASIC_LATIN,
|
||||
B_UNICODE_LATIN_1_SUPPLEMENT,
|
||||
B_UNICODE_LATIN_EXTENDED_A,
|
||||
B_UNICODE_LATIN_EXTENDED_B,
|
||||
B_UNICODE_IPA_EXTENSIONS,
|
||||
B_UNICODE_SPACING_MODIFIER_LETTERS,
|
||||
B_UNICODE_COMBINING_DIACRITICAL_MARKS,
|
||||
B_UNICODE_GREEK,
|
||||
B_UNICODE_CYRILLIC,
|
||||
B_UNICODE_ARMENIAN,
|
||||
B_UNICODE_HEBREW,
|
||||
B_UNICODE_ARABIC,
|
||||
B_UNICODE_SYRIAC,
|
||||
B_UNICODE_THAANA,
|
||||
B_UNICODE_DEVANAGARI,
|
||||
B_UNICODE_BENGALI,
|
||||
B_UNICODE_GURMUKHI,
|
||||
B_UNICODE_GUJARATI,
|
||||
B_UNICODE_ORIYA,
|
||||
B_UNICODE_TAMIL,
|
||||
B_UNICODE_TELUGU,
|
||||
B_UNICODE_KANNADA,
|
||||
B_UNICODE_MALAYALAM,
|
||||
B_UNICODE_SINHALA,
|
||||
B_UNICODE_THAI,
|
||||
B_UNICODE_LAO,
|
||||
B_UNICODE_TIBETAN,
|
||||
B_UNICODE_MYANMAR,
|
||||
B_UNICODE_GEORGIAN,
|
||||
B_UNICODE_HANGUL_JAMO,
|
||||
B_UNICODE_ETHIOPIC,
|
||||
B_UNICODE_CHEROKEE,
|
||||
B_UNICODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS,
|
||||
B_UNICODE_OGHAM,
|
||||
B_UNICODE_RUNIC,
|
||||
B_UNICODE_KHMER,
|
||||
B_UNICODE_MONGOLIAN,
|
||||
B_UNICODE_LATIN_EXTENDED_ADDITIONAL,
|
||||
B_UNICODE_GREEK_EXTENDED,
|
||||
B_UNICODE_GENERAL_PUNCTUATION,
|
||||
B_UNICODE_SUPERSCRIPTS_AND_SUBSCRIPTS,
|
||||
B_UNICODE_CURRENCY_SYMBOLS,
|
||||
B_UNICODE_COMBINING_MARKS_FOR_SYMBOLS,
|
||||
B_UNICODE_LETTERLIKE_SYMBOLS,
|
||||
B_UNICODE_NUMBER_FORMS,
|
||||
B_UNICODE_ARROWS,
|
||||
B_UNICODE_MATHEMATICAL_OPERATORS,
|
||||
B_UNICODE_MISCELLANEOUS_TECHNICAL,
|
||||
B_UNICODE_CONTROL_PICTURES,
|
||||
B_UNICODE_OPTICAL_CHARACTER_RECOGNITION,
|
||||
B_UNICODE_ENCLOSED_ALPHANUMERICS,
|
||||
B_UNICODE_BOX_DRAWING,
|
||||
B_UNICODE_BLOCK_ELEMENTS,
|
||||
B_UNICODE_GEOMETRIC_SHAPES,
|
||||
B_UNICODE_MISCELLANEOUS_SYMBOLS,
|
||||
B_UNICODE_DINGBATS,
|
||||
B_UNICODE_BRAILLE_PATTERNS,
|
||||
B_UNICODE_CJK_RADICALS_SUPPLEMENT,
|
||||
B_UNICODE_KANGXI_RADICALS,
|
||||
B_UNICODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS,
|
||||
B_UNICODE_CJK_SYMBOLS_AND_PUNCTUATION,
|
||||
B_UNICODE_HIRAGANA,
|
||||
B_UNICODE_KATAKANA,
|
||||
B_UNICODE_BOPOMOFO,
|
||||
B_UNICODE_HANGUL_COMPATIBILITY_JAMO,
|
||||
B_UNICODE_KANBUN,
|
||||
B_UNICODE_BOPOMOFO_EXTENDED,
|
||||
B_UNICODE_ENCLOSED_CJK_LETTERS_AND_MONTHS,
|
||||
B_UNICODE_CJK_COMPATIBILITY,
|
||||
B_UNICODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A,
|
||||
B_UNICODE_CJK_UNIFIED_IDEOGRAPHS,
|
||||
B_UNICODE_YI_SYLLABLES,
|
||||
B_UNICODE_YI_RADICALS,
|
||||
B_UNICODE_HANGUL_SYLLABLES,
|
||||
B_UNICODE_HIGH_SURROGATES,
|
||||
B_UNICODE_HIGH_PRIVATE_USE_SURROGATES,
|
||||
B_UNICODE_LOW_SURROGATES,
|
||||
B_UNICODE_PRIVATE_USE_AREA,
|
||||
B_UNICODE_CJK_COMPATIBILITY_IDEOGRAPHS,
|
||||
B_UNICODE_ALPHABETIC_PRESENTATION_FORMS,
|
||||
B_UNICODE_ARABIC_PRESENTATION_FORMS_A,
|
||||
B_UNICODE_COMBINING_HALF_MARKS,
|
||||
B_UNICODE_CJK_COMPATIBILITY_FORMS,
|
||||
B_UNICODE_SMALL_FORM_VARIANTS,
|
||||
B_UNICODE_ARABIC_PRESENTATION_FORMS_B,
|
||||
B_UNICODE_SPECIALS,
|
||||
B_UNICODE_HALFWIDTH_AND_FULLWIDTH_FORMS,
|
||||
|
||||
B_UNICODE_SCRIPT_COUNT,
|
||||
B_UNICODE_NO_SCRIPT = B_UNICODE_SCRIPT_COUNT
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Values returned by the u_getCellWidth() function.
|
||||
*/
|
||||
|
||||
enum unicode_cell_width
|
||||
{
|
||||
B_UNICODE_ZERO_WIDTH = 0,
|
||||
B_UNICODE_HALF_WIDTH = 1,
|
||||
B_UNICODE_FULL_WIDTH = 2,
|
||||
B_UNICODE_NEUTRAL_WIDTH = 3,
|
||||
|
||||
B_UNICODE_CELL_WIDTH_COUNT
|
||||
};
|
||||
|
||||
|
||||
class _IMPEXP_LOCALE BUnicodeChar {
|
||||
public:
|
||||
static bool IsAlpha(uint32 c);
|
||||
static bool IsAlNum(uint32 c);
|
||||
static bool IsDigit(uint32 c);
|
||||
static bool IsHexDigit(uint32 c);
|
||||
static bool IsUpper(uint32 c);
|
||||
static bool IsLower(uint32 c);
|
||||
static bool IsSpace(uint32 c);
|
||||
static bool IsWhitespace(uint32 c);
|
||||
static bool IsControl(uint32 c);
|
||||
static bool IsPunctuation(uint32 c);
|
||||
static bool IsPrintable(uint32 c);
|
||||
static bool IsTitle(uint32 c);
|
||||
static bool IsDefined(uint32 c);
|
||||
static bool IsBase(uint32 c);
|
||||
|
||||
static int8 Type(uint32 c);
|
||||
|
||||
static uint32 ToLower(uint32 c);
|
||||
static uint32 ToUpper(uint32 c);
|
||||
static uint32 ToTitle(uint32 c);
|
||||
static int32 DigitValue(uint32 c);
|
||||
|
||||
static void ToUTF8(uint32 c, char **out);
|
||||
static uint32 FromUTF8(const char **in);
|
||||
static uint32 FromUTF8(const char *in);
|
||||
|
||||
static size_t UTF8StringLength(const char *str);
|
||||
static size_t UTF8StringLength(const char *str, size_t maxLength);
|
||||
|
||||
private:
|
||||
BUnicodeChar();
|
||||
};
|
||||
|
||||
|
||||
inline uint32
|
||||
BUnicodeChar::FromUTF8(const char *in)
|
||||
{
|
||||
const char *string = in;
|
||||
return FromUTF8(&string);
|
||||
}
|
||||
|
||||
|
||||
#endif /* _UNICODE_CHAR_H_ */
|
||||
@@ -0,0 +1,86 @@
|
||||
#ifndef _LANGINFO_H_
|
||||
#define _LANGINFO_H_
|
||||
|
||||
#include <LocaleBuild.h>
|
||||
|
||||
#include <LocaleStrings.h>
|
||||
#include <nl_types.h>
|
||||
|
||||
#define CODESET B_CODESET /* codeset name */
|
||||
#define D_T_FMT B_DATE_TIME_FORMAT /* string for formatting date and time */
|
||||
#define D_FMT B_DATE_FORMAT /* date format string */
|
||||
#define T_FMT B_TIME_FORMAT /* time format string */
|
||||
#define T_FMT_AMPM B_AM_PM_TIME_FORMAT /* a.m. or p.m. time formatting string */
|
||||
#define AM_STR B_AM_STRING /* Ante Meridian affix */
|
||||
#define PM_STR B_PM_STRING /* Post Meridian affix */
|
||||
|
||||
/* week day names */
|
||||
#define DAY_1 B_DAY_1
|
||||
#define DAY_2 B_DAY_2
|
||||
#define DAY_3 B_DAY_3
|
||||
#define DAY_4 B_DAY_4
|
||||
#define DAY_5 B_DAY_5
|
||||
#define DAY_6 B_DAY_6
|
||||
#define DAY_7 B_DAY_7
|
||||
|
||||
/* abbreviated week day names */
|
||||
#define ABDAY_1 B_AB_DAY_1
|
||||
#define ABDAY_2 B_AB_DAY_2
|
||||
#define ABDAY_3 B_AB_DAY_3
|
||||
#define ABDAY_4 B_AB_DAY_4
|
||||
#define ABDAY_5 B_AB_DAY_5
|
||||
#define ABDAY_6 B_AB_DAY_6
|
||||
#define ABDAY_7 B_AB_DAY_7
|
||||
|
||||
/* month names */
|
||||
#define MON_1 B_MON_1
|
||||
#define MON_2 B_MON_2
|
||||
#define MON_3 B_MON_3
|
||||
#define MON_4 B_MON_4
|
||||
#define MON_5 B_MON_5
|
||||
#define MON_6 B_MON_6
|
||||
#define MON_7 B_MON_7
|
||||
#define MON_8 B_MON_8
|
||||
#define MON_9 B_MON_9
|
||||
#define MON_10 B_MON_10
|
||||
#define MON_11 B_MON_11
|
||||
#define MON_12 B_MON_12
|
||||
|
||||
/* abbreviated month names */
|
||||
#define ABMON_1 B_AB_MON_1
|
||||
#define ABMON_2 B_AB_MON_2
|
||||
#define ABMON_3 B_AB_MON_3
|
||||
#define ABMON_4 B_AB_MON_4
|
||||
#define ABMON_5 B_AB_MON_5
|
||||
#define ABMON_6 B_AB_MON_6
|
||||
#define ABMON_7 B_AB_MON_7
|
||||
#define ABMON_8 B_AB_MON_8
|
||||
#define ABMON_9 B_AB_MON_9
|
||||
#define ABMON_10 B_AB_MON_10
|
||||
#define ABMON_11 B_AB_MON_11
|
||||
#define ABMON_12 B_AB_MON_12
|
||||
|
||||
#define ERA B_ERA /* era description segments */
|
||||
#define ERA_D_FMT B_ERA_DATE_FORMAT /* era date format string */
|
||||
#define ERA_D_T_FMT B_ERA_DATE_TIME_FORMAT /* era date and time format string */
|
||||
#define ERA_T_FMT B_TIME_FORMAT /* era time format string */
|
||||
#define ALT_DIGITS B_ALT_DIGITS /* alternative symbols for digits */
|
||||
|
||||
#define RADIXCHAR B_DECIMAL_POINT /* radix char */
|
||||
#define THOUSEP B_THOUSANDS_SEPARATOR /* separator for thousands */
|
||||
|
||||
#define YESEXPR B_YES_EXPRESSION /* affirmative response expression */
|
||||
#define NOEXPR B_NO_EXPRESSION /* negative response expression */
|
||||
#define YESSTR B_YES_STRING /* affirmative response for yes/no queries */
|
||||
#define NOSTR B_NO_STRING /* negative response for yes/no queries */
|
||||
|
||||
#define CRNCYSTR B_CURRENCY_SYMBOL /* currency symbol */
|
||||
|
||||
//#define D_MD_ORDER 57 /* month/day order (local extension) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
_IMPEXP_LOCALE char *nl_langinfo(nl_item);
|
||||
|
||||
#endif /* _LANGINFO_H_ */
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef _MONETARY_H_
|
||||
#define _MONETARY_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <LocaleBuild.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
_IMPEXP_LOCALE ssize_t strfmon(char *string, size_t maxSize, const char *format, ...);
|
||||
_IMPEXP_LOCALE ssize_t vstrfmon(char *string, size_t maxSize, const char *format, va_list args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MONETARY_H_ */
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
#ifndef PROPERTY_FILE_H
|
||||
#define PROPERTY_FILE_H
|
||||
|
||||
|
||||
#include <File.h>
|
||||
|
||||
|
||||
// This is the read-only version of the PropertyFile class - the
|
||||
// genprops tool contains the write-only version of it
|
||||
|
||||
|
||||
class PropertyFile : public BFile {
|
||||
public:
|
||||
status_t SetTo(const char *directory, const char *name);
|
||||
|
||||
off_t Size();
|
||||
};
|
||||
|
||||
#endif /* PROPERTY_FILE_H */
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
#ifndef _UNICODE_PROPERTIES_H_
|
||||
#define _UNICODE_PROPERTIES_H_
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <ByteOrder.h>
|
||||
|
||||
|
||||
#define PROPERTIES_DIRECTORY "locale"
|
||||
#define PROPERTIES_FILE_NAME "unicode.properties"
|
||||
#define PROPERTIES_FORMAT 'UPro'
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8 size;
|
||||
uint8 isBigEndian;
|
||||
uint32 format;
|
||||
uint8 version[3];
|
||||
} UnicodePropertiesHeader;
|
||||
|
||||
#endif /* _UNICODE_PROPERTIES_H_ */
|
||||
Reference in New Issue
Block a user