search_metadata.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (c) 2013 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. #ifndef COMPONENTS_DRIVE_CHROMEOS_SEARCH_METADATA_H_
  5. #define COMPONENTS_DRIVE_CHROMEOS_SEARCH_METADATA_H_
  6. #include <string>
  7. #include <vector>
  8. namespace base {
  9. namespace i18n {
  10. class FixedPatternStringSearchIgnoringCaseAndAccents;
  11. } // namespace i18n
  12. } // namespace base
  13. namespace drive {
  14. namespace internal {
  15. // Finds |queries| in |text| while ignoring cases or accents. Cases of non-ASCII
  16. // characters are also ignored; they are compared in the 'Primary Level' of
  17. // http://userguide.icu-project.org/collation/concepts.
  18. // Returns true if |queries| are found. |highlighted_text| will have the
  19. // original
  20. // text with matched portions highlighted with <b> tag (only the first match
  21. // is highlighted). Meta characters are escaped like &lt;. The original
  22. // contents of |highlighted_text| will be lost.
  23. bool FindAndHighlight(
  24. const std::string& text,
  25. const std::vector<std::unique_ptr<
  26. base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents>>& queries,
  27. std::string* highlighted_text);
  28. } // namespace internal
  29. } // namespace drive
  30. #endif // COMPONENTS_DRIVE_CHROMEOS_SEARCH_METADATA_H_