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