Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ********************************************************************** |
michael@0 | 3 | * Copyright (c) 2004-2012 International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ********************************************************************** |
michael@0 | 6 | * Author: Alan Liu |
michael@0 | 7 | * Created: April 20, 2004 |
michael@0 | 8 | * Since: ICU 3.0 |
michael@0 | 9 | ********************************************************************** |
michael@0 | 10 | */ |
michael@0 | 11 | #include "utypeinfo.h" // for 'typeid' to work |
michael@0 | 12 | |
michael@0 | 13 | #include "unicode/utypes.h" |
michael@0 | 14 | |
michael@0 | 15 | #if !UCONFIG_NO_FORMATTING |
michael@0 | 16 | |
michael@0 | 17 | #include "currfmt.h" |
michael@0 | 18 | #include "unicode/numfmt.h" |
michael@0 | 19 | #include "unicode/curramt.h" |
michael@0 | 20 | |
michael@0 | 21 | U_NAMESPACE_BEGIN |
michael@0 | 22 | |
michael@0 | 23 | CurrencyFormat::CurrencyFormat(const Locale& locale, UErrorCode& ec) : |
michael@0 | 24 | fmt(NULL) |
michael@0 | 25 | { |
michael@0 | 26 | fmt = NumberFormat::createCurrencyInstance(locale, ec); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | CurrencyFormat::CurrencyFormat(const CurrencyFormat& other) : |
michael@0 | 30 | MeasureFormat(other), fmt(NULL) |
michael@0 | 31 | { |
michael@0 | 32 | fmt = (NumberFormat*) other.fmt->clone(); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | CurrencyFormat::~CurrencyFormat() { |
michael@0 | 36 | delete fmt; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | UBool CurrencyFormat::operator==(const Format& other) const { |
michael@0 | 40 | if (this == &other) { |
michael@0 | 41 | return TRUE; |
michael@0 | 42 | } |
michael@0 | 43 | if (typeid(*this) != typeid(other)) { |
michael@0 | 44 | return FALSE; |
michael@0 | 45 | } |
michael@0 | 46 | const CurrencyFormat* c = (const CurrencyFormat*) &other; |
michael@0 | 47 | return *fmt == *c->fmt; |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | Format* CurrencyFormat::clone() const { |
michael@0 | 51 | return new CurrencyFormat(*this); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | UnicodeString& CurrencyFormat::format(const Formattable& obj, |
michael@0 | 55 | UnicodeString& appendTo, |
michael@0 | 56 | FieldPosition& pos, |
michael@0 | 57 | UErrorCode& ec) const |
michael@0 | 58 | { |
michael@0 | 59 | return fmt->format(obj, appendTo, pos, ec); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | void CurrencyFormat::parseObject(const UnicodeString& source, |
michael@0 | 63 | Formattable& result, |
michael@0 | 64 | ParsePosition& pos) const |
michael@0 | 65 | { |
michael@0 | 66 | CurrencyAmount* currAmt = fmt->parseCurrency(source, pos); |
michael@0 | 67 | if (currAmt != NULL) { |
michael@0 | 68 | result.adoptObject(currAmt); |
michael@0 | 69 | } |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyFormat) |
michael@0 | 73 | |
michael@0 | 74 | U_NAMESPACE_END |
michael@0 | 75 | |
michael@0 | 76 | #endif /* #if !UCONFIG_NO_FORMATTING */ |