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