/*
*******************************************************************************
-* Copyright (C) 1997-2013, International Business Machines Corporation and *
+* Copyright (C) 1997-2014, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
parseError.postContext[stop-start]= 0;
}
+DecimalFormatPattern::DecimalFormatPattern()
+ : fMinimumIntegerDigits(1),
+ fMaximumIntegerDigits(gDefaultMaxIntegerDigits),
+ fMinimumFractionDigits(0),
+ fMaximumFractionDigits(3),
+ fUseSignificantDigits(FALSE),
+ fMinimumSignificantDigits(1),
+ fMaximumSignificantDigits(6),
+ fUseExponentialNotation(FALSE),
+ fMinExponentDigits(0),
+ fExponentSignAlwaysShown(FALSE),
+ fCurrencySignCount(fgCurrencySignCountZero),
+ fGroupingUsed(TRUE),
+ fGroupingSize(0),
+ fGroupingSize2(0),
+ fMultiplier(1),
+ fDecimalSeparatorAlwaysShown(FALSE),
+ fFormatWidth(0),
+ fRoundingIncrementUsed(FALSE),
+ fRoundingIncrement(),
+ fPad(kPatternPadEscape),
+ fNegPatternsBogus(TRUE),
+ fPosPatternsBogus(TRUE),
+ fNegPrefixPattern(),
+ fNegSuffixPattern(),
+ fPosPrefixPattern(),
+ fPosSuffixPattern(),
+ fPadPosition(DecimalFormatPattern::kPadBeforePrefix) {
+}
+
+
DecimalFormatPatternParser::DecimalFormatPatternParser() :
fZeroDigit(kPatternZeroDigit),
fSigDigit(kPatternSignificantDigit),
{
return;
}
-
- out.fMinimumIntegerDigits = 1;
- out.fMaximumIntegerDigits = gDefaultMaxIntegerDigits;
- out.fMinimumFractionDigits = 0;
- out.fMaximumFractionDigits = 3;
- out.fUseSignificantDigits = FALSE;
- out.fMinimumSignificantDigits = 1;
- out.fMaximumSignificantDigits = 6;
- out.fUseExponentialNotation = FALSE;
- out.fMinExponentDigits = 0;
- out.fExponentSignAlwaysShown = FALSE;
- out.fCurrencySignCount = fgCurrencySignCountZero;
- out.fGroupingUsed = TRUE;
- out.fGroupingSize = 0;
- out.fGroupingSize2 = 0;
- out.fMultiplier = 1;
- out.fDecimalSeparatorAlwaysShown = FALSE;
- out.fFormatWidth = 0;
- out.fRoundingIncrementUsed = FALSE;
- out.fPad = 0;
- out.fNegPrefixPattern.setToBogus();
- out.fNegSuffixPattern.setToBogus();
- out.fPosPrefixPattern.setToBogus();
- out.fPosSuffixPattern.setToBogus();
- out.fPadPosition = DecimalFormatPattern::kPadBeforePrefix;
- out.fPad = kPatternPadEscape;
+ out = DecimalFormatPattern();
// Clear error struct
parseError.offset = -1;
}
if (part == 0) {
+ out.fPosPatternsBogus = FALSE;
out.fPosPrefixPattern = prefix;
out.fPosSuffixPattern = suffix;
- out.fNegPrefixPattern.setToBogus();
- out.fNegSuffixPattern.setToBogus();
+ out.fNegPatternsBogus = TRUE;
+ out.fNegPrefixPattern.remove();
+ out.fNegSuffixPattern.remove();
out.fUseExponentialNotation = (expDigits >= 0);
if (out.fUseExponentialNotation) {
out.fRoundingIncrementUsed = FALSE;
}
} else {
+ out.fNegPatternsBogus = FALSE;
out.fNegPrefixPattern = prefix;
out.fNegSuffixPattern = suffix;
}
}
if (pattern.length() == 0) {
- out.fNegPrefixPattern.setToBogus();
- out.fNegSuffixPattern.setToBogus();
+ out.fNegPatternsBogus = TRUE;
+ out.fNegPrefixPattern.remove();
+ out.fNegSuffixPattern.remove();
+ out.fPosPatternsBogus = FALSE;
out.fPosPrefixPattern.remove();
out.fPosSuffixPattern.remove();
// If there was no negative pattern, or if the negative pattern is
// identical to the positive pattern, then prepend the minus sign to the
// positive pattern to form the negative pattern.
- if (out.fNegPrefixPattern.isBogus() ||
+ if (out.fNegPatternsBogus ||
(out.fNegPrefixPattern == out.fPosPrefixPattern
&& out.fNegSuffixPattern == out.fPosSuffixPattern)) {
+ out.fNegPatternsBogus = FALSE;
out.fNegSuffixPattern = out.fPosSuffixPattern;
- out.fNegPrefixPattern.remove();
out.fNegPrefixPattern.append(kQuote).append(kPatternMinus)
.append(out.fPosPrefixPattern);
}
/*
*******************************************************************************
-* Copyright (C) 1997-2013, International Business Machines Corporation and *
+* Copyright (C) 1997-2014, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
kPadAfterSuffix
};
+ DecimalFormatPattern();
+
int32_t fMinimumIntegerDigits;
int32_t fMaximumIntegerDigits;
int32_t fMinimumFractionDigits;
UBool fRoundingIncrementUsed;
DigitList fRoundingIncrement;
UChar32 fPad;
-
- // These next four can be set to empty or bogus as
- // there is a difference between having an empty
- // pattern and having an unspecified pattern.
+ UBool fNegPatternsBogus;
+ UBool fPosPatternsBogus;
UnicodeString fNegPrefixPattern;
UnicodeString fNegSuffixPattern;
UnicodeString fPosPrefixPattern;
/*
*******************************************************************************
-* Copyright (C) 1997-2013, International Business Machines Corporation and *
+* Copyright (C) 1997-2014, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
********************************************************************************
*/
-#include <iostream>
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#include "plurrule_impl.h"
#include "decimalformatpattern.h"
-#define COMPLAIN(W, X, Y) (std::cout << (W) << ": " << (X) << ", got: " << (Y) << std::endl)
-
-#define CHECK_COMPLAIN(W, X, Y) if ((X) != (Y)) COMPLAIN(W, X, Y)
-
-#define CHECK_STRING(W, X, Y) if (((X) == NULL && !(Y).isBogus()) || ((X) != NULL && (Y) != *(X))) COMPLAIN(W, "EXPECTED", "ACTUAL")
-
/*
* On certain platforms, round is a macro defined in math.h
* This undefine is to avoid conflict between the macro and
inline int32_t _min(int32_t a, int32_t b) { return (a<b) ? a : b; }
inline int32_t _max(int32_t a, int32_t b) { return (a<b) ? b : a; }
-static void copyString(const UnicodeString& src, UnicodeString *& dest, UErrorCode &status) {
+static void copyString(const UnicodeString& src, UBool isBogus, UnicodeString *& dest, UErrorCode &status) {
if (U_FAILURE(status)) {
return;
}
- if (src.isBogus()) {
+ if (isBogus) {
delete dest;
dest = NULL;
} else {
fPadPosition = kPadAfterSuffix;
break;
}
- copyString(out.fNegPrefixPattern, fNegPrefixPattern, status);
- copyString(out.fNegSuffixPattern, fNegSuffixPattern, status);
- copyString(out.fPosPrefixPattern, fPosPrefixPattern, status);
- copyString(out.fPosSuffixPattern, fPosSuffixPattern, status);
+ copyString(out.fNegPrefixPattern, out.fNegPatternsBogus, fNegPrefixPattern, status);
+ copyString(out.fNegSuffixPattern, out.fNegPatternsBogus, fNegSuffixPattern, status);
+ copyString(out.fPosPrefixPattern, out.fPosPatternsBogus, fPosPrefixPattern, status);
+ copyString(out.fPosSuffixPattern, out.fPosPatternsBogus, fPosSuffixPattern, status);
}