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