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

Side by Side Diff: base/strings/string_util.h

Issue 1223153003: Move JoinString to the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: windows Created 5 years, 5 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
« no previous file with comments | « base/debug/crash_logging.cc ('k') | base/strings/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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_STRINGS_STRING_UTIL_H_ 7 #ifndef BASE_STRINGS_STRING_UTIL_H_
8 #define BASE_STRINGS_STRING_UTIL_H_ 8 #define BASE_STRINGS_STRING_UTIL_H_
9 9
10 #include <ctype.h> 10 #include <ctype.h>
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 // immediately write over this memory, but there is no other way to set the size 484 // immediately write over this memory, but there is no other way to set the size
485 // of the string, and not doing that will mean people who access |str| rather 485 // of the string, and not doing that will mean people who access |str| rather
486 // than str.c_str() will get back a string of whatever size |str| had on entry 486 // than str.c_str() will get back a string of whatever size |str| had on entry
487 // to this function (probably 0). 487 // to this function (probably 0).
488 BASE_EXPORT char* WriteInto(std::string* str, size_t length_with_null); 488 BASE_EXPORT char* WriteInto(std::string* str, size_t length_with_null);
489 BASE_EXPORT char16* WriteInto(base::string16* str, size_t length_with_null); 489 BASE_EXPORT char16* WriteInto(base::string16* str, size_t length_with_null);
490 #ifndef OS_WIN 490 #ifndef OS_WIN
491 BASE_EXPORT wchar_t* WriteInto(std::wstring* str, size_t length_with_null); 491 BASE_EXPORT wchar_t* WriteInto(std::wstring* str, size_t length_with_null);
492 #endif 492 #endif
493 493
494 // Does the opposite of SplitString().
495 BASE_EXPORT std::string JoinString(const std::vector<std::string>& parts,
496 StringPiece separator);
497 BASE_EXPORT string16 JoinString(const std::vector<string16>& parts,
498 StringPiece16 separator);
499
494 } // namespace base 500 } // namespace base
495 501
496 #if defined(OS_WIN) 502 #if defined(OS_WIN)
497 #include "base/strings/string_util_win.h" 503 #include "base/strings/string_util_win.h"
498 #elif defined(OS_POSIX) 504 #elif defined(OS_POSIX)
499 #include "base/strings/string_util_posix.h" 505 #include "base/strings/string_util_posix.h"
500 #else 506 #else
501 #error Define string operations appropriately for your platform 507 #error Define string operations appropriately for your platform
502 #endif 508 #endif
503 509
504 //-----------------------------------------------------------------------------
505
506 // Does the opposite of SplitString().
507 BASE_EXPORT base::string16 JoinString(const std::vector<base::string16>& parts,
508 base::char16 s);
509 BASE_EXPORT std::string JoinString(
510 const std::vector<std::string>& parts, char s);
511
512 // Join |parts| using |separator|.
513 BASE_EXPORT std::string JoinString(
514 const std::vector<std::string>& parts,
515 const std::string& separator);
516 BASE_EXPORT base::string16 JoinString(
517 const std::vector<base::string16>& parts,
518 const base::string16& separator);
519
520 // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively. 510 // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively.
521 // Additionally, any number of consecutive '$' characters is replaced by that 511 // Additionally, any number of consecutive '$' characters is replaced by that
522 // number less one. Eg $$->$, $$$->$$, etc. The offsets parameter here can be 512 // number less one. Eg $$->$, $$$->$$, etc. The offsets parameter here can be
523 // NULL. This only allows you to use up to nine replacements. 513 // NULL. This only allows you to use up to nine replacements.
524 BASE_EXPORT base::string16 ReplaceStringPlaceholders( 514 BASE_EXPORT base::string16 ReplaceStringPlaceholders(
525 const base::string16& format_string, 515 const base::string16& format_string,
526 const std::vector<base::string16>& subst, 516 const std::vector<base::string16>& subst,
527 std::vector<size_t>* offsets); 517 std::vector<size_t>* offsets);
528 518
529 BASE_EXPORT std::string ReplaceStringPlaceholders( 519 BASE_EXPORT std::string ReplaceStringPlaceholders(
530 const base::StringPiece& format_string, 520 const base::StringPiece& format_string,
531 const std::vector<std::string>& subst, 521 const std::vector<std::string>& subst,
532 std::vector<size_t>* offsets); 522 std::vector<size_t>* offsets);
533 523
534 // Single-string shortcut for ReplaceStringHolders. |offset| may be NULL. 524 // Single-string shortcut for ReplaceStringHolders. |offset| may be NULL.
535 BASE_EXPORT base::string16 ReplaceStringPlaceholders( 525 BASE_EXPORT base::string16 ReplaceStringPlaceholders(
536 const base::string16& format_string, 526 const base::string16& format_string,
537 const base::string16& a, 527 const base::string16& a,
538 size_t* offset); 528 size_t* offset);
539 529
540 #endif // BASE_STRINGS_STRING_UTIL_H_ 530 #endif // BASE_STRINGS_STRING_UTIL_H_
OLDNEW
« no previous file with comments | « base/debug/crash_logging.cc ('k') | base/strings/string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698