LocaleKit: remove obsolete files.
Formatting floats is handled by BNumberFormat already.
This commit is contained in:
@@ -7,9 +7,6 @@
|
|||||||
#include <Collator.h>
|
#include <Collator.h>
|
||||||
#include <Country.h>
|
#include <Country.h>
|
||||||
#include <Currency.h>
|
#include <Currency.h>
|
||||||
#include <FloatFormat.h>
|
|
||||||
#include <FloatFormatImpl.h>
|
|
||||||
#include <FloatFormatParameters.h>
|
|
||||||
#include <Format.h>
|
#include <Format.h>
|
||||||
#include <FormatImpl.h>
|
#include <FormatImpl.h>
|
||||||
#include <FormatParameters.h>
|
#include <FormatParameters.h>
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
#ifndef _B_FLOAT_FORMAT_H_
|
|
||||||
#define _B_FLOAT_FORMAT_H_
|
|
||||||
|
|
||||||
#include <NumberFormat.h>
|
|
||||||
#include <FloatFormatParameters.h>
|
|
||||||
|
|
||||||
class BString;
|
|
||||||
class BFloatFormatImpl;
|
|
||||||
|
|
||||||
class 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
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _B_FLOAT_FORMAT_H_
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
#ifndef _B_FLOAT_FORMAT_IMPL_H_
|
|
||||||
#define _B_FLOAT_FORMAT_IMPL_H_
|
|
||||||
|
|
||||||
struct format_field_position;
|
|
||||||
class BFloatFormatParameters;
|
|
||||||
class BString;
|
|
||||||
|
|
||||||
class BFloatFormatImpl {
|
|
||||||
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_
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
#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 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_
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
#include <FloatFormat.h>
|
|
||||||
#include <FloatFormatImpl.h>
|
|
||||||
|
|
||||||
// copy constructor
|
|
||||||
BFloatFormat::BFloatFormat(const BFloatFormat &other)
|
|
||||||
: BNumberFormat(other),
|
|
||||||
BFloatFormatParameters(other)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// destructor
|
|
||||||
BFloatFormat::~BFloatFormat()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format
|
|
||||||
status_t
|
|
||||||
BFloatFormat::Format(double number, BString *buffer) const
|
|
||||||
{
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format
|
|
||||||
status_t
|
|
||||||
BFloatFormat::Format(double number, BString *buffer,
|
|
||||||
format_field_position *positions, int32 positionCount,
|
|
||||||
int32 *fieldCount, bool allFieldPositions) const
|
|
||||||
{
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// =
|
|
||||||
BFloatFormat &
|
|
||||||
BFloatFormat::operator=(const BFloatFormat &other)
|
|
||||||
{
|
|
||||||
BNumberFormat::operator=(other);
|
|
||||||
BFloatFormatParameters::operator=(other);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
BFloatFormat::BFloatFormat(BFloatFormatImpl *impl)
|
|
||||||
: BNumberFormat(),
|
|
||||||
BFloatFormatParameters(impl ? impl->DefaultFloatFormatParameters()
|
|
||||||
: NULL)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#include <FloatFormatImpl.h>
|
|
||||||
#include <FloatFormatParameters.h>
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
BFloatFormatImpl::BFloatFormatImpl()
|
|
||||||
: BNumberFormatImpl()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// destructor
|
|
||||||
BFloatFormatImpl::~BFloatFormatImpl()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// DefaultNumberFormatParameters
|
|
||||||
BNumberFormatParameters *
|
|
||||||
BFloatFormatImpl::DefaultNumberFormatParameters()
|
|
||||||
{
|
|
||||||
return DefaultFloatFormatParameters();
|
|
||||||
}
|
|
||||||
|
|
||||||
// DefaultNumberFormatParameters
|
|
||||||
const BNumberFormatParameters *
|
|
||||||
BFloatFormatImpl::DefaultNumberFormatParameters() const
|
|
||||||
{
|
|
||||||
return DefaultFloatFormatParameters();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
#include <FloatFormatParameters.h>
|
|
||||||
|
|
||||||
// defaults
|
|
||||||
static const size_t kDefaultMinimalFractionDigits = 0;
|
|
||||||
static const size_t kDefaultMaximalFractionDigits = 6;
|
|
||||||
static const bool kDefaultUseUpperCase = false;
|
|
||||||
static const float_format_type kDefaultFloatFormatType = B_AUTO_FLOAT_FORMAT;
|
|
||||||
static const bool kDefaultAlwaysUseFractionSeparator = false;
|
|
||||||
static const bool kDefaultKeepTrailingFractionZeros = false;
|
|
||||||
|
|
||||||
|
|
||||||
// flags
|
|
||||||
enum {
|
|
||||||
MINIMAL_FRACTION_DIGITS_SET = 0x01,
|
|
||||||
MAXIMAL_FRACTION_DIGITS_SET = 0x02,
|
|
||||||
USE_UPPER_CASE_SET = 0x04,
|
|
||||||
FLOAT_FORMAT_TYPE_SET = 0x08,
|
|
||||||
ALWAYS_USE_FRACTION_SEPARATOR_SET = 0x10,
|
|
||||||
KEEP_TRAILING_FRACTION_ZEROS_SET = 0x20,
|
|
||||||
};
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
BFloatFormatParameters::BFloatFormatParameters(
|
|
||||||
const BFloatFormatParameters *parent)
|
|
||||||
: BNumberFormatParameters(parent),
|
|
||||||
fParent(parent),
|
|
||||||
fFlags(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy constructor
|
|
||||||
BFloatFormatParameters::BFloatFormatParameters(
|
|
||||||
const BFloatFormatParameters &other)
|
|
||||||
: BNumberFormatParameters(other),
|
|
||||||
fParent(other.fParent),
|
|
||||||
fMinimalFractionDigits(other.fMinimalFractionDigits),
|
|
||||||
fMaximalFractionDigits(other.fMaximalFractionDigits),
|
|
||||||
fUseUpperCase(other.fUseUpperCase),
|
|
||||||
fFloatFormatType(other.fFloatFormatType),
|
|
||||||
fAlwaysUseFractionSeparator(other.fAlwaysUseFractionSeparator),
|
|
||||||
fKeepTrailingFractionZeros(other.fKeepTrailingFractionZeros),
|
|
||||||
fFlags(other.fFlags)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// destructor
|
|
||||||
BFloatFormatParameters::~BFloatFormatParameters()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMinimalFractionDigits
|
|
||||||
void
|
|
||||||
BFloatFormatParameters::SetMinimalFractionDigits(size_t minFractionDigits)
|
|
||||||
{
|
|
||||||
fMinimalFractionDigits = minFractionDigits;
|
|
||||||
fFlags |= MINIMAL_FRACTION_DIGITS_SET;
|
|
||||||
}
|
|
||||||
|
|
||||||
// MinimalFractionDigits
|
|
||||||
size_t
|
|
||||||
BFloatFormatParameters::MinimalFractionDigits() const
|
|
||||||
{
|
|
||||||
if (fFlags & MINIMAL_FRACTION_DIGITS_SET)
|
|
||||||
return fMinimalFractionDigits;
|
|
||||||
if (fParent)
|
|
||||||
return fParent->MinimalFractionDigits();
|
|
||||||
return kDefaultMinimalFractionDigits;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMaximalFractionDigits
|
|
||||||
void
|
|
||||||
BFloatFormatParameters::SetMaximalFractionDigits(size_t maxFractionDigits)
|
|
||||||
{
|
|
||||||
fMaximalFractionDigits = maxFractionDigits;
|
|
||||||
fFlags |= MAXIMAL_FRACTION_DIGITS_SET;
|
|
||||||
}
|
|
||||||
|
|
||||||
// MaximalFractionDigits
|
|
||||||
size_t
|
|
||||||
BFloatFormatParameters::MaximalFractionDigits() const
|
|
||||||
{
|
|
||||||
if (fFlags & MAXIMAL_FRACTION_DIGITS_SET)
|
|
||||||
return fMaximalFractionDigits;
|
|
||||||
if (fParent)
|
|
||||||
return fParent->MaximalFractionDigits();
|
|
||||||
return kDefaultMaximalFractionDigits;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetUseUpperCase
|
|
||||||
void
|
|
||||||
BFloatFormatParameters::SetUseUpperCase(bool useCapitals)
|
|
||||||
{
|
|
||||||
fUseUpperCase = useCapitals;
|
|
||||||
fFlags |= USE_UPPER_CASE_SET;
|
|
||||||
}
|
|
||||||
|
|
||||||
// UseUpperCase
|
|
||||||
bool
|
|
||||||
BFloatFormatParameters::UseUpperCase() const
|
|
||||||
{
|
|
||||||
if (fFlags & USE_UPPER_CASE_SET)
|
|
||||||
return fUseUpperCase;
|
|
||||||
if (fParent)
|
|
||||||
return fParent->UseUpperCase();
|
|
||||||
return kDefaultUseUpperCase;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetFloatFormatType
|
|
||||||
void
|
|
||||||
BFloatFormatParameters::SetFloatFormatType(float_format_type type)
|
|
||||||
{
|
|
||||||
fFloatFormatType = type;
|
|
||||||
fFlags |= FLOAT_FORMAT_TYPE_SET;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FloatFormatType
|
|
||||||
float_format_type
|
|
||||||
BFloatFormatParameters::FloatFormatType() const
|
|
||||||
{
|
|
||||||
if (fFlags & FLOAT_FORMAT_TYPE_SET)
|
|
||||||
return fFloatFormatType;
|
|
||||||
if (fParent)
|
|
||||||
return fParent->FloatFormatType();
|
|
||||||
return kDefaultFloatFormatType;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetAlwaysUseFractionSeparator
|
|
||||||
void
|
|
||||||
BFloatFormatParameters::SetAlwaysUseFractionSeparator(
|
|
||||||
bool alwaysUseFractionSeparator)
|
|
||||||
{
|
|
||||||
fAlwaysUseFractionSeparator = alwaysUseFractionSeparator;
|
|
||||||
fFlags |= ALWAYS_USE_FRACTION_SEPARATOR_SET;
|
|
||||||
}
|
|
||||||
|
|
||||||
// AlwaysUseFractionSeparator
|
|
||||||
bool
|
|
||||||
BFloatFormatParameters::AlwaysUseFractionSeparator() const
|
|
||||||
{
|
|
||||||
if (fFlags & ALWAYS_USE_FRACTION_SEPARATOR_SET)
|
|
||||||
return fAlwaysUseFractionSeparator;
|
|
||||||
if (fParent)
|
|
||||||
return fParent->AlwaysUseFractionSeparator();
|
|
||||||
return kDefaultAlwaysUseFractionSeparator;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetKeepTrailingFractionZeros
|
|
||||||
void
|
|
||||||
BFloatFormatParameters::SetKeepTrailingFractionZeros(
|
|
||||||
bool keepTrailingFractionZeros)
|
|
||||||
{
|
|
||||||
fKeepTrailingFractionZeros = keepTrailingFractionZeros;
|
|
||||||
fFlags |= KEEP_TRAILING_FRACTION_ZEROS_SET;
|
|
||||||
}
|
|
||||||
|
|
||||||
// KeepTrailingFractionZeros
|
|
||||||
bool
|
|
||||||
BFloatFormatParameters::KeepTrailingFractionZeros() const
|
|
||||||
{
|
|
||||||
if (fFlags & KEEP_TRAILING_FRACTION_ZEROS_SET)
|
|
||||||
return fKeepTrailingFractionZeros;
|
|
||||||
if (fParent)
|
|
||||||
return fParent->KeepTrailingFractionZeros();
|
|
||||||
return kDefaultKeepTrailingFractionZeros;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetParentFloatParameters
|
|
||||||
void
|
|
||||||
BFloatFormatParameters::SetParentFloatParameters(
|
|
||||||
const BFloatFormatParameters *parent)
|
|
||||||
{
|
|
||||||
fParent = parent;
|
|
||||||
SetParentNumberParameters(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParentFloatParameters
|
|
||||||
const BFloatFormatParameters *
|
|
||||||
BFloatFormatParameters::ParentFloatParameters() const
|
|
||||||
{
|
|
||||||
return fParent;
|
|
||||||
}
|
|
||||||
|
|
||||||
// =
|
|
||||||
BFloatFormatParameters &
|
|
||||||
BFloatFormatParameters::operator=(const BFloatFormatParameters &other)
|
|
||||||
{
|
|
||||||
BNumberFormatParameters::operator=(other);
|
|
||||||
fParent = other.fParent;
|
|
||||||
fMinimalFractionDigits = other.fMinimalFractionDigits;
|
|
||||||
fMaximalFractionDigits = other.fMaximalFractionDigits;
|
|
||||||
fUseUpperCase = other.fUseUpperCase;
|
|
||||||
fFloatFormatType = other.fFloatFormatType;
|
|
||||||
fAlwaysUseFractionSeparator = other.fAlwaysUseFractionSeparator;
|
|
||||||
fKeepTrailingFractionZeros = other.fKeepTrailingFractionZeros;
|
|
||||||
fFlags = other.fFlags;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -37,9 +37,6 @@ local sources =
|
|||||||
|
|
||||||
# old, needs investigation
|
# old, needs investigation
|
||||||
# Currency.cpp
|
# Currency.cpp
|
||||||
# FloatFormat.cpp
|
|
||||||
# FloatFormatImpl.cpp
|
|
||||||
# FloatFormatParameters.cpp
|
|
||||||
# FormatImpl.cpp
|
# FormatImpl.cpp
|
||||||
# FormatParameters.cpp
|
# FormatParameters.cpp
|
||||||
# GenericNumberFormat.cpp
|
# GenericNumberFormat.cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user