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 // This file defines utility functions for working with strings. | 5 // This file defines utility functions for working with strings. |
6 | 6 |
7 #ifndef BASE_STRING_UTIL_H_ | 7 #ifndef BASE_STRING_UTIL_H_ |
8 #define BASE_STRING_UTIL_H_ | 8 #define BASE_STRING_UTIL_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 const std::wstring& c, | 501 const std::wstring& c, |
502 std::vector<size_t>* offsets); | 502 std::vector<size_t>* offsets); |
503 | 503 |
504 std::wstring ReplaceStringPlaceholders(const std::wstring& format_string, | 504 std::wstring ReplaceStringPlaceholders(const std::wstring& format_string, |
505 const std::wstring& a, | 505 const std::wstring& a, |
506 const std::wstring& b, | 506 const std::wstring& b, |
507 const std::wstring& c, | 507 const std::wstring& c, |
508 const std::wstring& d, | 508 const std::wstring& d, |
509 std::vector<size_t>* offsets); | 509 std::vector<size_t>* offsets); |
510 | 510 |
| 511 // If the size of |input| is more than |max_len|, this function returns true and |
| 512 // |input| is shortened into |output| by removing chars in the middle (they are |
| 513 // replaced with up to 3 dots, as size permits). |
| 514 // Ex: ElideString(L"Hello", 10, &str) puts Hello in str and returns false. |
| 515 // ElideString(L"Hello my name is Tom", 10, &str) puts "Hell...Tom" in str and |
| 516 // returns true. |
| 517 bool ElideString(const std::wstring& input, int max_len, std::wstring* output); |
| 518 |
511 // Returns true if the string passed in matches the pattern. The pattern | 519 // Returns true if the string passed in matches the pattern. The pattern |
512 // string can contain wildcards like * and ? | 520 // string can contain wildcards like * and ? |
513 // TODO(iyengar) This function may not work correctly for CJK strings as | 521 // TODO(iyengar) This function may not work correctly for CJK strings as |
514 // it does individual character matches. | 522 // it does individual character matches. |
515 // The backslash character (\) is an escape character for * and ? | 523 // The backslash character (\) is an escape character for * and ? |
516 bool MatchPattern(const std::wstring& string, const std::wstring& pattern); | 524 bool MatchPattern(const std::wstring& string, const std::wstring& pattern); |
517 bool MatchPattern(const std::string& string, const std::string& pattern); | 525 bool MatchPattern(const std::string& string, const std::string& pattern); |
518 | 526 |
519 #endif // BASE_STRING_UTIL_H_ | 527 #endif // BASE_STRING_UTIL_H_ |
520 | 528 |
OLD | NEW |