Remove more unneeded files from the Locale Kit
All of this is replaced by the single BNumberFormat class.
This commit is contained in:
@@ -6,15 +6,11 @@
|
|||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <Collator.h>
|
#include <Collator.h>
|
||||||
#include <Country.h>
|
#include <Country.h>
|
||||||
#include <Currency.h>
|
|
||||||
#include <Format.h>
|
#include <Format.h>
|
||||||
#include <FormatImpl.h>
|
#include <FormatImpl.h>
|
||||||
#include <FormatParameters.h>
|
#include <FormatParameters.h>
|
||||||
#include <FormattingConventions.h>
|
#include <FormattingConventions.h>
|
||||||
#include <GenericNumberFormat.h>
|
#include <GenericNumberFormat.h>
|
||||||
#include <IntegerFormat.h>
|
|
||||||
#include <IntegerFormatImpl.h>
|
|
||||||
#include <IntegerFormatParameters.h>
|
|
||||||
#include <Language.h>
|
#include <Language.h>
|
||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
#include <NumberFormat.h>
|
#include <NumberFormat.h>
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
#ifndef _B_CURRENCY_H_
|
|
||||||
#define _B_CURRENCY_H_
|
|
||||||
|
|
||||||
#include <Archivable.h>
|
|
||||||
#include <Message.h>
|
|
||||||
#include <String.h>
|
|
||||||
|
|
||||||
class BLocale;
|
|
||||||
|
|
||||||
class 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_
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
#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 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
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _B_INTEGER_FORMAT_H_
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#ifndef _B_INTEGER_FORMAT_IMPL_H_
|
|
||||||
#define _B_INTEGER_FORMAT_IMPL_H_
|
|
||||||
|
|
||||||
struct format_field_position;
|
|
||||||
class BIntegerFormatParameters;
|
|
||||||
class BString;
|
|
||||||
|
|
||||||
class BIntegerFormatImpl {
|
|
||||||
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_
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#ifndef _B_INTEGER_FORMAT_PARAMETERS_H_
|
|
||||||
#define _B_INTEGER_FORMAT_PARAMETERS_H_
|
|
||||||
|
|
||||||
#include <NumberFormatParameters.h>
|
|
||||||
|
|
||||||
class 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_
|
|
||||||
@@ -1,192 +0,0 @@
|
|||||||
#include <Currency.h>
|
|
||||||
|
|
||||||
// message archive field names
|
|
||||||
static const char *kArchivedCurrencyCodeName = "be:currency code";
|
|
||||||
static const char *kArchivedDefaultSymbol = "be:default symbol";
|
|
||||||
static const char *kArchivedDefaultFractionDigits
|
|
||||||
= "be:default fraction digits";
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
BCurrency::BCurrency(const BCurrency &other)
|
|
||||||
: fCurrencyCode(),
|
|
||||||
fDefaultSymbol(),
|
|
||||||
fDefaultFractionDigits(B_NO_INIT)
|
|
||||||
{
|
|
||||||
*this = other;
|
|
||||||
}
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
BCurrency::BCurrency(BMessage *archive)
|
|
||||||
: fCurrencyCode(),
|
|
||||||
fDefaultSymbol(),
|
|
||||||
fDefaultFractionDigits(B_NO_INIT)
|
|
||||||
{
|
|
||||||
if (archive->FindString(kArchivedCurrencyCodeName, &fCurrencyCode)
|
|
||||||
== B_OK
|
|
||||||
&& archive->FindString(kArchivedDefaultSymbol, &fDefaultSymbol)
|
|
||||||
== B_OK
|
|
||||||
&& archive->FindInt32(kArchivedDefaultFractionDigits,
|
|
||||||
&fDefaultFractionDigits) == B_OK
|
|
||||||
&& _CheckData()) {
|
|
||||||
// everything went fine
|
|
||||||
} else
|
|
||||||
_Unset(B_NO_INIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
BCurrency::BCurrency(const char *currencyCode)
|
|
||||||
{
|
|
||||||
// TODO: load currency from disk
|
|
||||||
}
|
|
||||||
|
|
||||||
// destructor
|
|
||||||
BCurrency::~BCurrency()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitCheck
|
|
||||||
status_t
|
|
||||||
BCurrency::InitCheck() const
|
|
||||||
{
|
|
||||||
return (fDefaultFractionDigits < 0 ? fDefaultFractionDigits : B_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Archive
|
|
||||||
status_t
|
|
||||||
BCurrency::Archive(BMessage *archive, bool deep) const
|
|
||||||
{
|
|
||||||
status_t error = BArchivable::Archive(archive, deep);
|
|
||||||
if (error == B_OK) {
|
|
||||||
if (archive->AddString(kArchivedCurrencyCodeName, fCurrencyCode)
|
|
||||||
== B_OK
|
|
||||||
&& archive->AddString(kArchivedDefaultSymbol, fDefaultSymbol)
|
|
||||||
== B_OK
|
|
||||||
&& archive->AddInt32(kArchivedDefaultFractionDigits,
|
|
||||||
fDefaultFractionDigits) == B_OK) {
|
|
||||||
// everything went fine
|
|
||||||
} else
|
|
||||||
error = B_ERROR;
|
|
||||||
}
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Instantiate
|
|
||||||
_EXPORT
|
|
||||||
BArchivable *
|
|
||||||
BCurrency::Instantiate(BMessage *archive)
|
|
||||||
{
|
|
||||||
if (!validate_instantiation(archive, "BCurrency"))
|
|
||||||
return NULL;
|
|
||||||
return new BCurrency(archive);
|
|
||||||
}
|
|
||||||
|
|
||||||
// CurrencyCode
|
|
||||||
const char *
|
|
||||||
BCurrency::CurrencyCode() const
|
|
||||||
{
|
|
||||||
return (InitCheck() == B_OK ? fCurrencyCode.String() : NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
// DefaultSymbol
|
|
||||||
const char *
|
|
||||||
BCurrency::DefaultSymbol() const
|
|
||||||
{
|
|
||||||
return (InitCheck() == B_OK ? fDefaultSymbol.String() : NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
// DefaultFractionDigits
|
|
||||||
int32
|
|
||||||
BCurrency::DefaultFractionDigits() const
|
|
||||||
{
|
|
||||||
return (InitCheck() == B_OK ? fDefaultFractionDigits : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetSymbol
|
|
||||||
status_t
|
|
||||||
BCurrency::GetSymbol(char *symbol, size_t maxSize, BLocale *locale)
|
|
||||||
{
|
|
||||||
// check initialization and parameters
|
|
||||||
if (InitCheck() != B_OK)
|
|
||||||
return B_NO_INIT;
|
|
||||||
if (symbol == NULL)
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
// TODO: get symbol from locale
|
|
||||||
// fall back to the default symbol
|
|
||||||
if ((int32)maxSize <= fDefaultSymbol.Length())
|
|
||||||
return EOVERFLOW; // OpenBeOS: B_BUFFER_OVERFLOW
|
|
||||||
strcpy(symbol, fDefaultSymbol.String());
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetSymbol
|
|
||||||
status_t
|
|
||||||
BCurrency::GetSymbol(BString *symbol, BLocale *locale)
|
|
||||||
{
|
|
||||||
// check initialization and parameters
|
|
||||||
if (InitCheck() != B_OK)
|
|
||||||
return B_NO_INIT;
|
|
||||||
if (symbol == NULL)
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
// TODO: get symbol from locale
|
|
||||||
// fall back to the default symbol
|
|
||||||
*symbol = fDefaultSymbol;
|
|
||||||
if (symbol->Length() != fDefaultSymbol.Length())
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// =
|
|
||||||
BCurrency &
|
|
||||||
BCurrency::operator=(const BCurrency &other)
|
|
||||||
{
|
|
||||||
if (other.InitCheck() == B_OK) {
|
|
||||||
fCurrencyCode = other.fCurrencyCode;
|
|
||||||
fDefaultSymbol = other.fDefaultSymbol;
|
|
||||||
fDefaultFractionDigits = other.fDefaultFractionDigits;
|
|
||||||
if (!_CheckData())
|
|
||||||
_Unset(B_NO_MEMORY);
|
|
||||||
} else
|
|
||||||
_Unset(B_NO_MEMORY);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==
|
|
||||||
bool
|
|
||||||
BCurrency::operator==(const BCurrency &other) const
|
|
||||||
{
|
|
||||||
if (InitCheck() != B_OK || other.InitCheck() != B_OK)
|
|
||||||
return false;
|
|
||||||
return (fCurrencyCode == other.fCurrencyCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
// !=
|
|
||||||
bool
|
|
||||||
BCurrency::operator!=(const BCurrency &other) const
|
|
||||||
{
|
|
||||||
return !(*this == other);
|
|
||||||
}
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
BCurrency::BCurrency()
|
|
||||||
{
|
|
||||||
// privatized to make it unaccessible
|
|
||||||
}
|
|
||||||
|
|
||||||
// _CheckData
|
|
||||||
bool
|
|
||||||
BCurrency::_CheckData() const
|
|
||||||
{
|
|
||||||
return (fDefaultFractionDigits >= 0
|
|
||||||
&& fCurrencyCode.Length() > 0
|
|
||||||
&& fDefaultSymbol.Length() == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// _Unset
|
|
||||||
void
|
|
||||||
BCurrency::_Unset(status_t error)
|
|
||||||
{
|
|
||||||
fCurrencyCode.Truncate(0);
|
|
||||||
fDefaultSymbol.Truncate(0);
|
|
||||||
fDefaultFractionDigits = error;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
#include <IntegerFormat.h>
|
|
||||||
#include <IntegerFormatImpl.h>
|
|
||||||
|
|
||||||
// copy constructor
|
|
||||||
BIntegerFormat::BIntegerFormat(const BIntegerFormat &other)
|
|
||||||
: BNumberFormat(other),
|
|
||||||
BIntegerFormatParameters(other)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// destructor
|
|
||||||
BIntegerFormat::~BIntegerFormat()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format
|
|
||||||
status_t
|
|
||||||
BIntegerFormat::Format(int64 number, BString *buffer) const
|
|
||||||
{
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format
|
|
||||||
status_t
|
|
||||||
BIntegerFormat::Format(int64 number, BString *buffer,
|
|
||||||
format_field_position *positions, int32 positionCount,
|
|
||||||
int32 *fieldCount, bool allFieldPositions) const
|
|
||||||
{
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// =
|
|
||||||
BIntegerFormat &
|
|
||||||
BIntegerFormat::operator=(const BIntegerFormat &other)
|
|
||||||
{
|
|
||||||
BNumberFormat::operator=(other);
|
|
||||||
BIntegerFormatParameters::operator=(other);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
BIntegerFormat::BIntegerFormat(BIntegerFormatImpl *impl)
|
|
||||||
: BNumberFormat(),
|
|
||||||
BIntegerFormatParameters(impl ? impl->DefaultIntegerFormatParameters()
|
|
||||||
: NULL)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#include <IntegerFormatImpl.h>
|
|
||||||
#include <IntegerFormatParameters.h>
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
BIntegerFormatImpl::BIntegerFormatImpl()
|
|
||||||
: BNumberFormatImpl()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// destructor
|
|
||||||
BIntegerFormatImpl::~BIntegerFormatImpl()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// DefaultNumberFormatParameters
|
|
||||||
BNumberFormatParameters *
|
|
||||||
BIntegerFormatImpl::DefaultNumberFormatParameters()
|
|
||||||
{
|
|
||||||
return DefaultIntegerFormatParameters();
|
|
||||||
}
|
|
||||||
|
|
||||||
// DefaultNumberFormatParameters
|
|
||||||
const BNumberFormatParameters *
|
|
||||||
BIntegerFormatImpl::DefaultNumberFormatParameters() const
|
|
||||||
{
|
|
||||||
return DefaultIntegerFormatParameters();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
#include <IntegerFormatParameters.h>
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
BIntegerFormatParameters::BIntegerFormatParameters(
|
|
||||||
const BIntegerFormatParameters *parent)
|
|
||||||
: BNumberFormatParameters(parent),
|
|
||||||
fParent(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy constructor
|
|
||||||
BIntegerFormatParameters::BIntegerFormatParameters(
|
|
||||||
const BIntegerFormatParameters &other)
|
|
||||||
: BNumberFormatParameters(other),
|
|
||||||
fParent(other.fParent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// destructor
|
|
||||||
BIntegerFormatParameters::~BIntegerFormatParameters()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetParentIntegerParameters
|
|
||||||
void
|
|
||||||
BIntegerFormatParameters::SetParentIntegerParameters(
|
|
||||||
const BIntegerFormatParameters *parent)
|
|
||||||
{
|
|
||||||
fParent = parent;
|
|
||||||
SetParentNumberParameters(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParentIntegerParameters
|
|
||||||
const BIntegerFormatParameters *
|
|
||||||
BIntegerFormatParameters::ParentIntegerParameters() const
|
|
||||||
{
|
|
||||||
return fParent;
|
|
||||||
}
|
|
||||||
|
|
||||||
// =
|
|
||||||
BIntegerFormatParameters &
|
|
||||||
BIntegerFormatParameters::operator=(const BIntegerFormatParameters &other)
|
|
||||||
{
|
|
||||||
BNumberFormatParameters::operator=(other);
|
|
||||||
fParent = other.fParent;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -36,13 +36,9 @@ local sources =
|
|||||||
UnicodeChar.cpp # Already used in FirstBootPrompt.
|
UnicodeChar.cpp # Already used in FirstBootPrompt.
|
||||||
|
|
||||||
# old, needs investigation
|
# old, needs investigation
|
||||||
# Currency.cpp
|
|
||||||
# FormatImpl.cpp
|
# FormatImpl.cpp
|
||||||
# FormatParameters.cpp
|
# FormatParameters.cpp
|
||||||
# GenericNumberFormat.cpp
|
# GenericNumberFormat.cpp
|
||||||
# IntegerFormat.cpp
|
|
||||||
# IntegerFormatImpl.cpp
|
|
||||||
# IntegerFormatParameters.cpp
|
|
||||||
# NumberFormatParameters.cpp
|
# NumberFormatParameters.cpp
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user