Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: base/string_util.h

Issue 10255: Port some files in chrome/common to Linux.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/common.scons » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 template <class char_type> 432 template <class char_type>
433 inline char_type* WriteInto( 433 inline char_type* WriteInto(
434 std::basic_string<char_type, std::char_traits<char_type>, 434 std::basic_string<char_type, std::char_traits<char_type>,
435 std::allocator<char_type> >* str, 435 std::allocator<char_type> >* str,
436 size_t length_including_null) { 436 size_t length_including_null) {
437 str->reserve(length_including_null); 437 str->reserve(length_including_null);
438 str->resize(length_including_null - 1); 438 str->resize(length_including_null - 1);
439 return &((*str)[0]); 439 return &((*str)[0]);
440 } 440 }
441 441
442 inline char16* WriteInto(string16* str, size_t length_including_null) {
443 str->reserve(length_including_null);
444 str->resize(length_including_null - 1);
445 return &((*str)[0]);
446 }
447
442 //----------------------------------------------------------------------------- 448 //-----------------------------------------------------------------------------
443 449
444 // Function objects to aid in comparing/searching strings. 450 // Function objects to aid in comparing/searching strings.
445 451
446 template<typename Char> struct CaseInsensitiveCompare { 452 template<typename Char> struct CaseInsensitiveCompare {
447 public: 453 public:
448 bool operator()(Char x, Char y) const { 454 bool operator()(Char x, Char y) const {
449 return tolower(x) == tolower(y); 455 return tolower(x) == tolower(y);
450 } 456 }
451 }; 457 };
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 // Returns true if the string passed in matches the pattern. The pattern 532 // Returns true if the string passed in matches the pattern. The pattern
527 // string can contain wildcards like * and ? 533 // string can contain wildcards like * and ?
528 // TODO(iyengar) This function may not work correctly for CJK strings as 534 // TODO(iyengar) This function may not work correctly for CJK strings as
529 // it does individual character matches. 535 // it does individual character matches.
530 // The backslash character (\) is an escape character for * and ? 536 // The backslash character (\) is an escape character for * and ?
531 bool MatchPattern(const std::wstring& string, const std::wstring& pattern); 537 bool MatchPattern(const std::wstring& string, const std::wstring& pattern);
532 bool MatchPattern(const std::string& string, const std::string& pattern); 538 bool MatchPattern(const std::string& string, const std::string& pattern);
533 539
534 #endif // BASE_STRING_UTIL_H_ 540 #endif // BASE_STRING_UTIL_H_
535 541
OLDNEW
« no previous file with comments | « no previous file | chrome/common/common.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698