ICU-13634 Changes from pre-merge code light-review.

X-SVN-Rev: 41267
This commit is contained in:
Shane Carr 2018-04-24 01:19:44 +00:00
parent 607a60bc3b
commit faa2897561
12 changed files with 114 additions and 15 deletions

View file

@ -44,5 +44,31 @@ CompactDecimalFormat& CompactDecimalFormat::operator=(const CompactDecimalFormat
return *this;
}
Format* CompactDecimalFormat::clone() const {
return new CompactDecimalFormat(*this);
}
void
CompactDecimalFormat::parse(
const UnicodeString& /* text */,
Formattable& /* result */,
ParsePosition& /* parsePosition */) const {
}
void
CompactDecimalFormat::parse(
const UnicodeString& /* text */,
Formattable& /* result */,
UErrorCode& status) const {
status = U_UNSUPPORTED_ERROR;
}
CurrencyAmount*
CompactDecimalFormat::parseCurrency(
const UnicodeString& /* text */,
ParsePosition& /* pos */) const {
return nullptr;
}
#endif /* #if !UCONFIG_NO_FORMATTING */

View file

@ -528,11 +528,13 @@
<ClInclude Include="number_scientific.h" />
<ClInclude Include="number_stringbuilder.h" />
<ClInclude Include="number_types.h" />
<ClInclude Include="number_utypes.h" />
<ClInclude Include="number_utils.h" />
<ClInclude Include="number_mapper.h" />
<ClInclude Include="number_multiplier.h" />
<ClInclude Include="number_currencysymbols.h" />
<ClInclude Include="number_skeletons.h" />
<ClInclude Include="fieldposutil.h" />
<ClInclude Include="numparse_stringsegment.h" />
<ClInclude Include="numparse_impl.h" />
<ClInclude Include="numparse_symbols.h" />

View file

@ -839,6 +839,9 @@
<ClInclude Include="number_types.h">
<Filter>formatting</Filter>
</ClInclude>
<ClInclude Include="number_utypes.h">
<Filter>formatting</Filter>
</ClInclude>
<ClInclude Include="number_utils.h">
<Filter>formatting</Filter>
</ClInclude>
@ -854,6 +857,9 @@
<ClInclude Include="number_skeletons.h">
<Filter>formatting</Filter>
</ClInclude>
<ClInclude Include="fieldposutil.h">
<Filter>formatting</Filter>
</ClInclude>
<ClInclude Include="numparse_stringsegment.h">
<Filter>formatting</Filter>
</ClInclude>

View file

@ -633,11 +633,13 @@
<ClInclude Include="number_scientific.h" />
<ClInclude Include="number_stringbuilder.h" />
<ClInclude Include="number_types.h" />
<ClInclude Include="number_utypes.h" />
<ClInclude Include="number_utils.h" />
<ClInclude Include="number_mapper.h" />
<ClInclude Include="number_multiplier.h" />
<ClInclude Include="number_currencysymbols.h" />
<ClInclude Include="number_skeletons.h" />
<ClInclude Include="fieldposutil.h" />
<ClInclude Include="numparse_stringsegment.h" />
<ClInclude Include="numparse_impl.h" />
<ClInclude Include="numparse_symbols.h" />

View file

