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.
4
5#ifndef UI_APP_LIST_SEARCH_TOKENIZED_STRING_H_
6#define UI_APP_LIST_SEARCH_TOKENIZED_STRING_H_
7
8#include <vector>
9
10#include "base/basictypes.h"
11#include "base/strings/string16.h"
12#include "ui/app_list/app_list_export.h"
13#include "ui/gfx/range/range.h"
14
15namespace app_list {
16
17// TokenizedString takes a string and breaks it down into token words. It
18// first breaks using BreakIterator to get all the words. Then it breaks
19// the words again at camel case boundaries and alpha/number boundaries.
20class APP_LIST_EXPORT TokenizedString {
21 public:
22  typedef std::vector<base::string16> Tokens;
23  typedef std::vector<gfx::Range> Mappings;
24
25  explicit TokenizedString(const base::string16& text);
26  ~TokenizedString();
27
28  const base::string16& text() const { return text_; }
29  const Tokens& tokens() const { return tokens_; }
30  const Mappings& mappings() const { return mappings_; }
31
32 private:
33  void Tokenize();
34
35  // Input text.
36  const base::string16 text_;
37
38  // Broken down tokens and the index mapping of tokens in original string.
39  Tokens tokens_;
40  Mappings mappings_;
41
42  DISALLOW_COPY_AND_ASSIGN(TokenizedString);
43};
44
45}  // namespace app_list
46
47#endif  // UI_APP_LIST_SEARCH_TOKENIZED_STRING_H_
48