OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * Copyright (C) 2007-2010, International Business Machines Corporation and | 3 * Copyright (C) 2007-2010, International Business Machines Corporation and |
4 * others. All Rights Reserved. | 4 * others. All Rights Reserved. |
5 ******************************************************************************* | 5 ******************************************************************************* |
6 */ | 6 */ |
7 | 7 |
8 #include <typeinfo> // for 'typeid' to work | |
9 | 8 |
10 #include "unicode/utypes.h" | 9 #include "unicode/utypes.h" |
11 | 10 |
12 #if !UCONFIG_NO_FORMATTING | 11 #if !UCONFIG_NO_FORMATTING |
13 | 12 |
14 #include "unicode/rbtz.h" | 13 #include "unicode/rbtz.h" |
15 #include "unicode/gregocal.h" | 14 #include "unicode/gregocal.h" |
16 #include "uvector.h" | 15 #include "uvector.h" |
17 #include "gregoimp.h" | 16 #include "gregoimp.h" |
18 #include "cmemory.h" | 17 #include "cmemory.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 fUpToDate = FALSE; | 82 fUpToDate = FALSE; |
84 } | 83 } |
85 return *this; | 84 return *this; |
86 } | 85 } |
87 | 86 |
88 UBool | 87 UBool |
89 RuleBasedTimeZone::operator==(const TimeZone& that) const { | 88 RuleBasedTimeZone::operator==(const TimeZone& that) const { |
90 if (this == &that) { | 89 if (this == &that) { |
91 return TRUE; | 90 return TRUE; |
92 } | 91 } |
93 if (typeid(*this) != typeid(that) | 92 if (CR_TYPEID(*this) != CR_TYPEID(that) |
94 || BasicTimeZone::operator==(that) == FALSE) { | 93 || BasicTimeZone::operator==(that) == FALSE) { |
95 return FALSE; | 94 return FALSE; |
96 } | 95 } |
97 RuleBasedTimeZone *rbtz = (RuleBasedTimeZone*)&that; | 96 RuleBasedTimeZone *rbtz = (RuleBasedTimeZone*)&that; |
98 if (*fInitialRule != *(rbtz->fInitialRule)) { | 97 if (*fInitialRule != *(rbtz->fInitialRule)) { |
99 return FALSE; | 98 return FALSE; |
100 } | 99 } |
101 if (compareRules(fHistoricRules, rbtz->fHistoricRules) | 100 if (compareRules(fHistoricRules, rbtz->fHistoricRules) |
102 && compareRules(fFinalRules, rbtz->fFinalRules)) { | 101 && compareRules(fFinalRules, rbtz->fFinalRules)) { |
103 return TRUE; | 102 return TRUE; |
104 } | 103 } |
105 return FALSE; | 104 return FALSE; |
106 } | 105 } |
107 | 106 |
108 UBool | 107 UBool |
109 RuleBasedTimeZone::operator!=(const TimeZone& that) const { | 108 RuleBasedTimeZone::operator!=(const TimeZone& that) const { |
110 return !operator==(that); | 109 return !operator==(that); |
111 } | 110 } |
112 | 111 |
113 void | 112 void |
114 RuleBasedTimeZone::addTransitionRule(TimeZoneRule* rule, UErrorCode& status) { | 113 RuleBasedTimeZone::addTransitionRule(TimeZoneRule* rule, UErrorCode& status) { |
115 if (U_FAILURE(status)) { | 114 if (U_FAILURE(status)) { |
116 return; | 115 return; |
117 } | 116 } |
118 AnnualTimeZoneRule* atzrule = dynamic_cast<AnnualTimeZoneRule*>(rule); | 117 AnnualTimeZoneRule* atzrule = CR_DYNAMIC_CAST<AnnualTimeZoneRule*>(rule); |
119 if (atzrule != NULL && atzrule->getEndYear() == AnnualTimeZoneRule::MAX_YEAR
) { | 118 if (atzrule != NULL && atzrule->getEndYear() == AnnualTimeZoneRule::MAX_YEAR
) { |
120 // A final rule | 119 // A final rule |
121 if (fFinalRules == NULL) { | 120 if (fFinalRules == NULL) { |
122 fFinalRules = new UVector(status); | 121 fFinalRules = new UVector(status); |
123 if (U_FAILURE(status)) { | 122 if (U_FAILURE(status)) { |
124 return; | 123 return; |
125 } | 124 } |
126 } else if (fFinalRules->size() >= 2) { | 125 } else if (fFinalRules->size() >= 2) { |
127 // Cannot handle more than two final rules | 126 // Cannot handle more than two final rules |
128 status = U_INVALID_STATE_ERROR; | 127 status = U_INVALID_STATE_ERROR; |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 return TRUE; | 500 return TRUE; |
502 } | 501 } |
503 return FALSE; | 502 return FALSE; |
504 } | 503 } |
505 | 504 |
506 UBool | 505 UBool |
507 RuleBasedTimeZone::hasSameRules(const TimeZone& other) const { | 506 RuleBasedTimeZone::hasSameRules(const TimeZone& other) const { |
508 if (this == &other) { | 507 if (this == &other) { |
509 return TRUE; | 508 return TRUE; |
510 } | 509 } |
511 if (typeid(*this) != typeid(other)) { | 510 if (CR_TYPEID(*this) != CR_TYPEID(other)) { |
512 return FALSE; | 511 return FALSE; |
513 } | 512 } |
514 const RuleBasedTimeZone& that = (const RuleBasedTimeZone&)other; | 513 const RuleBasedTimeZone& that = (const RuleBasedTimeZone&)other; |
515 if (*fInitialRule != *(that.fInitialRule)) { | 514 if (*fInitialRule != *(that.fInitialRule)) { |
516 return FALSE; | 515 return FALSE; |
517 } | 516 } |
518 if (compareRules(fHistoricRules, that.fHistoricRules) | 517 if (compareRules(fHistoricRules, that.fHistoricRules) |
519 && compareRules(fFinalRules, that.fFinalRules)) { | 518 && compareRules(fFinalRules, that.fFinalRules)) { |
520 return TRUE; | 519 return TRUE; |
521 } | 520 } |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 } | 924 } |
926 return delta; | 925 return delta; |
927 } | 926 } |
928 | 927 |
929 U_NAMESPACE_END | 928 U_NAMESPACE_END |
930 | 929 |
931 #endif /* #if !UCONFIG_NO_FORMATTING */ | 930 #endif /* #if !UCONFIG_NO_FORMATTING */ |
932 | 931 |
933 //eof | 932 //eof |
934 | 933 |
OLD | NEW |