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