diff options
author | jshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 05:12:29 +0000 |
---|---|---|
committer | jshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 05:12:29 +0000 |
commit | b5b2385af64eb08b1feb53fb0ad65c835f472912 (patch) | |
tree | 6af57cd4a4965cebe2107e07ca8e563444c3afe9 /chrome/common/time_format.cc | |
parent | 80d6524d33061e0e4f7b06dd87ee94de3e05c7a8 (diff) | |
download | chromium_src-b5b2385af64eb08b1feb53fb0ad65c835f472912.zip chromium_src-b5b2385af64eb08b1feb53fb0ad65c835f472912.tar.gz chromium_src-b5b2385af64eb08b1feb53fb0ad65c835f472912.tar.bz2 |
Use 'icu::' namespace explicitly throughout Chrome tree instead of relying on 'using namespace icu'.
This is Chrome's counterpart to the ICU header change that disables
'using namespace icu' (http://codereview.chromium.org/171010/show), which is required to avoid the name colission between Chrome's StringPiece (in base) and ICU's StringPiece.
The webkit change (which is minor) will be dealt with in the webkit bugzilla.
This can go in before the ICU change/upgrade without affecting anything.
BUG=8198
TEST=All the targets are built without an error on all platforms.
Review URL: http://codereview.chromium.org/171012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23613 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/time_format.cc')
-rw-r--r-- | chrome/common/time_format.cc | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/chrome/common/time_format.cc b/chrome/common/time_format.cc index 80fe242b..a692218 100644 --- a/chrome/common/time_format.cc +++ b/chrome/common/time_format.cc @@ -113,7 +113,7 @@ enum FormatType { class TimeFormatter { public: - const std::vector<PluralFormat*>& formatter(FormatType format_type) { + const std::vector<icu::PluralFormat*>& formatter(FormatType format_type) { switch (format_type) { case FORMAT_SHORT: return short_formatter_; @@ -171,39 +171,38 @@ class TimeFormatter { friend class Singleton<TimeFormatter>; friend struct DefaultSingletonTraits<TimeFormatter>; - std::vector<PluralFormat*> short_formatter_; - std::vector<PluralFormat*> time_left_formatter_; - std::vector<PluralFormat*> time_elapsed_formatter_; + std::vector<icu::PluralFormat*> short_formatter_; + std::vector<icu::PluralFormat*> time_left_formatter_; + std::vector<icu::PluralFormat*> time_elapsed_formatter_; static void BuildFormats(FormatType format_type, - std::vector<PluralFormat*>* time_formats); - static PluralFormat* createFallbackFormat(const PluralRules& rules, - int index, - FormatType format_type); + std::vector<icu::PluralFormat*>* time_formats); + static icu::PluralFormat* createFallbackFormat( + const icu::PluralRules& rules, int index, FormatType format_type); DISALLOW_EVIL_CONSTRUCTORS(TimeFormatter); }; -void TimeFormatter::BuildFormats(FormatType format_type, - std::vector<PluralFormat*>* time_formats) { - const static UnicodeString kKeywords[] = { +void TimeFormatter::BuildFormats( + FormatType format_type, std::vector<icu::PluralFormat*>* time_formats) { + static const icu::UnicodeString kKeywords[] = { UNICODE_STRING_SIMPLE("other"), UNICODE_STRING_SIMPLE("one"), UNICODE_STRING_SIMPLE("zero"), UNICODE_STRING_SIMPLE("two"), UNICODE_STRING_SIMPLE("few"), UNICODE_STRING_SIMPLE("many") }; UErrorCode err = U_ZERO_ERROR; - scoped_ptr<PluralRules> rules( - PluralRules::forLocale(Locale::getDefault(), err)); + scoped_ptr<icu::PluralRules> rules( + icu::PluralRules::forLocale(icu::Locale::getDefault(), err)); if (U_FAILURE(err)) { err = U_ZERO_ERROR; - UnicodeString fallback_rules("one: n is 1", -1, US_INV); - rules.reset(PluralRules::createRules(fallback_rules, err)); + icu::UnicodeString fallback_rules("one: n is 1", -1, US_INV); + rules.reset(icu::PluralRules::createRules(fallback_rules, err)); DCHECK(U_SUCCESS(err)); } const MessageIDs& message_ids = GetMessageIDs(format_type); for (int i = 0; i < 4; ++i) { - UnicodeString pattern; + icu::UnicodeString pattern; for (size_t j = 0; j < arraysize(kKeywords); ++j) { int msg_id = message_ids.ids[i][j]; std::string sub_pattern = WideToUTF8(l10n_util::GetString(msg_id)); @@ -216,11 +215,11 @@ void TimeFormatter::BuildFormats(FormatType format_type, (j == 0 || rules->isKeyword(kKeywords[j]))) { pattern += kKeywords[j]; pattern += UNICODE_STRING_SIMPLE("{"); - pattern += UnicodeString(sub_pattern.c_str(), "UTF-8"); + pattern += icu::UnicodeString(sub_pattern.c_str(), "UTF-8"); pattern += UNICODE_STRING_SIMPLE("}"); } } - PluralFormat* format = new PluralFormat(*rules, pattern, err); + icu::PluralFormat* format = new icu::PluralFormat(*rules, pattern, err); if (U_SUCCESS(err)) { time_formats->push_back(format); } else { @@ -234,23 +233,22 @@ void TimeFormatter::BuildFormats(FormatType format_type, // Create a hard-coded fallback plural format. This will never be called // unless translators make a mistake. -PluralFormat* TimeFormatter::createFallbackFormat(const PluralRules& rules, - int index, - FormatType format_type) { - const static UnicodeString kUnits[4][2] = { +icu::PluralFormat* TimeFormatter::createFallbackFormat( + const icu::PluralRules& rules, int index, FormatType format_type) { + static const icu::UnicodeString kUnits[4][2] = { { UNICODE_STRING_SIMPLE("sec"), UNICODE_STRING_SIMPLE("secs") }, { UNICODE_STRING_SIMPLE("min"), UNICODE_STRING_SIMPLE("mins") }, { UNICODE_STRING_SIMPLE("hour"), UNICODE_STRING_SIMPLE("hours") }, { UNICODE_STRING_SIMPLE("day"), UNICODE_STRING_SIMPLE("days") } }; - UnicodeString suffix(GetFallbackFormatSuffix(format_type), -1, US_INV); - UnicodeString pattern; + icu::UnicodeString suffix(GetFallbackFormatSuffix(format_type), -1, US_INV); + icu::UnicodeString pattern; if (rules.isKeyword(UNICODE_STRING_SIMPLE("one"))) { pattern += UNICODE_STRING_SIMPLE("one{# ") + kUnits[index][0] + suffix; } pattern += UNICODE_STRING_SIMPLE(" other{# ") + kUnits[index][1] + suffix; UErrorCode err = U_ZERO_ERROR; - PluralFormat* format = new PluralFormat(rules, pattern, err); + icu::PluralFormat* format = new icu::PluralFormat(rules, pattern, err); DCHECK(U_SUCCESS(err)); return format; } @@ -266,11 +264,11 @@ static std::wstring FormatTimeImpl(const TimeDelta& delta, int number; - const std::vector<PluralFormat*>& formatters = + const std::vector<icu::PluralFormat*>& formatters = time_formatter->formatter(format_type); UErrorCode error = U_ZERO_ERROR; - UnicodeString time_string; + icu::UnicodeString time_string; // Less than a minute gets "X seconds left" if (delta.ToInternalValue() < Time::kMicrosecondsPerMinute) { number = static_cast<int>(delta.ToInternalValue() / |