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 | 9 |
10 #include <stdarg.h> // va_list | 10 #include <stdarg.h> // va_list |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 } | 523 } |
524 }; | 524 }; |
525 | 525 |
526 template<typename Char> struct CaseInsensitiveCompareASCII { | 526 template<typename Char> struct CaseInsensitiveCompareASCII { |
527 public: | 527 public: |
528 bool operator()(Char x, Char y) const { | 528 bool operator()(Char x, Char y) const { |
529 return ToLowerASCII(x) == ToLowerASCII(y); | 529 return ToLowerASCII(x) == ToLowerASCII(y); |
530 } | 530 } |
531 }; | 531 }; |
532 | 532 |
| 533 // TODO(timsteele): Move these split string functions into their own API on |
| 534 // string_split.cc/.h files. |
533 //----------------------------------------------------------------------------- | 535 //----------------------------------------------------------------------------- |
534 | 536 |
535 // Splits |str| into a vector of strings delimited by |s|. Append the results | 537 // Splits |str| into a vector of strings delimited by |s|. Append the results |
536 // into |r| as they appear. If several instances of |s| are contiguous, or if | 538 // into |r| as they appear. If several instances of |s| are contiguous, or if |
537 // |str| begins with or ends with |s|, then an empty string is inserted. | 539 // |str| begins with or ends with |s|, then an empty string is inserted. |
538 // | 540 // |
539 // Every substring is trimmed of any leading or trailing white space. | 541 // Every substring is trimmed of any leading or trailing white space. |
540 void SplitString(const std::wstring& str, | 542 void SplitString(const std::wstring& str, |
541 wchar_t s, | 543 wchar_t s, |
542 std::vector<std::wstring>* r); | 544 std::vector<std::wstring>* r); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 #elif defined(WCHAR_T_IS_UTF32) | 656 #elif defined(WCHAR_T_IS_UTF32) |
655 typedef uint32 Unsigned; | 657 typedef uint32 Unsigned; |
656 #endif | 658 #endif |
657 }; | 659 }; |
658 template<> | 660 template<> |
659 struct ToUnsigned<short> { | 661 struct ToUnsigned<short> { |
660 typedef unsigned short Unsigned; | 662 typedef unsigned short Unsigned; |
661 }; | 663 }; |
662 | 664 |
663 #endif // BASE_STRING_UTIL_H_ | 665 #endif // BASE_STRING_UTIL_H_ |
OLD | NEW |