blob: 5bcab5e3897664d71cac1526082af98a20073cc2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_TITLE_MATCH_H_
#define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_TITLE_MATCH_H_
#include <cstddef>
#include <utility>
#include <vector>
namespace bookmarks {
class BookmarkNode;
struct BookmarkMatch {
// Each MatchPosition is the [begin, end) positions of a match within a
// string.
typedef std::pair<size_t, size_t> MatchPosition;
typedef std::vector<MatchPosition> MatchPositions;
BookmarkMatch();
~BookmarkMatch();
// Extracts and returns the offsets from |match_positions|.
static std::vector<size_t> OffsetsFromMatchPositions(
const MatchPositions& match_positions);
// Replaces the offsets in |match_positions| with those given in |offsets|,
// deleting any which are npos, and returns the updated list of match
// positions.
static MatchPositions ReplaceOffsetsInMatchPositions(
const MatchPositions& match_positions,
const std::vector<size_t>& offsets);
// The matching node of a query.
const BookmarkNode* node;
// Location of the matching words in the title of the node.
MatchPositions title_match_positions;
// Location of the matching words in the URL of the node.
MatchPositions url_match_positions;
};
} // namespace bookmarks
#endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_TITLE_MATCH_H_
|