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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 // replaced with up to 3 dots, as size permits). | 551 // replaced with up to 3 dots, as size permits). |
552 // Ex: ElideString(L"Hello", 10, &str) puts Hello in str and returns false. | 552 // Ex: ElideString(L"Hello", 10, &str) puts Hello in str and returns false. |
553 // ElideString(L"Hello my name is Tom", 10, &str) puts "Hell...Tom" in str and | 553 // ElideString(L"Hello my name is Tom", 10, &str) puts "Hell...Tom" in str and |
554 // returns true. | 554 // returns true. |
555 bool ElideString(const std::wstring& input, int max_len, std::wstring* output); | 555 bool ElideString(const std::wstring& input, int max_len, std::wstring* output); |
556 | 556 |
557 // Returns true if the string passed in matches the pattern. The pattern | 557 // Returns true if the string passed in matches the pattern. The pattern |
558 // string can contain wildcards like * and ? | 558 // string can contain wildcards like * and ? |
559 // The backslash character (\) is an escape character for * and ? | 559 // The backslash character (\) is an escape character for * and ? |
560 // We limit the patterns to having a max of 16 * or ? characters. | 560 // We limit the patterns to having a max of 16 * or ? characters. |
561 bool MatchPattern(const std::string& string, const std::string& pattern); | 561 bool MatchPattern(const base::StringPiece& string, |
| 562 const base::StringPiece& pattern); |
562 bool MatchPattern(const string16& string, const string16& pattern); | 563 bool MatchPattern(const string16& string, const string16& pattern); |
563 | 564 |
564 // Hack to convert any char-like type to its unsigned counterpart. | 565 // Hack to convert any char-like type to its unsigned counterpart. |
565 // For example, it will convert char, signed char and unsigned char to unsigned | 566 // For example, it will convert char, signed char and unsigned char to unsigned |
566 // char. | 567 // char. |
567 template<typename T> | 568 template<typename T> |
568 struct ToUnsigned { | 569 struct ToUnsigned { |
569 typedef T Unsigned; | 570 typedef T Unsigned; |
570 }; | 571 }; |
571 | 572 |
(...skipping 12 matching lines...) Expand all Loading... |
584 #elif defined(WCHAR_T_IS_UTF32) | 585 #elif defined(WCHAR_T_IS_UTF32) |
585 typedef uint32 Unsigned; | 586 typedef uint32 Unsigned; |
586 #endif | 587 #endif |
587 }; | 588 }; |
588 template<> | 589 template<> |
589 struct ToUnsigned<short> { | 590 struct ToUnsigned<short> { |
590 typedef unsigned short Unsigned; | 591 typedef unsigned short Unsigned; |
591 }; | 592 }; |
592 | 593 |
593 #endif // BASE_STRING_UTIL_H_ | 594 #endif // BASE_STRING_UTIL_H_ |
OLD | NEW |