1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 **********************************************************************
5 * Copyright (c) 2004-2014 International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
9 * Created: April 20, 2004
11 **********************************************************************
13 #include "unicode/utypes.h"
15 #if !UCONFIG_NO_FORMATTING
18 #include "unicode/numfmt.h"
19 #include "unicode/curramt.h"
23 CurrencyFormat::CurrencyFormat(const Locale& locale, UErrorCode& ec) :
24 MeasureFormat(locale, UMEASFMT_WIDTH_WIDE, ec), fmt(NULL)
26 fmt = NumberFormat::createCurrencyInstance(locale, ec);
29 CurrencyFormat::CurrencyFormat(const CurrencyFormat& other) :
30 MeasureFormat(other), fmt(NULL)
32 fmt = (NumberFormat*) other.fmt->clone();
35 CurrencyFormat::~CurrencyFormat() {
39 Format* CurrencyFormat::clone() const {
40 return new CurrencyFormat(*this);
43 UnicodeString& CurrencyFormat::format(const Formattable& obj,
44 UnicodeString& appendTo,
48 return fmt->format(obj, appendTo, pos, ec);
51 void CurrencyFormat::parseObject(const UnicodeString& source,
53 ParsePosition& pos) const
55 CurrencyAmount* currAmt = fmt->parseCurrency(source, pos);
56 if (currAmt != NULL) {
57 result.adoptObject(currAmt);
61 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyFormat)
65 #endif /* #if !UCONFIG_NO_FORMATTING */