Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: chrome/browser/history/query_parser.h

Issue 13296: Adds QueryParser::ExtractQueryWords. For consistent this should... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/history/query_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // The query parser is used to parse queries entered into the history 5 // The query parser is used to parse queries entered into the history
6 // search into more normalized queries can be passed to the SQLite backend. 6 // search into more normalized queries can be passed to the SQLite backend.
7 7
8 #ifndef CHROME_BROWSER_HISTORY_QUERY_PARSER_H__ 8 #ifndef CHROME_BROWSER_HISTORY_QUERY_PARSER_H__
9 #define CHROME_BROWSER_HISTORY_QUERY_PARSER_H__ 9 #define CHROME_BROWSER_HISTORY_QUERY_PARSER_H__
10 10
(...skipping 30 matching lines...) Expand all
41 // Returns true if this node matches the specified text. If exact is true, 41 // Returns true if this node matches the specified text. If exact is true,
42 // the string must exactly match. Otherwise, this uses a starts with 42 // the string must exactly match. Otherwise, this uses a starts with
43 // comparison. 43 // comparison.
44 virtual bool Matches(const std::wstring& word, bool exact) const = 0; 44 virtual bool Matches(const std::wstring& word, bool exact) const = 0;
45 45
46 // Returns true if this node matches at least one of the words in words. If 46 // Returns true if this node matches at least one of the words in words. If
47 // the node matches at least one word, an entry is added to match_positions 47 // the node matches at least one word, an entry is added to match_positions
48 // giving the matching region. 48 // giving the matching region.
49 virtual bool HasMatchIn(const std::vector<QueryWord>& words, 49 virtual bool HasMatchIn(const std::vector<QueryWord>& words,
50 Snippet::MatchPositions* match_positions) const = 0; 50 Snippet::MatchPositions* match_positions) const = 0;
51
52 // Appends the words that make up this node in |words|.
53 virtual void AppendWords(std::vector<std::wstring>* words) const = 0;
51 }; 54 };
52 55
53 56
54 class QueryParser { 57 class QueryParser {
55 public: 58 public:
56 QueryParser(); 59 QueryParser();
57 60
58 // Parse a query into a SQLite query. The resulting query is placed in 61 // Parse a query into a SQLite query. The resulting query is placed in
59 // sqlite_query and the number of words is returned. 62 // sqlite_query and the number of words is returned.
60 int ParseQuery(const std::wstring& query, 63 int ParseQuery(const std::wstring& query,
61 std::wstring* sqlite_query); 64 std::wstring* sqlite_query);
62 65
63 // Parses the query words in query, returning the nodes that constitute the 66 // Parses the query words in query, returning the nodes that constitute the
64 // valid words in the query. This is intended for later usage with 67 // valid words in the query. This is intended for later usage with
65 // DoesQueryMatch. 68 // DoesQueryMatch.
66 // Ownership of the nodes passes to the caller. 69 // Ownership of the nodes passes to the caller.
67 void ParseQuery(const std::wstring& query, 70 void ParseQuery(const std::wstring& query,
68 std::vector<QueryNode*>* nodes); 71 std::vector<QueryNode*>* nodes);
69 72
73 // Parses a query returning the words that make up the query. Any words in
74 // quotes are put in |words| without the quotes. For example, the query text
75 // "foo bar" results in two entries being added to words, one for foo and one
76 // for bar.
77 void ExtractQueryWords(const std::wstring& query,
78 std::vector<std::wstring>* words);
79
70 // Returns true if the string text matches the query nodes created by a call 80 // Returns true if the string text matches the query nodes created by a call
71 // to ParseQuery. If the query does match each of the matching positions in 81 // to ParseQuery. If the query does match each of the matching positions in
72 // the text is added to |match_positions|. 82 // the text is added to |match_positions|.
73 bool DoesQueryMatch(const std::wstring& text, 83 bool DoesQueryMatch(const std::wstring& text,
74 const std::vector<QueryNode*>& nodes, 84 const std::vector<QueryNode*>& nodes,
75 Snippet::MatchPositions* match_positions); 85 Snippet::MatchPositions* match_positions);
76 86
77 private: 87 private:
78 // Does the work of parsing a query; creates nodes in QueryNodeList as 88 // Does the work of parsing a query; creates nodes in QueryNodeList as
79 // appropriate. This is invoked from both of the ParseQuery methods. 89 // appropriate. This is invoked from both of the ParseQuery methods.
80 bool ParseQueryImpl(const std::wstring& query, 90 bool ParseQueryImpl(const std::wstring& query,
81 QueryNodeList* root); 91 QueryNodeList* root);
82 92
83 // Extracts the words from text, placing each word into words. 93 // Extracts the words from text, placing each word into words.
84 void ExtractQueryWords(const std::wstring& text, 94 void ExtractQueryWords(const std::wstring& text,
85 std::vector<QueryWord>* words); 95 std::vector<QueryWord>* words);
86 }; 96 };
87 97
88 #endif // CHROME_BROWSER_HISTORY_QUERY_PARSER_H__ 98 #endif // CHROME_BROWSER_HISTORY_QUERY_PARSER_H__
89 99
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/query_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698