1e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// Copyright (C) 2013 Google Inc. 2e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// 3e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// Licensed under the Apache License, Version 2.0 (the "License"); 4e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// you may not use this file except in compliance with the License. 5e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// You may obtain a copy of the License at 6e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// 7e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// http://www.apache.org/licenses/LICENSE-2.0 8e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// 9e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// Unless required by applicable law or agreed to in writing, software 10e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// distributed under the License is distributed on an "AS IS" BASIS, 11e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// See the License for the specific language governing permissions and 13e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// limitations under the License. 14e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org 15e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org#ifndef I18N_ADDRESSINPUT_ADDRESS_FIELD_UTIL_H_ 16e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org#define I18N_ADDRESSINPUT_ADDRESS_FIELD_UTIL_H_ 17e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org 18e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org#include <libaddressinput/address_field.h> 19e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org 20e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org#include <string> 21e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org#include <vector> 22e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org 23e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.orgnamespace i18n { 24e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.orgnamespace addressinput { 25e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org 269f47fe3ed525accac995b095d408a825673a2ee1roubert@google.comclass FormatElement; 279f47fe3ed525accac995b095d408a825673a2ee1roubert@google.com 28e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// Clears |fields|, parses |format|, and adds the format address fields to 29e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// |fields|. The |fields| may also contain NEWLINE elements. For example, parses 30e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// "%S%C%n%D%X" into {ADMIN_AREA, LOCALITY, NEWLINE, DEPENDENT_LOCALITY, 31e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org// SORTING_CODE}. 32c8efd308315b65f36c0d056e04dc98cb3d98f204lararennie@google.comvoid ParseFormatRule(const std::string& format, 33c8efd308315b65f36c0d056e04dc98cb3d98f204lararennie@google.com std::vector<FormatElement>* fields); 34e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org 35cddbcfaacf0a7fafb942ebc66e7d9b84faf7e5f8roubert@google.com// Clears |fields|, parses |required|, and adds the required fields to |fields|. 36cddbcfaacf0a7fafb942ebc66e7d9b84faf7e5f8roubert@google.com// For example, parses "SCDX" into {ADMIN_AREA, LOCALITY, DEPENDENT_LOCALITY, 37cddbcfaacf0a7fafb942ebc66e7d9b84faf7e5f8roubert@google.com// SORTING_CODE}. 38cddbcfaacf0a7fafb942ebc66e7d9b84faf7e5f8roubert@google.comvoid ParseAddressFieldsRequired(const std::string& required, 39cddbcfaacf0a7fafb942ebc66e7d9b84faf7e5f8roubert@google.com std::vector<AddressField>* fields); 40cddbcfaacf0a7fafb942ebc66e7d9b84faf7e5f8roubert@google.com 41e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org} // namespace addressinput 42e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org} // namespace i18n 43e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org 44e44b60b2f13cd40ca783937f0b1a418bd8510921rouslan@chromium.org#endif // I18N_ADDRESSINPUT_ADDRESS_FIELD_UTIL_H_ 45