]>
Commit | Line | Data |
---|---|---|
374ca955 A |
1 | /* |
2 | ********************************************************************** | |
3 | * Copyright (c) 2004, 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 "unicode/utypes.h" | |
12 | ||
13 | #if !UCONFIG_NO_FORMATTING | |
14 | ||
15 | #include "currfmt.h" | |
16 | #include "unicode/numfmt.h" | |
17 | ||
18 | U_NAMESPACE_BEGIN | |
19 | ||
20 | CurrencyFormat::CurrencyFormat(const Locale& locale, UErrorCode& ec) : | |
21 | fmt(NULL) { | |
22 | fmt = NumberFormat::createCurrencyInstance(locale, ec); | |
23 | } | |
24 | ||
25 | CurrencyFormat::CurrencyFormat(const CurrencyFormat& other) : | |
26 | MeasureFormat(other), fmt(NULL) { | |
27 | fmt = (NumberFormat*) other.fmt->clone(); | |
28 | } | |
29 | ||
30 | CurrencyFormat::~CurrencyFormat() { | |
31 | delete fmt; | |
32 | } | |
33 | ||
34 | UBool CurrencyFormat::operator==(const Format& other) const { | |
35 | if (this == &other) { | |
36 | return TRUE; | |
37 | } | |
38 | if (other.getDynamicClassID() != CurrencyFormat::getStaticClassID()) { | |
39 | return FALSE; | |
40 | } | |
41 | const CurrencyFormat* c = (const CurrencyFormat*) &other; | |
42 | return *fmt == *c->fmt; | |
43 | } | |
44 | ||
45 | Format* CurrencyFormat::clone() const { | |
46 | return new CurrencyFormat(*this); | |
47 | } | |
48 | ||
49 | UnicodeString& CurrencyFormat::format(const Formattable& obj, | |
50 | UnicodeString& appendTo, | |
51 | FieldPosition& pos, | |
52 | UErrorCode& ec) const { | |
53 | return fmt->format(obj, appendTo, pos, ec); | |
54 | } | |
55 | ||
56 | UnicodeString& CurrencyFormat::format(const Formattable& obj, | |
57 | UnicodeString& appendTo, | |
58 | UErrorCode& ec) const { | |
59 | return MeasureFormat::format(obj, appendTo, ec); | |
60 | } | |
61 | ||
62 | void CurrencyFormat::parseObject(const UnicodeString& source, | |
63 | Formattable& result, | |
64 | ParsePosition& pos) const { | |
65 | fmt->parseCurrency(source, result, pos); | |
66 | } | |
67 | ||
68 | void CurrencyFormat::parseObject(const UnicodeString& source, | |
69 | Formattable& result, | |
70 | UErrorCode& ec) const { | |
71 | MeasureFormat::parseObject(source, result, ec); | |
72 | } | |
73 | ||
74 | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyFormat) | |
75 | ||
76 | U_NAMESPACE_END | |
77 | ||
78 | #endif /* #if !UCONFIG_NO_FORMATTING */ |