| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_HISTORY_QUERY_PARSER_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_QUERY_PARSER_H_ |
| 6 #define CHROME_BROWSER_HISTORY_QUERY_PARSER_H_ | 6 #define CHROME_BROWSER_HISTORY_QUERY_PARSER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // the number of words in this node. | 33 // the number of words in this node. |
| 34 virtual int AppendToSQLiteQuery(string16* query) const = 0; | 34 virtual int AppendToSQLiteQuery(string16* query) const = 0; |
| 35 | 35 |
| 36 // Return true if this is a QueryNodeWord, false if it's a QueryNodeList. | 36 // Return true if this is a QueryNodeWord, false if it's a QueryNodeList. |
| 37 virtual bool IsWord() const = 0; | 37 virtual bool IsWord() const = 0; |
| 38 | 38 |
| 39 // Returns true if this node matches |word|. If |exact| is true, the string | 39 // Returns true if this node matches |word|. If |exact| is true, the string |
| 40 // must exactly match. Otherwise, this uses a starts with comparison. | 40 // must exactly match. Otherwise, this uses a starts with comparison. |
| 41 virtual bool Matches(const string16& word, bool exact) const = 0; | 41 virtual bool Matches(const string16& word, bool exact) const = 0; |
| 42 | 42 |
| 43 // Returns true if this node matches at least one of the words in |words|. If | 43 // Returns true if this node matches at least one of the words in |words|. An |
| 44 // the node matches at least one word, an entry is added to |match_positions| | 44 // entry is added to |match_positions| for all matching words giving the |
| 45 // giving the matching region. | 45 // matching regions. |
| 46 virtual bool HasMatchIn(const std::vector<QueryWord>& words, | 46 virtual bool HasMatchIn(const std::vector<QueryWord>& words, |
| 47 Snippet::MatchPositions* match_positions) const = 0; | 47 Snippet::MatchPositions* match_positions) const = 0; |
| 48 | 48 |
| 49 // Appends the words that make up this node in |words|. | 49 // Appends the words that make up this node in |words|. |
| 50 virtual void AppendWords(std::vector<string16>* words) const = 0; | 50 virtual void AppendWords(std::vector<string16>* words) const = 0; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 // This class is used to parse queries entered into the history search into more | 53 // This class is used to parse queries entered into the history search into more |
| 54 // normalized queries that can be passed to the SQLite backend. | 54 // normalized queries that can be passed to the SQLite backend. |
| 55 class QueryParser { | 55 class QueryParser { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // This is invoked from both of the ParseQuery methods. | 92 // This is invoked from both of the ParseQuery methods. |
| 93 bool ParseQueryImpl(const string16& query, QueryNodeList* root); | 93 bool ParseQueryImpl(const string16& query, QueryNodeList* root); |
| 94 | 94 |
| 95 // Extracts the words from |text|, placing each word into |words|. | 95 // Extracts the words from |text|, placing each word into |words|. |
| 96 void ExtractQueryWords(const string16& text, std::vector<QueryWord>* words); | 96 void ExtractQueryWords(const string16& text, std::vector<QueryWord>* words); |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(QueryParser); | 98 DISALLOW_COPY_AND_ASSIGN(QueryParser); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 #endif // CHROME_BROWSER_HISTORY_QUERY_PARSER_H_ | 101 #endif // CHROME_BROWSER_HISTORY_QUERY_PARSER_H_ |
| OLD | NEW |