More cleanup in locale kit, this time regarding namespaces.
* it's bad practice to do a 'using <namespace>' in a header, as that is very likely to have unintended effects, so drop those from a couple of private Locale headers * adjust files all over the locale kit in order to fix the problems (by explicitly importing the required classes in the implementation files)
This commit is contained in:
@@ -22,7 +22,7 @@ namespace BPrivate {
|
|||||||
* but the value-type might change to add support for shortcuts and/or
|
* but the value-type might change to add support for shortcuts and/or
|
||||||
* graphical data (button-images and the like).
|
* graphical data (button-images and the like).
|
||||||
*/
|
*/
|
||||||
class DefaultCatalog : public BHashMapCatalog {
|
class DefaultCatalog : public HashMapCatalog {
|
||||||
public:
|
public:
|
||||||
DefaultCatalog(const entry_ref &catalogOwner, const char *language,
|
DefaultCatalog(const entry_ref &catalogOwner, const char *language,
|
||||||
uint32 fingerprint);
|
uint32 fingerprint);
|
||||||
@@ -35,7 +35,6 @@ class DefaultCatalog : public BHashMapCatalog {
|
|||||||
|
|
||||||
~DefaultCatalog();
|
~DefaultCatalog();
|
||||||
|
|
||||||
|
|
||||||
// implementation for editor-interface:
|
// implementation for editor-interface:
|
||||||
status_t ReadFromFile(const char *path = NULL);
|
status_t ReadFromFile(const char *path = NULL);
|
||||||
status_t ReadFromAttribute(const entry_ref &appOrAddOnRef);
|
status_t ReadFromAttribute(const entry_ref &appOrAddOnRef);
|
||||||
@@ -63,13 +62,14 @@ class DefaultCatalog : public BHashMapCatalog {
|
|||||||
mutable BString fPath;
|
mutable BString fPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern "C" status_t
|
extern "C" status_t
|
||||||
default_catalog_get_available_languages(BMessage* availableLanguages,
|
default_catalog_get_available_languages(BMessage* availableLanguages,
|
||||||
const char* sigPattern, const char* langPattern = NULL,
|
const char* sigPattern, const char* langPattern = NULL,
|
||||||
int32 fingerprint = 0);
|
int32 fingerprint = 0);
|
||||||
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
using namespace BPrivate;
|
|
||||||
|
|
||||||
#endif /* _DEFAULT_CATALOG_H_ */
|
#endif /* _DEFAULT_CATALOG_H_ */
|
||||||
|
|||||||
@@ -61,14 +61,14 @@ class CatKey {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BHashMapCatalog: public BCatalogAddOn {
|
class HashMapCatalog: public BCatalogAddOn {
|
||||||
protected:
|
protected:
|
||||||
uint32 ComputeFingerprint() const;
|
uint32 ComputeFingerprint() const;
|
||||||
typedef HashMap<CatKey, BString> CatMap;
|
typedef HashMap<CatKey, BString> CatMap;
|
||||||
CatMap fCatMap;
|
CatMap fCatMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BHashMapCatalog(const char* signature, const char* language,
|
HashMapCatalog(const char* signature, const char* language,
|
||||||
uint32 fingerprint);
|
uint32 fingerprint);
|
||||||
// Constructor for normal use
|
// Constructor for normal use
|
||||||
//
|
//
|
||||||
@@ -112,7 +112,7 @@ class BHashMapCatalog: public BCatalogAddOn {
|
|||||||
public:
|
public:
|
||||||
//CatWalker() {}; // if you use this there is no way to set fPos
|
//CatWalker() {}; // if you use this there is no way to set fPos
|
||||||
// properly.
|
// properly.
|
||||||
CatWalker(BHashMapCatalog* catalog);
|
CatWalker(HashMapCatalog* catalog);
|
||||||
bool AtEnd() const;
|
bool AtEnd() const;
|
||||||
const CatKey& GetKey() const;
|
const CatKey& GetKey() const;
|
||||||
const char *GetValue() const;
|
const char *GetValue() const;
|
||||||
@@ -129,7 +129,7 @@ class BHashMapCatalog: public BCatalogAddOn {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline BHashMapCatalog::BHashMapCatalog(const char* signature,
|
inline HashMapCatalog::HashMapCatalog(const char* signature,
|
||||||
const char* language, uint32 fingerprint)
|
const char* language, uint32 fingerprint)
|
||||||
:
|
:
|
||||||
BCatalogAddOn(signature, language, fingerprint)
|
BCatalogAddOn(signature, language, fingerprint)
|
||||||
@@ -138,7 +138,7 @@ inline BHashMapCatalog::BHashMapCatalog(const char* signature,
|
|||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
BHashMapCatalog::CatWalker::CatWalker(BHashMapCatalog* catalog)
|
HashMapCatalog::CatWalker::CatWalker(HashMapCatalog* catalog)
|
||||||
:
|
:
|
||||||
fPos(catalog->fCatMap.GetIterator())
|
fPos(catalog->fCatMap.GetIterator())
|
||||||
{
|
{
|
||||||
@@ -151,14 +151,14 @@ BHashMapCatalog::CatWalker::CatWalker(BHashMapCatalog* catalog)
|
|||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
BHashMapCatalog::CatWalker::AtEnd() const
|
HashMapCatalog::CatWalker::AtEnd() const
|
||||||
{
|
{
|
||||||
return atEnd;
|
return atEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const CatKey &
|
inline const CatKey &
|
||||||
BHashMapCatalog::CatWalker::GetKey() const
|
HashMapCatalog::CatWalker::GetKey() const
|
||||||
{
|
{
|
||||||
assert(!atEnd);
|
assert(!atEnd);
|
||||||
return current.key;
|
return current.key;
|
||||||
@@ -166,7 +166,7 @@ BHashMapCatalog::CatWalker::GetKey() const
|
|||||||
|
|
||||||
|
|
||||||
inline const char *
|
inline const char *
|
||||||
BHashMapCatalog::CatWalker::GetValue() const
|
HashMapCatalog::CatWalker::GetValue() const
|
||||||
{
|
{
|
||||||
assert(!atEnd);
|
assert(!atEnd);
|
||||||
return current.value.String();
|
return current.value.String();
|
||||||
@@ -174,7 +174,7 @@ BHashMapCatalog::CatWalker::GetValue() const
|
|||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
BHashMapCatalog::CatWalker::Next()
|
HashMapCatalog::CatWalker::Next()
|
||||||
{
|
{
|
||||||
if (fPos.HasNext()) {
|
if (fPos.HasNext()) {
|
||||||
current = fPos.Next();
|
current = fPos.Next();
|
||||||
@@ -185,7 +185,7 @@ BHashMapCatalog::CatWalker::Next()
|
|||||||
|
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
BHashMapCatalog::GetWalker(CatWalker *walker)
|
HashMapCatalog::GetWalker(CatWalker *walker)
|
||||||
{
|
{
|
||||||
if (!walker)
|
if (!walker)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ class BFile;
|
|||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
class PlainTextCatalog : public BHashMapCatalog {
|
|
||||||
|
class PlainTextCatalog : public HashMapCatalog {
|
||||||
public:
|
public:
|
||||||
PlainTextCatalog(const char *signature, const char *language,
|
PlainTextCatalog(const char *signature, const char *language,
|
||||||
uint32 fingerprint);
|
uint32 fingerprint);
|
||||||
@@ -28,7 +29,6 @@ class PlainTextCatalog : public BHashMapCatalog {
|
|||||||
|
|
||||||
~PlainTextCatalog();
|
~PlainTextCatalog();
|
||||||
|
|
||||||
|
|
||||||
// implementation for editor-interface:
|
// implementation for editor-interface:
|
||||||
status_t ReadFromFile(const char *path = NULL);
|
status_t ReadFromFile(const char *path = NULL);
|
||||||
status_t WriteToFile(const char *path = NULL);
|
status_t WriteToFile(const char *path = NULL);
|
||||||
@@ -45,9 +45,8 @@ class PlainTextCatalog : public BHashMapCatalog {
|
|||||||
mutable BString fPath;
|
mutable BString fPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace BPrivate
|
|
||||||
|
|
||||||
using BPrivate::PlainTextCatalog;
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
#endif /* _PLAINTEXT_CATALOG_H_ */
|
#endif /* _PLAINTEXT_CATALOG_H_ */
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::HashMapCatalog;
|
||||||
|
using BPrivate::PlainTextCatalog;
|
||||||
using std::auto_ptr;
|
using std::auto_ptr;
|
||||||
using std::min;
|
using std::min;
|
||||||
using std::max;
|
using std::max;
|
||||||
@@ -77,7 +79,7 @@ escapeQuotedChars(BString& stringToEscape)
|
|||||||
PlainTextCatalog::PlainTextCatalog(const char *signature, const char *language,
|
PlainTextCatalog::PlainTextCatalog(const char *signature, const char *language,
|
||||||
uint32 fingerprint)
|
uint32 fingerprint)
|
||||||
:
|
:
|
||||||
BHashMapCatalog(signature, language, fingerprint)
|
HashMapCatalog(signature, language, fingerprint)
|
||||||
{
|
{
|
||||||
// give highest priority to catalog living in sub-folder of app's folder:
|
// give highest priority to catalog living in sub-folder of app's folder:
|
||||||
app_info appInfo;
|
app_info appInfo;
|
||||||
@@ -137,7 +139,7 @@ PlainTextCatalog::PlainTextCatalog(const char *signature, const char *language,
|
|||||||
PlainTextCatalog::PlainTextCatalog(const char *path, const char *signature,
|
PlainTextCatalog::PlainTextCatalog(const char *path, const char *signature,
|
||||||
const char *language)
|
const char *language)
|
||||||
:
|
:
|
||||||
BHashMapCatalog(signature, language, 0),
|
HashMapCatalog(signature, language, 0),
|
||||||
fPath(path)
|
fPath(path)
|
||||||
{
|
{
|
||||||
fInitCheck = B_OK;
|
fInitCheck = B_OK;
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
#include <DefaultCatalog.h>
|
#include <DefaultCatalog.h>
|
||||||
#include <EditableCatalog.h>
|
#include <EditableCatalog.h>
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::CatKey;
|
||||||
|
using BPrivate::DefaultCatalog;
|
||||||
using BPrivate::EditableCatalog;
|
using BPrivate::EditableCatalog;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,12 @@
|
|||||||
#include <EditableCatalog.h>
|
#include <EditableCatalog.h>
|
||||||
#include <DefaultCatalog.h>
|
#include <DefaultCatalog.h>
|
||||||
#include <HashMapCatalog.h>
|
#include <HashMapCatalog.h>
|
||||||
#include <PlainTextCatalog.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::CatKey;
|
||||||
|
using BPrivate::DefaultCatalog;
|
||||||
using BPrivate::EditableCatalog;
|
using BPrivate::EditableCatalog;
|
||||||
|
using BPrivate::HashMapCatalog;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
|
||||||
@@ -112,8 +115,8 @@ main(int argc, char **argv)
|
|||||||
inputFiles[i], strerror(res));
|
inputFiles[i], strerror(res));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
BHashMapCatalog* inputCatImpl
|
HashMapCatalog* inputCatImpl
|
||||||
= dynamic_cast<BHashMapCatalog*>(inputCatalog.CatalogAddOn());
|
= dynamic_cast<HashMapCatalog*>(inputCatalog.CatalogAddOn());
|
||||||
if (!inputCatImpl) {
|
if (!inputCatImpl) {
|
||||||
fprintf(stderr, "couldn't access impl of input-catalog %s\n",
|
fprintf(stderr, "couldn't access impl of input-catalog %s\n",
|
||||||
inputFiles[i]);
|
inputFiles[i]);
|
||||||
@@ -122,7 +125,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
// now walk over all entries in input-catalog and add them to
|
// now walk over all entries in input-catalog and add them to
|
||||||
// target catalog, unless they already exist there.
|
// target catalog, unless they already exist there.
|
||||||
BHashMapCatalog::CatWalker walker(inputCatImpl);
|
HashMapCatalog::CatWalker walker(inputCatImpl);
|
||||||
while (!walker.AtEnd()) {
|
while (!walker.AtEnd()) {
|
||||||
const CatKey &plainTextKey(walker.GetKey());
|
const CatKey &plainTextKey(walker.GetKey());
|
||||||
BString keyString, keyComment, keyContext;
|
BString keyString, keyComment, keyContext;
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ using std::pair;
|
|||||||
static const char *kCatFolder = "catalogs";
|
static const char *kCatFolder = "catalogs";
|
||||||
static const char *kCatExtension = ".catalog";
|
static const char *kCatExtension = ".catalog";
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
const char *DefaultCatalog::kCatMimeType
|
const char *DefaultCatalog::kCatMimeType
|
||||||
= "locale/x-vnd.Be.locale-catalog.default";
|
= "locale/x-vnd.Be.locale-catalog.default";
|
||||||
|
|
||||||
@@ -64,7 +68,7 @@ const uint8 DefaultCatalog::kDefaultCatalogAddOnPriority = 1;
|
|||||||
DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner, const char *language,
|
DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner, const char *language,
|
||||||
uint32 fingerprint)
|
uint32 fingerprint)
|
||||||
:
|
:
|
||||||
BHashMapCatalog("", language, fingerprint)
|
HashMapCatalog("", language, fingerprint)
|
||||||
{
|
{
|
||||||
// We created the catalog with an invalid signature, but we fix that now.
|
// We created the catalog with an invalid signature, but we fix that now.
|
||||||
SetSignature(catalogOwner);
|
SetSignature(catalogOwner);
|
||||||
@@ -127,7 +131,7 @@ DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner, const char *langua
|
|||||||
*/
|
*/
|
||||||
DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
|
DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
|
||||||
:
|
:
|
||||||
BHashMapCatalog("", "", 0)
|
HashMapCatalog("", "", 0)
|
||||||
{
|
{
|
||||||
fInitCheck = ReadFromResource(*appOrAddOnRef);
|
fInitCheck = ReadFromResource(*appOrAddOnRef);
|
||||||
log_team(LOG_DEBUG,
|
log_team(LOG_DEBUG,
|
||||||
@@ -143,7 +147,7 @@ DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
|
|||||||
DefaultCatalog::DefaultCatalog(const char *path, const char *signature,
|
DefaultCatalog::DefaultCatalog(const char *path, const char *signature,
|
||||||
const char *language)
|
const char *language)
|
||||||
:
|
:
|
||||||
BHashMapCatalog(signature, language, 0),
|
HashMapCatalog(signature, language, 0),
|
||||||
fPath(path)
|
fPath(path)
|
||||||
{
|
{
|
||||||
fInitCheck = B_OK;
|
fInitCheck = B_OK;
|
||||||
@@ -615,10 +619,13 @@ DefaultCatalog::Create(const char *signature, const char *language)
|
|||||||
return catalog;
|
return catalog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
extern "C" status_t
|
extern "C" status_t
|
||||||
default_catalog_get_available_languages(BMessage* availableLanguages,
|
default_catalog_get_available_languages(BMessage* availableLanguages,
|
||||||
const char* sigPattern, const char* langPattern = NULL,
|
const char* sigPattern, const char* langPattern, int32 fingerprint)
|
||||||
int32 fingerprint = 0)
|
|
||||||
{
|
{
|
||||||
if (availableLanguages == NULL || sigPattern == NULL)
|
if (availableLanguages == NULL || sigPattern == NULL)
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
|
|||||||
@@ -102,25 +102,25 @@ CatKey::HashFun(const char* s, int startValue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// BHashMapCatalog
|
// HashMapCatalog
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BHashMapCatalog::MakeEmpty()
|
HashMapCatalog::MakeEmpty()
|
||||||
{
|
{
|
||||||
fCatMap.Clear();
|
fCatMap.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
BHashMapCatalog::CountItems() const
|
HashMapCatalog::CountItems() const
|
||||||
{
|
{
|
||||||
return fCatMap.Size();
|
return fCatMap.Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
BHashMapCatalog::GetString(const char *string, const char *context,
|
HashMapCatalog::GetString(const char *string, const char *context,
|
||||||
const char *comment)
|
const char *comment)
|
||||||
{
|
{
|
||||||
CatKey key(string, context, comment);
|
CatKey key(string, context, comment);
|
||||||
@@ -129,7 +129,7 @@ BHashMapCatalog::GetString(const char *string, const char *context,
|
|||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
BHashMapCatalog::GetString(uint32 id)
|
HashMapCatalog::GetString(uint32 id)
|
||||||
{
|
{
|
||||||
CatKey key(id);
|
CatKey key(id);
|
||||||
return GetString(key);
|
return GetString(key);
|
||||||
@@ -137,7 +137,7 @@ BHashMapCatalog::GetString(uint32 id)
|
|||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
BHashMapCatalog::GetString(const CatKey& key)
|
HashMapCatalog::GetString(const CatKey& key)
|
||||||
{
|
{
|
||||||
BString value = fCatMap.Get(key);
|
BString value = fCatMap.Get(key);
|
||||||
if (value.Length() == 0)
|
if (value.Length() == 0)
|
||||||
@@ -202,7 +202,7 @@ parseQuotedChars(BString& stringToParse)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BHashMapCatalog::SetString(const char *string, const char *translated,
|
HashMapCatalog::SetString(const char *string, const char *translated,
|
||||||
const char *context, const char *comment)
|
const char *context, const char *comment)
|
||||||
{
|
{
|
||||||
BString stringCopy(string);
|
BString stringCopy(string);
|
||||||
@@ -225,7 +225,7 @@ BHashMapCatalog::SetString(const char *string, const char *translated,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BHashMapCatalog::SetString(int32 id, const char *translated)
|
HashMapCatalog::SetString(int32 id, const char *translated)
|
||||||
{
|
{
|
||||||
BString translatedCopy(translated);
|
BString translatedCopy(translated);
|
||||||
status_t result = parseQuotedChars(translatedCopy);
|
status_t result = parseQuotedChars(translatedCopy);
|
||||||
@@ -238,7 +238,7 @@ BHashMapCatalog::SetString(int32 id, const char *translated)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BHashMapCatalog::SetString(const CatKey& key, const char *translated)
|
HashMapCatalog::SetString(const CatKey& key, const char *translated)
|
||||||
{
|
{
|
||||||
BString translatedCopy(translated);
|
BString translatedCopy(translated);
|
||||||
status_t result = parseQuotedChars(translatedCopy);
|
status_t result = parseQuotedChars(translatedCopy);
|
||||||
@@ -258,7 +258,7 @@ BHashMapCatalog::SetString(const CatKey& key, const char *translated)
|
|||||||
* wrong order, and this does happen, as an hash map is an unsorted container.
|
* wrong order, and this does happen, as an hash map is an unsorted container.
|
||||||
*/
|
*/
|
||||||
uint32
|
uint32
|
||||||
BHashMapCatalog::ComputeFingerprint() const
|
HashMapCatalog::ComputeFingerprint() const
|
||||||
{
|
{
|
||||||
uint32 checksum = 0;
|
uint32 checksum = 0;
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ BHashMapCatalog::ComputeFingerprint() const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BHashMapCatalog::UpdateFingerprint()
|
HashMapCatalog::UpdateFingerprint()
|
||||||
{
|
{
|
||||||
fFingerprint = ComputeFingerprint();
|
fFingerprint = ComputeFingerprint();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ BCatalog gSystemCatalog;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::DefaultCatalog;
|
||||||
|
using BPrivate::MutableLocaleRoster;
|
||||||
|
using BPrivate::gSystemCatalog;
|
||||||
|
|
||||||
|
|
||||||
// helper function that makes sure an attribute-index exists:
|
// helper function that makes sure an attribute-index exists:
|
||||||
static void EnsureIndexExists(const char *attrName)
|
static void EnsureIndexExists(const char *attrName)
|
||||||
{
|
{
|
||||||
@@ -129,6 +134,5 @@ __initialize_locale_kit()
|
|||||||
{
|
{
|
||||||
SetupCatalogBasics();
|
SetupCatalogBasics();
|
||||||
|
|
||||||
MutableLocaleRoster::Default()->LoadSystemCatalog(
|
MutableLocaleRoster::Default()->LoadSystemCatalog(&gSystemCatalog);
|
||||||
&BPrivate::gSystemCatalog);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,8 @@
|
|||||||
|
|
||||||
|
|
||||||
using BPrivate::CatalogAddOnInfo;
|
using BPrivate::CatalogAddOnInfo;
|
||||||
|
using BPrivate::MutableLocaleRoster;
|
||||||
|
using BPrivate::RosterData;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::DefaultCatalog;
|
||||||
using std::auto_ptr;
|
using std::auto_ptr;
|
||||||
|
|
||||||
|
|
||||||
@@ -40,6 +41,9 @@ using std::auto_ptr;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
// several attributes/resource-IDs used within the Locale Kit:
|
// several attributes/resource-IDs used within the Locale Kit:
|
||||||
|
|
||||||
const char *kCatLangAttr = "BEOS:LOCALE_LANGUAGE";
|
const char *kCatLangAttr = "BEOS:LOCALE_LANGUAGE";
|
||||||
@@ -64,7 +68,7 @@ static int16 kCatArchiveVersion = 1;
|
|||||||
DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner,
|
DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner,
|
||||||
const char *language, uint32 fingerprint)
|
const char *language, uint32 fingerprint)
|
||||||
:
|
:
|
||||||
BHashMapCatalog("", language, fingerprint)
|
HashMapCatalog("", language, fingerprint)
|
||||||
{
|
{
|
||||||
fInitCheck = B_NOT_SUPPORTED;
|
fInitCheck = B_NOT_SUPPORTED;
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -80,7 +84,7 @@ DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner,
|
|||||||
*/
|
*/
|
||||||
DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
|
DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
|
||||||
:
|
:
|
||||||
BHashMapCatalog("", "", 0)
|
HashMapCatalog("", "", 0)
|
||||||
{
|
{
|
||||||
fInitCheck = ReadFromResource(*appOrAddOnRef);
|
fInitCheck = ReadFromResource(*appOrAddOnRef);
|
||||||
// fprintf(stderr,
|
// fprintf(stderr,
|
||||||
@@ -96,7 +100,7 @@ DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
|
|||||||
DefaultCatalog::DefaultCatalog(const char *path, const char *signature,
|
DefaultCatalog::DefaultCatalog(const char *path, const char *signature,
|
||||||
const char *language)
|
const char *language)
|
||||||
:
|
:
|
||||||
BHashMapCatalog(signature, language, 0),
|
HashMapCatalog(signature, language, 0),
|
||||||
fPath(path)
|
fPath(path)
|
||||||
{
|
{
|
||||||
fInitCheck = B_OK;
|
fInitCheck = B_OK;
|
||||||
@@ -426,3 +430,6 @@ DefaultCatalog::Create(const char *signature, const char *language)
|
|||||||
|
|
||||||
const uint8 DefaultCatalog::kDefaultCatalogAddOnPriority = 1;
|
const uint8 DefaultCatalog::kDefaultCatalogAddOnPriority = 1;
|
||||||
// give highest priority to our embedded catalog-add-on
|
// give highest priority to our embedded catalog-add-on
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BPrivate
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::PlainTextCatalog;
|
||||||
using std::auto_ptr;
|
using std::auto_ptr;
|
||||||
using std::min;
|
using std::min;
|
||||||
using std::max;
|
using std::max;
|
||||||
@@ -44,6 +45,9 @@ using std::pair;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
const char *PlainTextCatalog::kCatMimeType
|
const char *PlainTextCatalog::kCatMimeType
|
||||||
= "locale/x-vnd.Be.locale-catalog.plaintext";
|
= "locale/x-vnd.Be.locale-catalog.plaintext";
|
||||||
|
|
||||||
@@ -73,7 +77,7 @@ escapeQuotedChars(BString& stringToEscape)
|
|||||||
PlainTextCatalog::PlainTextCatalog(const char *signature, const char *language,
|
PlainTextCatalog::PlainTextCatalog(const char *signature, const char *language,
|
||||||
uint32 fingerprint)
|
uint32 fingerprint)
|
||||||
:
|
:
|
||||||
BHashMapCatalog(signature, language, fingerprint)
|
HashMapCatalog(signature, language, fingerprint)
|
||||||
{
|
{
|
||||||
// Look for the catalog in the directory we are going to use
|
// Look for the catalog in the directory we are going to use
|
||||||
// This constructor is not used so lets disable that...
|
// This constructor is not used so lets disable that...
|
||||||
@@ -93,7 +97,7 @@ PlainTextCatalog::PlainTextCatalog(const char *signature, const char *language,
|
|||||||
PlainTextCatalog::PlainTextCatalog(const char *path, const char *signature,
|
PlainTextCatalog::PlainTextCatalog(const char *path, const char *signature,
|
||||||
const char *language)
|
const char *language)
|
||||||
:
|
:
|
||||||
BHashMapCatalog(signature, language, 0),
|
HashMapCatalog(signature, language, 0),
|
||||||
fPath(path)
|
fPath(path)
|
||||||
{
|
{
|
||||||
fInitCheck = B_OK;
|
fInitCheck = B_OK;
|
||||||
@@ -339,6 +343,9 @@ PlainTextCatalog::Instantiate(const char *signature, const char *language,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
extern "C" BCatalogAddOn *
|
extern "C" BCatalogAddOn *
|
||||||
instantiate_catalog(const char *signature, const char *language,
|
instantiate_catalog(const char *signature, const char *language,
|
||||||
uint32 fingerprint)
|
uint32 fingerprint)
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::PlainTextCatalog;
|
||||||
|
|
||||||
|
|
||||||
bool showKeys = false;
|
bool showKeys = false;
|
||||||
bool showSummary = false;
|
bool showSummary = false;
|
||||||
bool showWarnings = false;
|
bool showWarnings = false;
|
||||||
|
|||||||
@@ -16,8 +16,13 @@
|
|||||||
#include <HashMapCatalog.h>
|
#include <HashMapCatalog.h>
|
||||||
#include <PlainTextCatalog.h>
|
#include <PlainTextCatalog.h>
|
||||||
|
|
||||||
|
using BPrivate::CatKey;
|
||||||
|
using BPrivate::DefaultCatalog;
|
||||||
|
using BPrivate::HashMapCatalog;
|
||||||
|
using BPrivate::PlainTextCatalog;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
@@ -108,7 +113,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
// now walk over all entries in input-catalog and add them to
|
// now walk over all entries in input-catalog and add them to
|
||||||
// target catalog, unless they already exist there.
|
// target catalog, unless they already exist there.
|
||||||
BHashMapCatalog::CatWalker walker(&inputCatalog);
|
HashMapCatalog::CatWalker walker(&inputCatalog);
|
||||||
while (!walker.AtEnd()) {
|
while (!walker.AtEnd()) {
|
||||||
const CatKey &key(walker.GetKey());
|
const CatKey &key(walker.GetKey());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user