intl/icu/source/i18n/currfmt.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial