| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/android/address_parser.h" | 5 #include "content/common/android/address_parser.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "content/common/android/address_parser_internal.h" | 9 #include "content/common/android/address_parser_internal.h" |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 size_t* start_pos, | 62 size_t* start_pos, |
| 63 size_t* end_pos) { | 63 size_t* end_pos) { |
| 64 HouseNumberParser house_number_parser; | 64 HouseNumberParser house_number_parser; |
| 65 | 65 |
| 66 // Keep going through the input string until a potential house number is | 66 // Keep going through the input string until a potential house number is |
| 67 // detected. Start tokenizing the following words to find a valid | 67 // detected. Start tokenizing the following words to find a valid |
| 68 // street name within a word range. Then, find a state name followed | 68 // street name within a word range. Then, find a state name followed |
| 69 // by a valid zip code for that state. Also keep a look for any other | 69 // by a valid zip code for that state. Also keep a look for any other |
| 70 // possible house numbers to continue from in case of no match and for | 70 // possible house numbers to continue from in case of no match and for |
| 71 // state names not followed by a zip code (e.g. New York, NY 10000). | 71 // state names not followed by a zip code (e.g. New York, NY 10000). |
| 72 const string16 newline_delimiters = kNewlineDelimiters; | 72 const base::string16 newline_delimiters = kNewlineDelimiters; |
| 73 const string16 delimiters = kWhitespaceUTF16 + newline_delimiters; | 73 const base::string16 delimiters = base::kWhitespaceUTF16 + newline_delimiters; |
| 74 for (string16::const_iterator it = begin; it != end; ) { | 74 for (base::string16::const_iterator it = begin; it != end; ) { |
| 75 Word house_number; | 75 Word house_number; |
| 76 if (!house_number_parser.Parse(it, end, &house_number)) | 76 if (!house_number_parser.Parse(it, end, &house_number)) |
| 77 return false; | 77 return false; |
| 78 | 78 |
| 79 String16Tokenizer tokenizer(house_number.end, end, delimiters); | 79 String16Tokenizer tokenizer(house_number.end, end, delimiters); |
| 80 tokenizer.set_options(String16Tokenizer::RETURN_DELIMS); | 80 tokenizer.set_options(String16Tokenizer::RETURN_DELIMS); |
| 81 | 81 |
| 82 WordList words; | 82 WordList words; |
| 83 words.push_back(house_number); | 83 words.push_back(house_number); |
| 84 | 84 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 it = words[next_word].end; | 210 it = words[next_word].end; |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 return false; | 214 return false; |
| 215 } | 215 } |
| 216 | 216 |
| 217 } // namespace address_parser | 217 } // namespace address_parser |
| 218 | 218 |
| 219 } // namespace content | 219 } // namespace content |
| OLD | NEW |