1*635a8641SAndroid Build Coastguard Worker // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file. 4*635a8641SAndroid Build Coastguard Worker 5*635a8641SAndroid Build Coastguard Worker #ifndef BASE_I18N_STRING_SEARCH_H_ 6*635a8641SAndroid Build Coastguard Worker #define BASE_I18N_STRING_SEARCH_H_ 7*635a8641SAndroid Build Coastguard Worker 8*635a8641SAndroid Build Coastguard Worker #include <stddef.h> 9*635a8641SAndroid Build Coastguard Worker 10*635a8641SAndroid Build Coastguard Worker #include "base/i18n/base_i18n_export.h" 11*635a8641SAndroid Build Coastguard Worker #include "base/strings/string16.h" 12*635a8641SAndroid Build Coastguard Worker 13*635a8641SAndroid Build Coastguard Worker struct UStringSearch; 14*635a8641SAndroid Build Coastguard Worker 15*635a8641SAndroid Build Coastguard Worker namespace base { 16*635a8641SAndroid Build Coastguard Worker namespace i18n { 17*635a8641SAndroid Build Coastguard Worker 18*635a8641SAndroid Build Coastguard Worker // Returns true if |in_this| contains |find_this|. If |match_index| or 19*635a8641SAndroid Build Coastguard Worker // |match_length| are non-NULL, they are assigned the start position and total 20*635a8641SAndroid Build Coastguard Worker // length of the match. 21*635a8641SAndroid Build Coastguard Worker // 22*635a8641SAndroid Build Coastguard Worker // Only differences between base letters are taken into consideration. Case and 23*635a8641SAndroid Build Coastguard Worker // accent differences are ignored. Please refer to 'primary level' in 24*635a8641SAndroid Build Coastguard Worker // http://userguide.icu-project.org/collation/concepts for additional details. 25*635a8641SAndroid Build Coastguard Worker BASE_I18N_EXPORT 26*635a8641SAndroid Build Coastguard Worker bool StringSearchIgnoringCaseAndAccents(const string16& find_this, 27*635a8641SAndroid Build Coastguard Worker const string16& in_this, 28*635a8641SAndroid Build Coastguard Worker size_t* match_index, 29*635a8641SAndroid Build Coastguard Worker size_t* match_length); 30*635a8641SAndroid Build Coastguard Worker 31*635a8641SAndroid Build Coastguard Worker // This class is for speeding up multiple StringSearchIgnoringCaseAndAccents() 32*635a8641SAndroid Build Coastguard Worker // with the same |find_this| argument. |find_this| is passed as the constructor 33*635a8641SAndroid Build Coastguard Worker // argument, and precomputation for searching is done only at that timing. 34*635a8641SAndroid Build Coastguard Worker class BASE_I18N_EXPORT FixedPatternStringSearchIgnoringCaseAndAccents { 35*635a8641SAndroid Build Coastguard Worker public: 36*635a8641SAndroid Build Coastguard Worker explicit FixedPatternStringSearchIgnoringCaseAndAccents( 37*635a8641SAndroid Build Coastguard Worker const string16& find_this); 38*635a8641SAndroid Build Coastguard Worker ~FixedPatternStringSearchIgnoringCaseAndAccents(); 39*635a8641SAndroid Build Coastguard Worker 40*635a8641SAndroid Build Coastguard Worker // Returns true if |in_this| contains |find_this|. If |match_index| or 41*635a8641SAndroid Build Coastguard Worker // |match_length| are non-NULL, they are assigned the start position and total 42*635a8641SAndroid Build Coastguard Worker // length of the match. 43*635a8641SAndroid Build Coastguard Worker bool Search(const string16& in_this, 44*635a8641SAndroid Build Coastguard Worker size_t* match_index, 45*635a8641SAndroid Build Coastguard Worker size_t* match_length); 46*635a8641SAndroid Build Coastguard Worker 47*635a8641SAndroid Build Coastguard Worker private: 48*635a8641SAndroid Build Coastguard Worker string16 find_this_; 49*635a8641SAndroid Build Coastguard Worker UStringSearch* search_; 50*635a8641SAndroid Build Coastguard Worker }; 51*635a8641SAndroid Build Coastguard Worker 52*635a8641SAndroid Build Coastguard Worker } // namespace i18n 53*635a8641SAndroid Build Coastguard Worker } // namespace base 54*635a8641SAndroid Build Coastguard Worker 55*635a8641SAndroid Build Coastguard Worker #endif // BASE_I18N_STRING_SEARCH_H_ 56