| 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 // This module computes snippets of queries based on hits in the documents | 5 // This module computes snippets of queries based on hits in the documents |
| 6 // for display in history search results. | 6 // for display in history search results. |
| 7 | 7 |
| 8 #ifndef COMPONENTS_QUERY_PARSER_SNIPPET_H__ | 8 #ifndef COMPONENTS_QUERY_PARSER_SNIPPET_H__ |
| 9 #define COMPONENTS_QUERY_PARSER_SNIPPET_H__ | 9 #define COMPONENTS_QUERY_PARSER_SNIPPET_H__ |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 MatchPositions* match_positions); | 41 MatchPositions* match_positions); |
| 42 | 42 |
| 43 // Converts match positions as returned from ExtractMatchPositions to be in | 43 // Converts match positions as returned from ExtractMatchPositions to be in |
| 44 // terms of a UTF-16 2-byte code unit. | 44 // terms of a UTF-16 2-byte code unit. |
| 45 static void ConvertMatchPositionsToWide( | 45 static void ConvertMatchPositionsToWide( |
| 46 const std::string& utf8_string, | 46 const std::string& utf8_string, |
| 47 Snippet::MatchPositions* match_positions); | 47 Snippet::MatchPositions* match_positions); |
| 48 | 48 |
| 49 Snippet(); | 49 Snippet(); |
| 50 Snippet(const Snippet& other); | 50 Snippet(const Snippet& other); |
| 51 Snippet(Snippet&& other) noexcept; |
| 51 ~Snippet(); | 52 ~Snippet(); |
| 52 | 53 |
| 54 Snippet& operator=(const Snippet&); |
| 55 |
| 53 // Given |matches|, the match positions within |document|, compute the snippet | 56 // Given |matches|, the match positions within |document|, compute the snippet |
| 54 // for the document. | 57 // for the document. |
| 55 // Note that |document| is UTF-8 and the offsets in |matches| are byte | 58 // Note that |document| is UTF-8 and the offsets in |matches| are byte |
| 56 // offsets. | 59 // offsets. |
| 57 void ComputeSnippet(const MatchPositions& matches, | 60 void ComputeSnippet(const MatchPositions& matches, |
| 58 const std::string& document); | 61 const std::string& document); |
| 59 | 62 |
| 60 const base::string16& text() const { return text_; } | 63 const base::string16& text() const { return text_; } |
| 61 const MatchPositions& matches() const { return matches_; } | 64 const MatchPositions& matches() const { return matches_; } |
| 62 | 65 |
| 63 // Efficiently swaps the contents of this snippet with the other. | 66 // Efficiently swaps the contents of this snippet with the other. |
| 64 void Swap(Snippet* other); | 67 void Swap(Snippet* other); |
| 65 | 68 |
| 66 private: | 69 private: |
| 67 // The text of the snippet. | 70 // The text of the snippet. |
| 68 base::string16 text_; | 71 base::string16 text_; |
| 69 | 72 |
| 70 // The matches within text_. | 73 // The matches within text_. |
| 71 MatchPositions matches_; | 74 MatchPositions matches_; |
| 72 }; | 75 }; |
| 73 | 76 |
| 74 } // namespace query_parser | 77 } // namespace query_parser |
| 75 | 78 |
| 76 #endif // COMPONENTS_QUERY_PARSER_SNIPPET_H__ | 79 #endif // COMPONENTS_QUERY_PARSER_SNIPPET_H__ |
| OLD | NEW |