From 0e4ad75e47f03dea328306c629d60466e8d83c49 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 23 Jul 2017 09:15:42 +0200 Subject: [PATCH] Remove more unneeded files from the Locale Kit All of this is replaced by the single BNumberFormat class. --- headers/os/LocaleKit.h | 4 - headers/os/locale/Currency.h | 45 ----- headers/os/locale/IntegerFormat.h | 58 ------ headers/os/locale/IntegerFormatImpl.h | 36 ---- headers/os/locale/IntegerFormatParameters.h | 22 --- src/kits/locale/Currency.cpp | 192 -------------------- src/kits/locale/IntegerFormat.cpp | 48 ----- src/kits/locale/IntegerFormatImpl.cpp | 28 --- src/kits/locale/IntegerFormatParameters.cpp | 48 ----- src/kits/locale/Jamfile | 4 - 10 files changed, 485 deletions(-) delete mode 100644 headers/os/locale/Currency.h delete mode 100644 headers/os/locale/IntegerFormat.h delete mode 100644 headers/os/locale/IntegerFormatImpl.h delete mode 100644 headers/os/locale/IntegerFormatParameters.h delete mode 100644 src/kits/locale/Currency.cpp delete mode 100644 src/kits/locale/IntegerFormat.cpp delete mode 100644 src/kits/locale/IntegerFormatImpl.cpp delete mode 100644 src/kits/locale/IntegerFormatParameters.cpp diff --git a/headers/os/LocaleKit.h b/headers/os/LocaleKit.h index c9a68df049..6dfc95823b 100644 --- a/headers/os/LocaleKit.h +++ b/headers/os/LocaleKit.h @@ -6,15 +6,11 @@ #include #include #include -#include #include #include #include #include #include -#include -#include -#include #include #include #include diff --git a/headers/os/locale/Currency.h b/headers/os/locale/Currency.h deleted file mode 100644 index 754f4731fa..0000000000 --- a/headers/os/locale/Currency.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _B_CURRENCY_H_ -#define _B_CURRENCY_H_ - -#include -#include -#include - -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_ diff --git a/headers/os/locale/IntegerFormat.h b/headers/os/locale/IntegerFormat.h deleted file mode 100644 index aed41e4261..0000000000 --- a/headers/os/locale/IntegerFormat.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef _B_INTEGER_FORMAT_H_ -#define _B_INTEGER_FORMAT_H_ - -#include -#include - -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_ diff --git a/headers/os/locale/IntegerFormatImpl.h b/headers/os/locale/IntegerFormatImpl.h deleted file mode 100644 index 9fdfa3f699..0000000000 --- a/headers/os/locale/IntegerFormatImpl.h +++ /dev/null @@ -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_ diff --git a/headers/os/locale/IntegerFormatParameters.h b/headers/os/locale/IntegerFormatParameters.h deleted file mode 100644 index e3b81aa61d..0000000000 --- a/headers/os/locale/IntegerFormatParameters.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _B_INTEGER_FORMAT_PARAMETERS_H_ -#define _B_INTEGER_FORMAT_PARAMETERS_H_ - -#include - -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_ diff --git a/src/kits/locale/Currency.cpp b/src/kits/locale/Currency.cpp deleted file mode 100644 index 86e4f34105..0000000000 --- a/src/kits/locale/Currency.cpp +++ /dev/null @@ -1,192 +0,0 @@ -#include - -// 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; -} - diff --git a/src/kits/locale/IntegerFormat.cpp b/src/kits/locale/IntegerFormat.cpp deleted file mode 100644 index 3a702c5df0..0000000000 --- a/src/kits/locale/IntegerFormat.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include - -// 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) -{ -} - diff --git a/src/kits/locale/IntegerFormatImpl.cpp b/src/kits/locale/IntegerFormatImpl.cpp deleted file mode 100644 index badb3acc90..0000000000 --- a/src/kits/locale/IntegerFormatImpl.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -// constructor -BIntegerFormatImpl::BIntegerFormatImpl() - : BNumberFormatImpl() -{ -} - -// destructor -BIntegerFormatImpl::~BIntegerFormatImpl() -{ -} - -// DefaultNumberFormatParameters -BNumberFormatParameters * -BIntegerFormatImpl::DefaultNumberFormatParameters() -{ - return DefaultIntegerFormatParameters(); -} - -// DefaultNumberFormatParameters -const BNumberFormatParameters * -BIntegerFormatImpl::DefaultNumberFormatParameters() const -{ - return DefaultIntegerFormatParameters(); -} - diff --git a/src/kits/locale/IntegerFormatParameters.cpp b/src/kits/locale/IntegerFormatParameters.cpp deleted file mode 100644 index 236297a8b2..0000000000 --- a/src/kits/locale/IntegerFormatParameters.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include - -// 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; -} - diff --git a/src/kits/locale/Jamfile b/src/kits/locale/Jamfile index ca16fe8ece..94130b9158 100644 --- a/src/kits/locale/Jamfile +++ b/src/kits/locale/Jamfile @@ -36,13 +36,9 @@ local sources = UnicodeChar.cpp # Already used in FirstBootPrompt. # old, needs investigation - # Currency.cpp # FormatImpl.cpp # FormatParameters.cpp # GenericNumberFormat.cpp - # IntegerFormat.cpp - # IntegerFormatImpl.cpp - # IntegerFormatParameters.cpp # NumberFormatParameters.cpp ;