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

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

Issue 1237873004: Revert of Move JoinString to the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
500 } // namespace base 494 } // namespace base
501 495
502 #if defined(OS_WIN) 496 #if defined(OS_WIN)
503 #include "base/strings/string_util_win.h" 497 #include "base/strings/string_util_win.h"
504 #elif defined(OS_POSIX) 498 #elif defined(OS_POSIX)
505 #include "base/strings/string_util_posix.h" 499 #include "base/strings/string_util_posix.h"
506 #else 500 #else
507 #error Define string operations appropriately for your platform 501 #error Define string operations appropriately for your platform
508 #endif 502 #endif
509 503
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
510 // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively. 520 // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively.
511 // Additionally, any number of consecutive '$' characters is replaced by that 521 // Additionally, any number of consecutive '$' characters is replaced by that
512 // number less one. Eg $$->$, $$$->$$, etc. The offsets parameter here can be 522 // number less one. Eg $$->$, $$$->$$, etc. The offsets parameter here can be
513 // NULL. This only allows you to use up to nine replacements. 523 // NULL. This only allows you to use up to nine replacements.
514 BASE_EXPORT base::string16 ReplaceStringPlaceholders( 524 BASE_EXPORT base::string16 ReplaceStringPlaceholders(
515 const base::string16& format_string, 525 const base::string16& format_string,
516 const std::vector<base::string16>& subst, 526 const std::vector<base::string16>& subst,
517 std::vector<size_t>* offsets); 527 std::vector<size_t>* offsets);
518 528
519 BASE_EXPORT std::string ReplaceStringPlaceholders( 529 BASE_EXPORT std::string ReplaceStringPlaceholders(
520 const base::StringPiece& format_string, 530 const base::StringPiece& format_string,
521 const std::vector<std::string>& subst, 531 const std::vector<std::string>& subst,
522 std::vector<size_t>* offsets); 532 std::vector<size_t>* offsets);
523 533
524 // Single-string shortcut for ReplaceStringHolders. |offset| may be NULL. 534 // Single-string shortcut for ReplaceStringHolders. |offset| may be NULL.
525 BASE_EXPORT base::string16 ReplaceStringPlaceholders( 535 BASE_EXPORT base::string16 ReplaceStringPlaceholders(
526 const base::string16& format_string, 536 const base::string16& format_string,
527 const base::string16& a, 537 const base::string16& a,
528 size_t* offset); 538 size_t* offset);
529 539
530 #endif // BASE_STRINGS_STRING_UTIL_H_ 540 #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