OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_TITLE_MATCH_H_ | 5 #ifndef COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_TITLE_MATCH_H_ |
6 #define COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_TITLE_MATCH_H_ | 6 #define COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_TITLE_MATCH_H_ |
7 | 7 |
8 #include <stddef.h> | |
9 | |
10 #include <utility> | 8 #include <utility> |
11 #include <vector> | 9 #include <vector> |
12 | 10 |
13 class BookmarkNode; | 11 class BookmarkNode; |
14 | 12 |
15 struct BookmarkTitleMatch { | 13 struct BookmarkMatch { |
16 // Each MatchPosition is the [begin, end) positions of a match within a | 14 // Each MatchPosition is the [begin, end) positions of a match within a |
17 // string. | 15 // string. |
18 typedef std::pair<size_t, size_t> MatchPosition; | 16 typedef std::pair<size_t, size_t> MatchPosition; |
19 typedef std::vector<MatchPosition> MatchPositions; | 17 typedef std::vector<MatchPosition> MatchPositions; |
20 | 18 |
21 BookmarkTitleMatch(); | 19 BookmarkMatch(); |
22 ~BookmarkTitleMatch(); | 20 ~BookmarkMatch(); |
| 21 |
| 22 // Extracts and returns the offsets from |match_positions|. |
| 23 static std::vector<size_t> OffsetsFromMatchPositions( |
| 24 const MatchPositions& match_positions); |
| 25 |
| 26 // Replaces the offsets in |match_positions| with those given in |offsets|, |
| 27 // deleting any which are npos, and returns the updated list of match |
| 28 // positions. |
| 29 static MatchPositions ReplaceOffsetsInMatchPositions( |
| 30 const MatchPositions& match_positions, |
| 31 const std::vector<size_t>& offsets); |
23 | 32 |
24 // The matching node of a query. | 33 // The matching node of a query. |
25 const BookmarkNode* node; | 34 const BookmarkNode* node; |
26 | 35 |
27 // Location of the matching words in the title of the node. | 36 // Location of the matching words in the title of the node. |
28 MatchPositions match_positions; | 37 MatchPositions title_match_positions; |
| 38 |
| 39 // Location of the matching words in the URL of the node. |
| 40 MatchPositions url_match_positions; |
29 }; | 41 }; |
30 | 42 |
31 #endif // COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_TITLE_MATCH_H_ | 43 #endif // COMPONENTS_BOOKMARKS_CORE_BROWSER_BOOKMARK_TITLE_MATCH_H_ |
OLD | NEW |