@ -42,6 +42,8 @@ class VisibleDigits;
namespace pluralimpl {
// TODO: Remove this and replace with u"" literals. Was for EBCDIC compatibility.
static const UChar DOT = ((UChar) 0x002E);
static const UChar SINGLE_QUOTE = ((UChar) 0x0027);
static const UChar SLASH = ((UChar) 0x002F);

View file

@ -94,8 +94,62 @@ public:
*/
CompactDecimalFormat& operator=(const CompactDecimalFormat& rhs);
/**
* Clone this Format object polymorphically. The caller owns the
* result and should delete it when done.
*
* @return a polymorphic copy of this CompactDecimalFormat.
* @stable ICU 51
*/
virtual Format* clone() const;
using DecimalFormat::format;
/**
* CompactDecimalFormat does not support parsing. This implementation
* does nothing.
* @param text Unused.
* @param result Does not change.
* @param parsePosition Does not change.
* @see Formattable
* @stable ICU 51
*/
void parse(const UnicodeString& text, Formattable& result,
ParsePosition& parsePosition) const U_OVERRIDE;
/**
* CompactDecimalFormat does not support parsing. This implementation
* sets status to U_UNSUPPORTED_ERROR
*
* @param text Unused.
* @param result Does not change.
* @param status Always set to U_UNSUPPORTED_ERROR.
* @stable ICU 51
*/
void parse(const UnicodeString& text, Formattable& result, UErrorCode& status) const U_OVERRIDE;
/**
* Parses text from the given string as a currency amount. Unlike
* the parse() method, this method will attempt to parse a generic
* currency name, searching for a match of this object's locale's
* currency display names, or for a 3-letter ISO currency code.
* This method will fail if this format is not a currency format,
* that is, if it does not contain the currency pattern symbol
* (U+00A4) in its prefix or suffix. This implementation always returns
* NULL.
*
* @param text the string to parse
* @param pos input-output position; on input, the position within text
* to match; must have 0 <= pos.getIndex() < text.length();
* on output, the position after the last matched character.
* If the parse fails, the position in unchanged upon output.
* @return if parse succeeds, a pointer to a newly-created CurrencyAmount
* object (owned by the caller) containing information about
* the parsed currency; if parse fails, this is NULL.
* @internal
*/
CurrencyAmount* parseCurrency(const UnicodeString& text, ParsePosition& pos) const U_OVERRIDE;
/**
* Return the class ID for this class. This is useful only for
* comparing to a return value from getDynamicClassID(). For example:

View file

@ -27,7 +27,6 @@
#ifndef DECIMFMT_H
#define DECIMFMT_H
#include <atomic>
#include "unicode/utypes.h"
/**
* \file
@ -36,6 +35,7 @@
#if !UCONFIG_NO_FORMATTING
#include <atomic>
#include "unicode/dcfmtsym.h"
#include "unicode/numfmt.h"
#include "unicode/locid.h"
@ -56,13 +56,8 @@
U_NAMESPACE_BEGIN
class DigitList;
class CurrencyPluralInfo;
class Hashtable;
class UnicodeSet;
class FieldPositionHandler;
class FixedDecimal;
class PluralRules;
class CompactDecimalFormat;
namespace number {
@ -712,7 +707,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* pattern is invalid this will be set to a failure code.
* @stable ICU 2.0
*/
explicit DecimalFormat(UErrorCode& status);
DecimalFormat(UErrorCode& status);
/**
* Create a DecimalFormat from the given pattern and the symbols
@ -1733,7 +1728,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* @see #setParseNoExponent
* @internal This API is a technical preview. It may change in an upcoming release.
*/
UBool isParseNoExponent() const;
virtual UBool isParseNoExponent() const;
/**
* {@icu} Specifies whether to stop parsing when an exponent separator is encountered. For
@ -1751,7 +1746,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* @see #setParseCaseSensitive
* @internal This API is a technical preview. It may change in an upcoming release.
*/
UBool isParseCaseSensitive() const;
virtual UBool isParseCaseSensitive() const;
/**
* {@icu} Whether to pay attention to case when parsing; default is to ignore case (perform
@ -1762,7 +1757,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
*
* @internal This API is a technical preview. It may change in an upcoming release.
*/
void setParseCaseSensitive(UBool value);
virtual void setParseCaseSensitive(UBool value);
/**
* {@icu} Returns whether truncation of high-order integer digits should result in an error.
@ -1771,7 +1766,7 @@ class U_I18N_API DecimalFormat : public NumberFormat {
* @see setFormatFailIfMoreThanMaxDigits
* @internal This API is a technical preview. It may change in an upcoming release.
*/
UBool isFormatFailIfMoreThanMaxDigits() const;
virtual UBool isFormatFailIfMoreThanMaxDigits() const;
/**
* {@icu} Sets whether truncation of high-order integer digits should result in an error.

View file

@ -1676,14 +1676,14 @@ class U_I18N_API NumberFormatterSettings {
/**
* Overload of grouping() for use on an rvalue reference.
*
* @param rounder
* @param strategy
* The grouping strategy to use.
* @return The fluent chain.
* @see #grouping
* @provisional This API might change or be removed in a future release.
* @draft ICU 62
*/
Derived grouping(const UGroupingStrategy& rounder) &&;
Derived grouping(const UGroupingStrategy& strategy) &&;
/**
* Specifies the minimum and maximum number of digits to render before the decimal mark.

View file

@ -1078,12 +1078,14 @@ typedef enum UNumberFormatAttribute {
/**
* Whether parsing is sensitive to case (lowercase/uppercase).
* TODO: Add to the test suite.
* @internal This API is a technical preview. It may change in an upcoming release.
*/
UNUM_PARSE_CASE_SENSITIVE = 0x1004,
/**
* Formatting: whether to show the plus sign on non-negative numbers.
* TODO: Add to the test suite.
* @internal This API is a technical preview. It may change in an upcoming release.
*/
UNUM_SIGN_ALWAYS_SHOWN = 0x1005,

View file

@ -9,7 +9,6 @@
#ifndef _DATADRIVENNUMBERFORMATTESTSUITE_H__
#define _DATADRIVENNUMBERFORMATTESTSUITE_H__
#include "cmemory.h"
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
@ -18,6 +17,7 @@
#include "unicode/unistr.h"
#include "numberformattesttuple.h"
#include "intltest.h"
#include "cmemory.h"
struct UCHARBUF;
class IntlTest;

View file

@ -22,8 +22,9 @@
#include "putilimp.h"
#include "plurrule_impl.h"
#include "number_decimalquantity.h"
#include <stdio.h>
#include <number_decimalquantity.h>
// This is an API test, not a unit test. It doesn't test very many cases, and doesn't
// try to test the full functionality. It just calls each function in the class and

View file

@ -8,6 +8,15 @@
// for that test suite. After the global settings, comes "begin", the
// per-test field names, and finally the test specific field values, 1 test
// per line.
//
// Field names:
// J = ICU58
// K = JDK
// C = ICU4C
// P = ICU4J parsing
// Q = ICU4J formatting
// S = ICU4J toPattern
//
// For more information on the format of this file, including all the available
// field names, please see
// https://docs.google.com/document/d/1T2P0p953_Lh1pRwo-5CuPVrHlIBa_wcXElG-Hhg_WHM/edit?usp=sharing