Chromium Code Reviews| Index: third_party/libaddressinput/chromium/cpp/src/ruleset.cc |
| diff --git a/third_party/libaddressinput/chromium/cpp/src/ruleset.cc b/third_party/libaddressinput/chromium/cpp/src/ruleset.cc |
| index 9090279ca27399f6b7ae892ee56525359b75ab2f..72c1e1219de0cc4866759fb73af1e1b4b81c7ec9 100644 |
| --- a/third_party/libaddressinput/chromium/cpp/src/ruleset.cc |
| +++ b/third_party/libaddressinput/chromium/cpp/src/ruleset.cc |
| @@ -14,6 +14,8 @@ |
| #include "ruleset.h" |
| +#include <libaddressinput/address_data.h> |
| +#include <libaddressinput/address_field.h> |
| #include <libaddressinput/util/scoped_ptr.h> |
| #include <cassert> |
| @@ -68,5 +70,28 @@ const Rule* Ruleset::GetLanguageCode(const std::string& language_code) const { |
| return it == language_codes_.end() ? NULL : it->second; |
| } |
| +std::map<AddressField, const Rule*> Ruleset::BuildRulesForAddress( |
|
Evan Stade
2014/01/08 21:29:34
I don't really understand the purpose for this fun
please use gerrit instead
2014/01/09 19:42:00
Done.
|
| + const AddressData& address) const { |
| + std::map<AddressField, const Rule*> result; |
| + if (address.country_code.empty()) { |
| + result.insert(std::make_pair(COUNTRY, &Rule::GetDefault())); |
| + return result; |
| + } |
| + |
| + AddressField field = COUNTRY; |
| + for (const Ruleset* ruleset = this; |
| + ruleset != NULL && field <= DEPENDENT_LOCALITY; |
| + ruleset = ruleset->GetSubRegion(address.GetField(field))) { |
| + const Rule* language_specific = |
| + ruleset->GetLanguageCode(address.language_code); |
| + result.insert(std::make_pair( |
| + field, |
| + language_specific != NULL ? language_specific : &ruleset->rule())); |
| + field = static_cast<AddressField>(field + 1); |
| + } |
| + |
| + return result; |
| +} |
| + |
| } // namespace addressinput |
| } // namespace i18n |