/*
******************************************************************************
*
-* Copyright (C) 1997-2011, International Business Machines
+* Copyright (C) 1997-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
#endif
+enum EStackMode { kOnStack };
+
+enum EFastpathBits { kFastpathOk = 1, kNoDecimal = 2 };
+
/**
* Digit List is actually a Decimal Floating Point number.
* The original implementation has been replaced by a thin wrapper onto a
*/
void set(int64_t source);
+ /**
+ * Utility routine to set the value of the digit list from an int64.
+ * Does not set the decnumber unless requested later
+ * If a non-zero maximumDigits is specified, no more than that number of
+ * significant digits will be produced.
+ * @param source The value to be set
+ */
+ void setInteger(int64_t source);
+
/**
* Utility routine to set the value of the digit list from a decimal number
* string.
* @param source The value to be set. The string must be nul-terminated.
+ * @param fastpathBits special flags for fast parsing
*/
- void set(const StringPiece &source, UErrorCode &status);
+ void set(const StringPiece &source, UErrorCode &status, uint32_t fastpathBits = 0);
/**
* Multiply this = this * arg
* This is an optimization for the formatting implementation, which may
* ask for the double value multiple times.
*/
- double fDouble;
- UBool fHaveDouble;
+ union DoubleOrInt64 {
+ double fDouble;
+ int64_t fInt64;
+ } fUnion;
+ enum EHave {
+ kNone=0,
+ kDouble,
+ kInt64
+ } fHave;
UBool shouldRoundUp(int32_t maximumDigits) const;
+
+ public:
+
+#if U_OVERRIDE_CXX_ALLOCATION
+ using UMemory::operator new;
+ using UMemory::operator delete;
+#else
+ static inline void * U_EXPORT2 operator new(size_t size) U_NO_THROW { return ::operator new(size); };
+ static inline void U_EXPORT2 operator delete(void *ptr ) U_NO_THROW { ::operator delete(ptr); };
+#endif
+
+ /**
+ * Placement new for stack usage
+ * @internal
+ */
+ static inline void * U_EXPORT2 operator new(size_t /*size*/, void * onStack, EStackMode /*mode*/) U_NO_THROW { return onStack; }
+
+ /**
+ * Placement delete for stack usage
+ * @internal
+ */
+ static inline void U_EXPORT2 operator delete(void * /*ptr*/, void * /*onStack*/, EStackMode /*mode*/) U_NO_THROW {}
+
+ private:
+ inline void internalSetDouble(double d) {
+ fHave = kDouble;
+ fUnion.fDouble=d;
+ }
+ inline void internalSetInt64(int64_t d) {
+ fHave = kInt64;
+ fUnion.fInt64=d;
+ }
+ inline void internalClear() {
+ fHave = kNone;
+ }
};