• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2014 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // Utility functions for formatting the addresses represented as AddressData.
16 //
17 // Note these work best if the address has a language code specified - this can
18 // be obtained when building the UI components (calling BuildComponents on
19 // address_ui.h).
20 
21 #ifndef I18N_ADDRESSINPUT_ADDRESS_FORMATTER_H_
22 #define I18N_ADDRESSINPUT_ADDRESS_FORMATTER_H_
23 
24 #include <string>
25 #include <vector>
26 
27 namespace i18n {
28 namespace addressinput {
29 
30 struct AddressData;
31 
32 // Formats the address onto multiple lines. This formats the address in national
33 // format; without the country.
34 void GetFormattedNationalAddress(
35     const AddressData& address_data, std::vector<std::string>* lines);
36 
37 // Formats the address as a single line. This formats the address in national
38 // format; without the country.
39 void GetFormattedNationalAddressLine(
40     const AddressData& address_data, std::string* line);
41 
42 // Formats the street-level part of an address as a single line. For example,
43 // two lines of "Apt 1", "10 Red St." will be concatenated in a
44 // language-appropriate way, to give something like "Apt 1, 10 Red St".
45 void GetStreetAddressLinesAsSingleLine(
46     const AddressData& address_data, std::string* line);
47 
48 }  // namespace addressinput
49 }  // namespace i18n
50 
51 #endif  // I18N_ADDRESSINPUT_ADDRESS_FORMATTER_H_
52