| 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 #ifndef CONTENT_COMMON_ANDROID_ADDRESS_PARSER_INTERNAL_H_ | 5 #ifndef ANDROID_WEBVIEW_NATIVE_ADDRESS_PARSER_INTERNAL_H_ |
| 6 #define CONTENT_COMMON_ANDROID_ADDRESS_PARSER_INTERNAL_H_ | 6 #define ANDROID_WEBVIEW_NATIVE_ADDRESS_PARSER_INTERNAL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/string_tokenizer.h" | 13 #include "base/strings/string_tokenizer.h" |
| 14 #include "content/common/content_export.h" | |
| 15 | 14 |
| 16 namespace content { | 15 namespace android_webview { |
| 17 | 16 |
| 18 namespace address_parser { | 17 namespace address_parser { |
| 19 | 18 |
| 20 // Internal classes and functions for address parsing. | 19 // Internal classes and functions for address parsing. |
| 21 namespace internal { | 20 namespace internal { |
| 22 | 21 |
| 23 // Exposed for tests. | 22 // Exposed for tests. |
| 24 struct CONTENT_EXPORT Word { | 23 struct Word { |
| 25 base::string16::const_iterator begin; | 24 base::string16::const_iterator begin; |
| 26 base::string16::const_iterator end; | 25 base::string16::const_iterator end; |
| 27 | 26 |
| 28 Word(); | 27 Word(); |
| 29 Word(const base::string16::const_iterator& begin, | 28 Word(const base::string16::const_iterator& begin, |
| 30 const base::string16::const_iterator& end); | 29 const base::string16::const_iterator& end); |
| 31 Word(const Word& other); | 30 Word(const Word& other); |
| 32 }; | 31 }; |
| 33 | 32 |
| 34 // Exposed for tests. | 33 // Exposed for tests. |
| 35 class CONTENT_EXPORT HouseNumberParser { | 34 class HouseNumberParser { |
| 36 public: | 35 public: |
| 37 HouseNumberParser(); | 36 HouseNumberParser(); |
| 38 | 37 |
| 39 bool Parse(const base::string16::const_iterator& begin, | 38 bool Parse(const base::string16::const_iterator& begin, |
| 40 const base::string16::const_iterator& end, | 39 const base::string16::const_iterator& end, |
| 41 Word* word); | 40 Word* word); |
| 42 | 41 |
| 43 private: | 42 private: |
| 44 static inline bool IsPreDelimiter(base::char16 character); | 43 static inline bool IsPreDelimiter(base::char16 character); |
| 45 static inline bool IsPostDelimiter(base::char16 character); | 44 static inline bool IsPostDelimiter(base::char16 character); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 64 size_t result_chars_; | 63 size_t result_chars_; |
| 65 | 64 |
| 66 DISALLOW_COPY_AND_ASSIGN(HouseNumberParser); | 65 DISALLOW_COPY_AND_ASSIGN(HouseNumberParser); |
| 67 }; | 66 }; |
| 68 | 67 |
| 69 typedef std::vector<Word> WordList; | 68 typedef std::vector<Word> WordList; |
| 70 typedef base::StringTokenizerT<base::string16, base::string16::const_iterator> | 69 typedef base::StringTokenizerT<base::string16, base::string16::const_iterator> |
| 71 String16Tokenizer; | 70 String16Tokenizer; |
| 72 | 71 |
| 73 // These are exposed for tests. | 72 // These are exposed for tests. |
| 74 CONTENT_EXPORT bool FindStateStartingInWord(WordList* words, | 73 bool FindStateStartingInWord(WordList* words, |
| 75 size_t state_first_word, | 74 size_t state_first_word, |
| 76 size_t* state_last_word, | 75 size_t* state_last_word, |
| 77 String16Tokenizer* tokenizer, | 76 String16Tokenizer* tokenizer, |
| 78 size_t* state_index); | 77 size_t* state_index); |
| 79 | 78 |
| 80 CONTENT_EXPORT bool IsValidLocationName(const Word& word); | 79 bool IsValidLocationName(const Word& word); |
| 81 CONTENT_EXPORT bool IsZipValid(const Word& word, size_t state_index); | 80 bool IsZipValid(const Word& word, size_t state_index); |
| 82 CONTENT_EXPORT bool IsZipValidForState(const Word& word, size_t state_index); | 81 bool IsZipValidForState(const Word& word, size_t state_index); |
| 83 | 82 |
| 84 } // namespace internal | 83 } // namespace internal |
| 85 | 84 |
| 86 } // namespace address_parser | 85 } // namespace address_parser |
| 87 | 86 |
| 88 } // namespace content | 87 } // namespace android_webview |
| 89 | 88 |
| 90 #endif // CONTENT_COMMON_ANDROID_ADDRESS_PARSER_INTERNAL_H_ | 89 #endif // ANDROID_WEBVIEW_NATIVE_ADDRESS_PARSER_INTERNAL_H_ |
| OLD | NEW |