1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/*
4**********************************************************************
5* Copyright (c) 2004-2014 International Business Machines
6* Corporation and others. All Rights Reserved.
7**********************************************************************
8* Author: Alan Liu
9* Created: April 20, 2004
10* Since: ICU 3.0
11**********************************************************************
12*/
13#include "unicode/utypes.h"
14
15#if !UCONFIG_NO_FORMATTING
16
17#include "currfmt.h"
18#include "unicode/numfmt.h"
19#include "unicode/curramt.h"
20
21U_NAMESPACE_BEGIN
22
23CurrencyFormat::CurrencyFormat(const Locale& locale, UErrorCode& ec) :
24 MeasureFormat(locale, UMEASFMT_WIDTH_WIDE, ec)
25{
26}
27
28CurrencyFormat::CurrencyFormat(const CurrencyFormat& other) :
29 MeasureFormat(other)
30{
31}
32
33CurrencyFormat::~CurrencyFormat() {
34}
35
36CurrencyFormat* CurrencyFormat::clone() const {
37 return new CurrencyFormat(*this);
38}
39
40UnicodeString& CurrencyFormat::format(const Formattable& obj,
41 UnicodeString& appendTo,
42 FieldPosition& pos,
43 UErrorCode& ec) const
44{
45 return getCurrencyFormatInternal().format(obj, appendTo, pos, ec);
46}
47
48void CurrencyFormat::parseObject(const UnicodeString& source,
49 Formattable& result,
50 ParsePosition& pos) const
51{
52 CurrencyAmount* currAmt = getCurrencyFormatInternal().parseCurrency(source, pos);
53 if (currAmt != NULL) {
54 result.adoptObject(currAmt);
55 }
56}
57
58UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyFormat)
59
60U_NAMESPACE_END
61
62#endif /* #if !UCONFIG_NO_FORMATTING */
63