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

Side by Side Diff: base/string_util.h

Issue 304003: Add more string16 variants. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months 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 | base/string_util.cc » ('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 <stdarg.h> // va_list 10 #include <stdarg.h> // va_list
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 //----------------------------------------------------------------------------- 496 //-----------------------------------------------------------------------------
497 497
498 // Splits |str| into a vector of strings delimited by |s|. Append the results 498 // Splits |str| into a vector of strings delimited by |s|. Append the results
499 // into |r| as they appear. If several instances of |s| are contiguous, or if 499 // into |r| as they appear. If several instances of |s| are contiguous, or if
500 // |str| begins with or ends with |s|, then an empty string is inserted. 500 // |str| begins with or ends with |s|, then an empty string is inserted.
501 // 501 //
502 // Every substring is trimmed of any leading or trailing white space. 502 // Every substring is trimmed of any leading or trailing white space.
503 void SplitString(const std::wstring& str, 503 void SplitString(const std::wstring& str,
504 wchar_t s, 504 wchar_t s,
505 std::vector<std::wstring>* r); 505 std::vector<std::wstring>* r);
506 void SplitString(const string16& str,
507 char16 s,
508 std::vector<string16>* r);
506 void SplitString(const std::string& str, 509 void SplitString(const std::string& str,
507 char s, 510 char s,
508 std::vector<std::string>* r); 511 std::vector<std::string>* r);
509 512
510 // The same as SplitString, but don't trim white space. 513 // The same as SplitString, but don't trim white space.
511 void SplitStringDontTrim(const std::wstring& str, 514 void SplitStringDontTrim(const std::wstring& str,
512 wchar_t s, 515 wchar_t s,
513 std::vector<std::wstring>* r); 516 std::vector<std::wstring>* r);
517 void SplitStringDontTrim(const string16& str,
518 char16 s,
519 std::vector<string16>* r);
514 void SplitStringDontTrim(const std::string& str, 520 void SplitStringDontTrim(const std::string& str,
515 char s, 521 char s,
516 std::vector<std::string>* r); 522 std::vector<std::string>* r);
517 523
518 // Does the opposite of SplitString(). 524 // Does the opposite of SplitString().
519 std::wstring JoinString(const std::vector<std::wstring>& parts, wchar_t s); 525 std::wstring JoinString(const std::vector<std::wstring>& parts, wchar_t s);
526 string16 JoinString(const std::vector<string16>& parts, char16 s);
520 std::string JoinString(const std::vector<std::string>& parts, char s); 527 std::string JoinString(const std::vector<std::string>& parts, char s);
521 528
522 // WARNING: this uses whitespace as defined by the HTML5 spec. If you need 529 // WARNING: this uses whitespace as defined by the HTML5 spec. If you need
523 // a function similar to this but want to trim all types of whitespace, then 530 // a function similar to this but want to trim all types of whitespace, then
524 // factor this out into a function that takes a string containing the characters 531 // factor this out into a function that takes a string containing the characters
525 // that are treated as whitespace. 532 // that are treated as whitespace.
526 // 533 //
527 // Splits the string along whitespace (where whitespace is the five space 534 // Splits the string along whitespace (where whitespace is the five space
528 // characters defined by HTML 5). Each contiguous block of non-whitespace 535 // characters defined by HTML 5). Each contiguous block of non-whitespace
529 // characters is added to result. 536 // characters is added to result.
530 void SplitStringAlongWhitespace(const std::wstring& str, 537 void SplitStringAlongWhitespace(const std::wstring& str,
531 std::vector<std::wstring>* result); 538 std::vector<std::wstring>* result);
539 void SplitStringAlongWhitespace(const string16& str,
540 std::vector<string16>* result);
532 void SplitStringAlongWhitespace(const std::string& str, 541 void SplitStringAlongWhitespace(const std::string& str,
533 std::vector<std::string>* result); 542 std::vector<std::string>* result);
534 543
535 // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively. 544 // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively.
536 // Additionally, $$ is replaced by $. The offsets parameter here can 545 // Additionally, $$ is replaced by $. The offsets parameter here can
537 // be NULL. This only allows you to use up to nine replacements. 546 // be NULL. This only allows you to use up to nine replacements.
538 string16 ReplaceStringPlaceholders(const string16& format_string, 547 string16 ReplaceStringPlaceholders(const string16& format_string,
539 const std::vector<string16>& subst, 548 const std::vector<string16>& subst,
540 std::vector<size_t>* offsets); 549 std::vector<size_t>* offsets);
541 550
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 #elif defined(WCHAR_T_IS_UTF32) 605 #elif defined(WCHAR_T_IS_UTF32)
597 typedef uint32 Unsigned; 606 typedef uint32 Unsigned;
598 #endif 607 #endif
599 }; 608 };
600 template<> 609 template<>
601 struct ToUnsigned<short> { 610 struct ToUnsigned<short> {
602 typedef unsigned short Unsigned; 611 typedef unsigned short Unsigned;
603 }; 612 };
604 613
605 #endif // BASE_STRING_UTIL_H_ 614 #endif // BASE_STRING_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698