Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Unified Diff: third_party/libaddressinput/chromium/cpp/src/ruleset.h

Issue 116363003: [rac] Validate an address. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/libaddressinput/chromium/cpp/src/ruleset.h
diff --git a/third_party/libaddressinput/chromium/cpp/src/ruleset.h b/third_party/libaddressinput/chromium/cpp/src/ruleset.h
index b9fdb33a56dbf42ec55933382c57fe07ac37ed17..ca0ce1c87af3be905aae9ef0ecb8aa572b464bd2 100644
--- a/third_party/libaddressinput/chromium/cpp/src/ruleset.h
+++ b/third_party/libaddressinput/chromium/cpp/src/ruleset.h
@@ -15,6 +15,7 @@
#ifndef I18N_ADDRESSINPUT_RULESET_H_
#define I18N_ADDRESSINPUT_RULESET_H_
+#include <libaddressinput/address_field.h>
#include <libaddressinput/util/basictypes.h>
#include <libaddressinput/util/scoped_ptr.h>
@@ -24,6 +25,7 @@
namespace i18n {
namespace addressinput {
+class AddressData;
class Rule;
// A recursive data structure that stores a set of rules for a region. Can store
@@ -58,14 +60,20 @@ class Ruleset {
// Adds a language-specific |rule| for |language_code| for this region.
void AddLanguageCode(const std::string& language_code, scoped_ptr<Rule> rule);
- // Returns the set of rules for |sub_region|. The result can be NULL. The
- // caller does not own the result.
+ // Returns the set of rules for |sub_region|. The result is NULL if there's no
+ // such |sub_region|. The caller does not own the result.
Ruleset* GetSubRegion(const std::string& sub_region) const;
- // Returns the language-specific rule for |language_code|. The result can be
- // NULL. The caller does not own the result.
+ // Returns the language-specific rule for |language_code|. The result is NULL
+ // if there's no such |language_code|. The caller does not own the result.
const Rule* GetLanguageCode(const std::string& language_code) const;
+ // Returns a mapping of field types to validation rules based on the field
+ // values in |address|. Should be invoked only on a root ruleset (at country
+ // level).
+ std::map<AddressField, const Rule*> BuildRulesForAddress(
+ const AddressData& address) const;
+
private:
// The region-wide rule in the default language of the country.
scoped_ptr<const Rule> rule_;

Powered by Google App Engine
This is Rietveld 408576698