Scroll in Android HTML Element accessibility navigation
[chromium-blink-merge.git] / ui / app_list / search / term_break_iterator.h
blobba9040bc2a5d203c14fe68176aa837b61468d00b
1 // Copyright 2013 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.
5 #ifndef UI_APP_LIST_SEARCH_TERM_BREAK_ITERATOR_H_
6 #define UI_APP_LIST_SEARCH_TERM_BREAK_ITERATOR_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string16.h"
11 #include "ui/app_list/app_list_export.h"
13 namespace base {
14 namespace i18n {
15 class UTF16CharIterator;
19 namespace app_list {
21 // TermBreakIterator breaks terms out of a word. Terms are broken on
22 // camel case boundaries and alpha/number boundaries. Numbers are defined
23 // as [0-9\.,]+.
24 // e.g.
25 // CamelCase -> Camel, Case
26 // Python2.7 -> Python, 2.7
27 class APP_LIST_EXPORT TermBreakIterator {
28 public:
29 // Note that |word| must out live this iterator.
30 explicit TermBreakIterator(const base::string16& word);
31 ~TermBreakIterator();
33 // Advance to the next term. Returns false if at the end of the word.
34 bool Advance();
36 // Returns the current term, which is the substr of |word_| in range
37 // [prev_, pos_).
38 const base::string16 GetCurrentTerm() const;
40 size_t prev() const { return prev_; }
41 size_t pos() const { return pos_; }
43 static const size_t npos = static_cast<size_t>(-1);
45 private:
46 enum State {
47 STATE_START, // Initial state
48 STATE_NUMBER, // Current char is a number [0-9\.,].
49 STATE_UPPER, // Current char is upper case.
50 STATE_LOWER, // Current char is lower case.
51 STATE_CHAR, // Current char has no case, e.g. a cjk char.
52 STATE_LAST,
55 // Returns new state for given |ch|.
56 State GetNewState(base::char16 ch);
58 const base::string16& word_;
59 size_t prev_;
60 size_t pos_;
62 scoped_ptr<base::i18n::UTF16CharIterator> iter_;
63 State state_;
65 DISALLOW_COPY_AND_ASSIGN(TermBreakIterator);
68 } // namespace app_list
70 #endif // UI_APP_LIST_SEARCH_TERM_BREAK_ITERATOR_H_