/*
*******************************************************************************
-* Copyright (C) 1997-2013, International Business Machines Corporation and others.
+* Copyright (C) 1997-2014, International Business Machines Corporation and others.
* All Rights Reserved.
*******************************************************************************
*/
#else
#define U_HAVE_RBNF 1
-#include "unicode/coll.h"
#include "unicode/dcfmtsym.h"
#include "unicode/fmtable.h"
#include "unicode/locid.h"
#include "unicode/numfmt.h"
#include "unicode/unistr.h"
#include "unicode/strenum.h"
+#include "unicode/brkiter.h"
U_NAMESPACE_BEGIN
class NFRuleSet;
class LocalizationInfo;
+class RuleBasedCollator;
/**
* Tags for the predefined rulesets.
URBNF_COUNT
};
-#if UCONFIG_NO_COLLATION
-class Collator;
-#endif
-
/**
* The RuleBasedNumberFormat class formats numbers according to a set of rules. This number formatter is
* typically used for spelling out numeric values in words (e.g., 25,3476 as
FieldPosition& pos,
UErrorCode& status) const;
- /**
- * Formats the specified number using the default ruleset.
- * @param obj The number to format.
- * @param toAppendTo the string that will hold the (appended) result
- * @param pos the fieldposition
- * @param status the status
- * @return A textual representation of the number.
- * @stable ICU 2.0
- */
- virtual UnicodeString& format(const Formattable& obj,
- UnicodeString& toAppendTo,
- FieldPosition& pos,
- UErrorCode& status) const;
- /**
- * Redeclared Format method.
- * @param obj the object to be formatted.
- * @param result Output param which will receive the formatted string.
- * @param status Output param set to success/failure code
- * @return A reference to 'result'.
- * @stable ICU 2.0
- */
- UnicodeString& format(const Formattable& obj,
- UnicodeString& result,
- UErrorCode& status) const;
-
- /**
- * Redeclared NumberFormat method.
- * @param number the double value to be formatted.
- * @param output Output param which will receive the formatted string.
- * @return A reference to 'output'.
- * @stable ICU 2.0
- */
- UnicodeString& format(double number,
- UnicodeString& output) const;
-
- /**
- * Redeclared NumberFormat method.
- * @param number the long value to be formatted.
- * @param output Output param which will receive the formatted string.
- * @return A reference to 'output'.
- * @stable ICU 2.0
- */
- UnicodeString& format(int32_t number,
- UnicodeString& output) const;
+ using NumberFormat::parse;
/**
* Parses the specfied string, beginning at the specified position, according
Formattable& result,
ParsePosition& parsePosition) const;
-
- /**
- * Redeclared Format method.
- * @param text The string to parse
- * @param result the result of the parse, either a double or a long.
- * @param status Output param set to failure code when a problem occurs.
- * @stable ICU 2.0
- */
- virtual inline void parse(const UnicodeString& text,
- Formattable& result,
- UErrorCode& status) const;
-
#if !UCONFIG_NO_COLLATION
/**
*/
virtual UnicodeString getDefaultRuleSetName() const;
+ /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */
+ /**
+ * Set a particular UDisplayContext value in the formatter, such as
+ * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. Note: For getContext, see
+ * NumberFormat.
+ * @param value The UDisplayContext value to set.
+ * @param status Input/output status. If at entry this indicates a failure
+ * status, the function will do nothing; otherwise this will be
+ * updated with any new status from the function.
+ * @draft ICU 53
+ */
+ virtual void setContext(UDisplayContext value, UErrorCode& status);
+
public:
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
const Locale& locale, UParseError& perror, UErrorCode& status);
void init(const UnicodeString& rules, LocalizationInfo* localizations, UParseError& perror, UErrorCode& status);
+ void initCapitalizationContextInfo(const Locale& thelocale);
void dispose();
void stripWhitespace(UnicodeString& src);
void initDefaultRuleSet();
friend class FractionalPartSubstitution;
inline NFRuleSet * getDefaultRuleSet() const;
- Collator * getCollator() const;
+ const RuleBasedCollator * getCollator() const;
DecimalFormatSymbols * getDecimalFormatSymbols() const;
+ UnicodeString& adjustForCapitalizationContext(int32_t startPos, UnicodeString& currentResult) const;
private:
NFRuleSet **ruleSets;
int32_t numRuleSets;
NFRuleSet *defaultRuleSet;
Locale locale;
- Collator* collator;
+ RuleBasedCollator* collator;
DecimalFormatSymbols* decimalFormatSymbols;
UBool lenient;
UnicodeString* lenientParseRules;
LocalizationInfo* localizations;
+ UnicodeString originalDescription;
+ UBool capitalizationInfoSet;
+ UBool capitalizationForUIListMenu;
+ UBool capitalizationForStandAlone;
+ BreakIterator* capitalizationBrkIter;
};
// ---------------
-inline UnicodeString&
-RuleBasedNumberFormat::format(const Formattable& obj,
- UnicodeString& result,
- UErrorCode& status) const
-{
- // Don't use Format:: - use immediate base class only,
- // in case immediate base modifies behavior later.
- // dlf - the above comment is bogus, if there were a reason to modify
- // it, it would be virtual, and there's no reason because it is
- // a one-line macro in NumberFormat anyway, just like this one.
- return NumberFormat::format(obj, result, status);
-}
-
-inline UnicodeString&
-RuleBasedNumberFormat::format(double number, UnicodeString& output) const {
- FieldPosition pos(0);
- return format(number, output, pos);
-}
-
-inline UnicodeString&
-RuleBasedNumberFormat::format(int32_t number, UnicodeString& output) const {
- FieldPosition pos(0);
- return format(number, output, pos);
-}
-
-inline void
-RuleBasedNumberFormat::parse(const UnicodeString& text, Formattable& result, UErrorCode& status) const
-{
- NumberFormat::parse(text, result, status);
-}
-
#if !UCONFIG_NO_COLLATION
inline UBool