| OLD | NEW |
| 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 #include <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "chrome/browser/history/query_parser.h" | 7 #include "chrome/browser/history/query_parser.h" |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/i18n/word_iterator.h" | 10 #include "base/i18n/word_iterator.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 // Inheritance structure: | 61 // Inheritance structure: |
| 62 // Queries are represented as trees of QueryNodes. | 62 // Queries are represented as trees of QueryNodes. |
| 63 // QueryNodes are either a collection of subnodes (a QueryNodeList) | 63 // QueryNodes are either a collection of subnodes (a QueryNodeList) |
| 64 // or a single word (a QueryNodeWord). | 64 // or a single word (a QueryNodeWord). |
| 65 | 65 |
| 66 // A QueryNodeWord is a single word in the query. | 66 // A QueryNodeWord is a single word in the query. |
| 67 class QueryNodeWord : public QueryNode { | 67 class QueryNodeWord : public QueryNode { |
| 68 public: | 68 public: |
| 69 QueryNodeWord(const std::wstring& word) : word_(word), literal_(false) {} | 69 explicit QueryNodeWord(const std::wstring& word) |
| 70 : word_(word), literal_(false) {} |
| 70 virtual ~QueryNodeWord() {} | 71 virtual ~QueryNodeWord() {} |
| 71 virtual int AppendToSQLiteQuery(std::wstring* query) const; | 72 virtual int AppendToSQLiteQuery(std::wstring* query) const; |
| 72 virtual bool IsWord() const { return true; } | 73 virtual bool IsWord() const { return true; } |
| 73 | 74 |
| 74 const std::wstring& word() const { return word_; } | 75 const std::wstring& word() const { return word_; } |
| 75 void set_literal(bool literal) { literal_ = literal; } | 76 void set_literal(bool literal) { literal_ = literal; } |
| 76 | 77 |
| 77 virtual bool HasMatchIn(const std::vector<QueryWord>& words, | 78 virtual bool HasMatchIn(const std::vector<QueryWord>& words, |
| 78 Snippet::MatchPositions* match_positions) const; | 79 Snippet::MatchPositions* match_positions) const; |
| 79 | 80 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 if (iter.IsWord()) { | 376 if (iter.IsWord()) { |
| 376 std::wstring word = iter.GetWord(); | 377 std::wstring word = iter.GetWord(); |
| 377 if (!word.empty()) { | 378 if (!word.empty()) { |
| 378 words->push_back(QueryWord()); | 379 words->push_back(QueryWord()); |
| 379 words->back().word = word; | 380 words->back().word = word; |
| 380 words->back().position = iter.prev(); | 381 words->back().position = iter.prev(); |
| 381 } | 382 } |
| 382 } | 383 } |
| 383 } | 384 } |
| 384 } | 385 } |
| OLD | NEW |