]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/currfmt.cpp
ICU-400.38.tar.gz
[apple/icu.git] / icuSources / i18n / currfmt.cpp
CommitLineData
374ca955
A
1/*
2**********************************************************************
46f4442e 3* Copyright (c) 2004-2008, 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"
17
18U_NAMESPACE_BEGIN
19
20CurrencyFormat::CurrencyFormat(const Locale& locale, UErrorCode& ec) :
46f4442e
A
21 fmt(NULL)
22{
374ca955
A
23 fmt = NumberFormat::createCurrencyInstance(locale, ec);
24}
25
26CurrencyFormat::CurrencyFormat(const CurrencyFormat& other) :
46f4442e
A
27 MeasureFormat(other), fmt(NULL)
28{
374ca955
A
29 fmt = (NumberFormat*) other.fmt->clone();
30}
31
32CurrencyFormat::~CurrencyFormat() {
33 delete fmt;
34}
35
36UBool CurrencyFormat::operator==(const Format& other) const {
37 if (this == &other) {
38 return TRUE;
39 }
40 if (other.getDynamicClassID() != CurrencyFormat::getStaticClassID()) {
41 return FALSE;
42 }
43 const CurrencyFormat* c = (const CurrencyFormat*) &other;
44 return *fmt == *c->fmt;
45}
46
47Format* CurrencyFormat::clone() const {
48 return new CurrencyFormat(*this);
49}
50
51UnicodeString& CurrencyFormat::format(const Formattable& obj,
52 UnicodeString& appendTo,
53 FieldPosition& pos,
46f4442e
A
54 UErrorCode& ec) const
55{
374ca955
A
56 return fmt->format(obj, appendTo, pos, ec);
57}
58
374ca955
A
59void CurrencyFormat::parseObject(const UnicodeString& source,
60 Formattable& result,
46f4442e
A
61 ParsePosition& pos) const
62{
374ca955
A
63 fmt->parseCurrency(source, result, pos);
64}
65
374ca955
A
66UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyFormat)
67
68U_NAMESPACE_END
69
70#endif /* #if !UCONFIG_NO_FORMATTING */