Extract EditableCatalog from Catalog.{h,cpp}.

* move EditableCatalog to its own header and implementation file
* move problematic BCatalog::CatalogAddOn() to EditableCatalog
* adjust Locale tools accordingly
This commit is contained in:
Oliver Tappe
2012-04-16 00:04:40 +02:00
parent 1cd97d5e86
commit 16e5092306
9 changed files with 233 additions and 208 deletions
-57
View File
@@ -50,10 +50,6 @@ public:
status_t InitCheck() const;
int32 CountItems() const;
// TODO: drop this, as the lifetime of the returned object
// is indeterminate
BCatalogAddOn* CatalogAddOn();
protected:
BCatalog(const BCatalog&);
const BCatalog& operator= (const BCatalog&);
@@ -378,13 +374,6 @@ BCatalog::GetNoAutoCollectString(uint32 id)
}
inline BCatalogAddOn*
BCatalog::CatalogAddOn()
{
return fCatalog;
}
/*
* BCatalogAddOn - inlines for trivial accessors:
*/
@@ -409,50 +398,4 @@ BCatalogAddOn::MarkForTranslation(int32 id)
}
// TODO: does not belong here, either
namespace BPrivate {
class EditableCatalog : public BCatalog {
public:
EditableCatalog(const char* type,
const char* signature,
const char* language);
virtual ~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(
const entry_ref& appOrAddOnRef);
status_t ReadFromResource(
const entry_ref& appOrAddOnRef);
status_t WriteToFile(const char* path = NULL);
status_t WriteToAttribute(
const entry_ref& appOrAddOnRef);
status_t WriteToResource(
const entry_ref& appOrAddOnRef);
void MakeEmpty();
private:
EditableCatalog();
EditableCatalog(const EditableCatalog& other);
const EditableCatalog& operator=(const EditableCatalog& other);
// hide assignment, default-, and
// copy-constructor
};
} // namespace BPrivate
#endif /* _CATALOG_H_ */
+63
View File
@@ -0,0 +1,63 @@
/*
* Copyright 2003-2012, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _EDITABLE_CATALOG_H_
#define _EDITABLE_CATALOG_H_
#include <Catalog.h>
class BMessage;
struct entry_ref;
namespace BPrivate {
class EditableCatalog : public BCatalog {
public:
EditableCatalog(const char* type,
const char* signature,
const char* language);
virtual ~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(
const entry_ref& appOrAddOnRef);
status_t ReadFromResource(
const entry_ref& appOrAddOnRef);
status_t WriteToFile(const char* path = NULL);
status_t WriteToAttribute(
const entry_ref& appOrAddOnRef);
status_t WriteToResource(
const entry_ref& appOrAddOnRef);
void MakeEmpty();
BCatalogAddOn* CatalogAddOn();
private:
EditableCatalog();
EditableCatalog(const EditableCatalog& other);
const EditableCatalog& operator=(const EditableCatalog& other);
// hide assignment, default-, and
// copy-constructor
};
} // namespace BPrivate
#endif /* _EDITABLE_CATALOG_H_ */
-6
View File
@@ -60,10 +60,6 @@ class CatKey {
uint32 GetHashCode() const { return fHashVal; }
};
} // namespace BPrivate
namespace BPrivate {
class BHashMapCatalog: public BCatalogAddOn {
protected:
@@ -200,6 +196,4 @@ BHashMapCatalog::GetWalker(CatWalker *walker)
} // namespace BPrivate
using namespace BPrivate;
#endif // _HASH_MAP_CATALOG_H_