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

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

Issue 110533002: [rac] Temporarily copy libaddressinput to Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Avoid redefinition of basictypes.h Created 7 years 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/rule.h
diff --git a/third_party/libaddressinput/chromium/cpp/src/rule.h b/third_party/libaddressinput/chromium/cpp/src/rule.h
new file mode 100644
index 0000000000000000000000000000000000000000..b420777cc81f4f973919e8e29da95205ce46d242
--- /dev/null
+++ b/third_party/libaddressinput/chromium/cpp/src/rule.h
@@ -0,0 +1,71 @@
+// Copyright (C) 2013 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// An object to store validation rules.
+
+#ifndef I18N_ADDRESSINPUT_RULE_H_
+#define I18N_ADDRESSINPUT_RULE_H_
+
+#include <libaddressinput/address_field.h>
+#include <libaddressinput/util/basictypes.h>
+
+#include <string>
+#include <vector>
+
+namespace i18n {
+namespace addressinput {
+
+// Stores the validation rules. Sample usage:
+// Rule rule;
+// if (rule.ParseSerializedRule("{\"fmt\": \"%A%n%C%S %Z\"}")) {
+// Process(rule.GetFormat());
+// }
+class Rule {
+ public:
+ Rule();
+ ~Rule();
+
+ // Copies all data from |rule|.
+ void CopyFrom(const Rule& rule);
+
+ // Parses |serialized_rule|. Returns |true| if the |serialized_rule| has valid
+ // format (JSON dictionary).
+ bool ParseSerializedRule(const std::string& serialized_rule);
+
+ // Returns the address format for this rule. The format can include the
+ // NEWLINE extension for AddressField enum.
+ const std::vector<AddressField>& GetFormat() const { return format_; }
+
+ // The message string identifier for admin area name. If not set, then
+ // INVALID_MESSAGE_ID.
+ int GetAdminAreaNameMessageId() const { return admin_area_name_message_id_; }
+
+ // The message string identifier for postal code name. If not set, then
+ // INVALID_MESSAGE_ID.
+ int GetPostalCodeNameMessageId() const {
+ return postal_code_name_message_id_;
+ }
+
+ private:
+ std::vector<AddressField> format_;
+ int admin_area_name_message_id_;
+ int postal_code_name_message_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(Rule);
+};
+
+} // namespace addressinput
+} // namespace i18n
+
+#endif // I18N_ADDRESSINPUT_RULE_H_
« no previous file with comments | « third_party/libaddressinput/chromium/cpp/src/retriever.cc ('k') | third_party/libaddressinput/chromium/cpp/src/rule.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698