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