]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/currfmt.cpp
ICU-531.48.tar.gz
[apple/icu.git] / icuSources / i18n / currfmt.cpp
CommitLineData
374ca955
A
1/*
2**********************************************************************
57a6839d 3* Copyright (c) 2004-2014 International Business Machines
374ca955
A
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 "unicode/utypes.h"
12
13#if !UCONFIG_NO_FORMATTING
14
15#include "currfmt.h"
16#include "unicode/numfmt.h"
4388f060 17#include "unicode/curramt.h"
374ca955
A
18
19U_NAMESPACE_BEGIN
20
21CurrencyFormat::CurrencyFormat(const Locale& locale, UErrorCode& ec) :
57a6839d 22 MeasureFormat(locale, UMEASFMT_WIDTH_WIDE, ec), fmt(NULL)
46f4442e 23{
374ca955
A
24 fmt = NumberFormat::createCurrencyInstance(locale, ec);
25}
26
27CurrencyFormat::CurrencyFormat(const CurrencyFormat& other) :
46f4442e
A
28 MeasureFormat(other), fmt(NULL)
29{
374ca955
A
30 fmt = (NumberFormat*) other.fmt->clone();
31}
32
33CurrencyFormat::~CurrencyFormat() {
34 delete fmt;
35}
36
374ca955
A
37Format* CurrencyFormat::clone() const {
38 return new CurrencyFormat(*this);
39}
40
41UnicodeString& CurrencyFormat::format(const Formattable& obj,
42 UnicodeString& appendTo,
43 FieldPosition& pos,
46f4442e
A
44 UErrorCode& ec) const
45{
374ca955
A
46 return fmt->format(obj, appendTo, pos, ec);
47}
48
374ca955
A
49void CurrencyFormat::parseObject(const UnicodeString& source,
50 Formattable& result,
46f4442e
A
51 ParsePosition& pos) const
52{
4388f060
A
53 CurrencyAmount* currAmt = fmt->parseCurrency(source, pos);
54 if (currAmt != NULL) {
55 result.adoptObject(currAmt);
56 }
374ca955
A
57}
58
374ca955
A
59UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyFormat)
60
61U_NAMESPACE_END
62
63#endif /* #if !UCONFIG_NO_FORMATTING */