Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: content/common/android/address_parser_internal.h

Issue 10456007: [Android] Split the address parser from AddressDetector for WebView use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: transforming AddressParser into a namespace. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_COMMON_ADDRESS_PARSER_INTERNAL_H_
6 #define CONTENT_COMMON_ADDRESS_PARSER_INTERNAL_H_
7 #pragma once
8
9 #include <vector>
10
11 #include "base/string_tokenizer.h"
12
13 namespace content {
14
15 namespace address_parser {
16
17 // Internal classes and functions for address parsing.
18 namespace internal {
19
20 struct Word {
21 string16::const_iterator begin;
22 string16::const_iterator end;
23
24 Word() {}
25 Word(const string16::const_iterator& begin,
26 const string16::const_iterator& end);
27 };
28
29 class HouseNumberParser {
30 public:
31 HouseNumberParser() {}
32
33 bool Parse(const string16::const_iterator& begin,
34 const string16::const_iterator& end,
35 Word* word);
36
37 private:
38 static inline bool IsPreDelimiter(char16 character);
39 static inline bool IsPostDelimiter(char16 character);
40 inline void RestartOnNextDelimiter();
41
42 inline bool CheckFinished(Word* word) const;
43 inline void AcceptChars(size_t num_chars);
44 inline void SkipChars(size_t num_chars);
45 inline void ResetState();
46
47 // Iterators to the beginning, current position and ending of the string
48 // being currently parsed.
49 string16::const_iterator begin_;
50 string16::const_iterator it_;
51 string16::const_iterator end_;
52
53 // Number of digits found in the current result candidate.
54 size_t num_digits_;
55
56 // Number of characters previous to the current iterator that belong
57 // to the current result candidate.
58 size_t result_chars_;
59
60 DISALLOW_COPY_AND_ASSIGN(HouseNumberParser);
61 };
62
63 typedef std::vector<Word> WordList;
64 typedef StringTokenizerT<string16, string16::const_iterator>
65 String16Tokenizer;
66
67 bool FindStateStartingInWord(WordList* words,
68 size_t state_first_word,
69 size_t* state_last_word,
70 String16Tokenizer* tokenizer,
71 size_t* state_index);
72
73 bool IsValidLocationName(const Word& word);
74 bool IsZipValid(const Word& word, size_t state_index);
75 bool IsZipValidForState(const Word& word, size_t state_index);
76
77 } // namespace internal
78
79 } // namespace address_parser
80
81 } // namespace content
82
83 #endif // CONTENT_COMMON_ADDRESS_PARSER_INTERNAL_H_
OLDNEW
« no previous file with comments | « content/common/android/address_parser.cc ('k') | content/common/android/address_parser_internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698