OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 9 #pragma once |
10 | 10 |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 | 516 |
517 std::string ReplaceStringPlaceholders(const base::StringPiece& format_string, | 517 std::string ReplaceStringPlaceholders(const base::StringPiece& format_string, |
518 const std::vector<std::string>& subst, | 518 const std::vector<std::string>& subst, |
519 std::vector<size_t>* offsets); | 519 std::vector<size_t>* offsets); |
520 | 520 |
521 // Single-string shortcut for ReplaceStringHolders. |offset| may be NULL. | 521 // Single-string shortcut for ReplaceStringHolders. |offset| may be NULL. |
522 string16 ReplaceStringPlaceholders(const string16& format_string, | 522 string16 ReplaceStringPlaceholders(const string16& format_string, |
523 const string16& a, | 523 const string16& a, |
524 size_t* offset); | 524 size_t* offset); |
525 | 525 |
526 // If the size of |input| is more than |max_len|, this function returns true and | |
527 // |input| is shortened into |output| by removing chars in the middle (they are | |
528 // replaced with up to 3 dots, as size permits). | |
529 // Ex: ElideString(L"Hello", 10, &str) puts Hello in str and returns false. | |
530 // ElideString(L"Hello my name is Tom", 10, &str) puts "Hell...Tom" in str and | |
531 // returns true. | |
532 bool ElideString(const std::wstring& input, int max_len, std::wstring* output); | |
533 | |
534 // Returns true if the string passed in matches the pattern. The pattern | 526 // Returns true if the string passed in matches the pattern. The pattern |
535 // string can contain wildcards like * and ? | 527 // string can contain wildcards like * and ? |
536 // The backslash character (\) is an escape character for * and ? | 528 // The backslash character (\) is an escape character for * and ? |
537 // We limit the patterns to having a max of 16 * or ? characters. | 529 // We limit the patterns to having a max of 16 * or ? characters. |
538 // ? matches 0 or 1 character, while * matches 0 or more characters. | 530 // ? matches 0 or 1 character, while * matches 0 or more characters. |
539 bool MatchPattern(const base::StringPiece& string, | 531 bool MatchPattern(const base::StringPiece& string, |
540 const base::StringPiece& pattern); | 532 const base::StringPiece& pattern); |
541 bool MatchPattern(const string16& string, const string16& pattern); | 533 bool MatchPattern(const string16& string, const string16& pattern); |
542 | 534 |
543 // Hack to convert any char-like type to its unsigned counterpart. | 535 // Hack to convert any char-like type to its unsigned counterpart. |
(...skipping 19 matching lines...) Expand all Loading... |
563 #elif defined(WCHAR_T_IS_UTF32) | 555 #elif defined(WCHAR_T_IS_UTF32) |
564 typedef uint32 Unsigned; | 556 typedef uint32 Unsigned; |
565 #endif | 557 #endif |
566 }; | 558 }; |
567 template<> | 559 template<> |
568 struct ToUnsigned<short> { | 560 struct ToUnsigned<short> { |
569 typedef unsigned short Unsigned; | 561 typedef unsigned short Unsigned; |
570 }; | 562 }; |
571 | 563 |
572 #endif // BASE_STRING_UTIL_H_ | 564 #endif // BASE_STRING_UTIL_H_ |
OLD | NEW |