OLD | NEW |
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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 const std::vector<std::string>& parts, char s); | 454 const std::vector<std::string>& parts, char s); |
455 | 455 |
456 // Join |parts| using |separator|. | 456 // Join |parts| using |separator|. |
457 BASE_EXPORT std::string JoinString( | 457 BASE_EXPORT std::string JoinString( |
458 const std::vector<std::string>& parts, | 458 const std::vector<std::string>& parts, |
459 const std::string& separator); | 459 const std::string& separator); |
460 BASE_EXPORT base::string16 JoinString( | 460 BASE_EXPORT base::string16 JoinString( |
461 const std::vector<base::string16>& parts, | 461 const std::vector<base::string16>& parts, |
462 const base::string16& separator); | 462 const base::string16& separator); |
463 | 463 |
| 464 typedef std::vector<std::pair<std::string, std::string> > StringPairs; |
| 465 |
| 466 // Does the opposite of SplitStringIntoKeyValuePairs(). |
| 467 BASE_EXPORT std::string JoinStringKeyValuePairs(const StringPairs& pairs, |
| 468 char key_value_delimiter, |
| 469 char key_value_pair_delimiter); |
| 470 |
464 // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively. | 471 // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively. |
465 // Additionally, any number of consecutive '$' characters is replaced by that | 472 // Additionally, any number of consecutive '$' characters is replaced by that |
466 // number less one. Eg $$->$, $$$->$$, etc. The offsets parameter here can be | 473 // number less one. Eg $$->$, $$$->$$, etc. The offsets parameter here can be |
467 // NULL. This only allows you to use up to nine replacements. | 474 // NULL. This only allows you to use up to nine replacements. |
468 BASE_EXPORT base::string16 ReplaceStringPlaceholders( | 475 BASE_EXPORT base::string16 ReplaceStringPlaceholders( |
469 const base::string16& format_string, | 476 const base::string16& format_string, |
470 const std::vector<base::string16>& subst, | 477 const std::vector<base::string16>& subst, |
471 std::vector<size_t>* offsets); | 478 std::vector<size_t>* offsets); |
472 | 479 |
473 BASE_EXPORT std::string ReplaceStringPlaceholders( | 480 BASE_EXPORT std::string ReplaceStringPlaceholders( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 #elif defined(WCHAR_T_IS_UTF32) | 521 #elif defined(WCHAR_T_IS_UTF32) |
515 typedef uint32 Unsigned; | 522 typedef uint32 Unsigned; |
516 #endif | 523 #endif |
517 }; | 524 }; |
518 template<> | 525 template<> |
519 struct ToUnsigned<short> { | 526 struct ToUnsigned<short> { |
520 typedef unsigned short Unsigned; | 527 typedef unsigned short Unsigned; |
521 }; | 528 }; |
522 | 529 |
523 #endif // BASE_STRINGS_STRING_UTIL_H_ | 530 #endif // BASE_STRINGS_STRING_UTIL_H_ |
OLD | NEW |