Chromium Code Reviews| 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> |
| 11 #include <stdarg.h> // va_list | 11 #include <stdarg.h> // va_list |
| 12 | 12 |
| 13 #include <map> | |
| 13 #include <string> | 14 #include <string> |
| 14 #include <vector> | 15 #include <vector> |
| 15 | 16 |
| 16 #include "base/base_export.h" | 17 #include "base/base_export.h" |
| 17 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
| 18 #include "base/compiler_specific.h" | 19 #include "base/compiler_specific.h" |
| 19 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
| 20 #include "base/strings/string_piece.h" // For implicit conversions. | 21 #include "base/strings/string_piece.h" // For implicit conversions. |
| 21 | 22 |
| 22 namespace base { | 23 namespace base { |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 const std::vector<std::string>& parts, char s); | 512 const std::vector<std::string>& parts, char s); |
| 512 | 513 |
| 513 // Join |parts| using |separator|. | 514 // Join |parts| using |separator|. |
| 514 BASE_EXPORT std::string JoinString( | 515 BASE_EXPORT std::string JoinString( |
| 515 const std::vector<std::string>& parts, | 516 const std::vector<std::string>& parts, |
| 516 const std::string& separator); | 517 const std::string& separator); |
| 517 BASE_EXPORT base::string16 JoinString( | 518 BASE_EXPORT base::string16 JoinString( |
| 518 const std::vector<base::string16>& parts, | 519 const std::vector<base::string16>& parts, |
| 519 const base::string16& separator); | 520 const base::string16& separator); |
| 520 | 521 |
| 522 // Replace ${foo} in the format string with the value for the foo key in subst. | |
|
Dan Beam
2015/07/02 02:10:16
subst -> |subst|
dschuyler
2015/07/07 23:05:30
Done.
| |
| 523 // Additionally, any number of consecutive '$' characters is replaced by that | |
| 524 // number less one. Eg $$ becomes $, $$$ becomes $$, etc. | |
| 525 BASE_EXPORT std::string ReplaceStringPlaceholders( | |
| 526 const std::string& format_string, | |
| 527 const std::map<std::string, std::string>& subst); | |
| 528 | |
| 521 // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively. | 529 // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively. |
| 522 // Additionally, any number of consecutive '$' characters is replaced by that | 530 // Additionally, any number of consecutive '$' characters is replaced by that |
| 523 // number less one. Eg $$->$, $$$->$$, etc. The offsets parameter here can be | 531 // number less one. Eg $$->$, $$$->$$, etc. The offsets parameter here can be |
| 524 // NULL. This only allows you to use up to nine replacements. | 532 // NULL. This only allows you to use up to nine replacements. |
| 525 BASE_EXPORT base::string16 ReplaceStringPlaceholders( | 533 BASE_EXPORT base::string16 ReplaceStringPlaceholders( |
| 526 const base::string16& format_string, | 534 const base::string16& format_string, |
| 527 const std::vector<base::string16>& subst, | 535 const std::vector<base::string16>& subst, |
| 528 std::vector<size_t>* offsets); | 536 std::vector<size_t>* offsets); |
| 529 | 537 |
| 530 BASE_EXPORT std::string ReplaceStringPlaceholders( | 538 BASE_EXPORT std::string ReplaceStringPlaceholders( |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 542 // string can contain wildcards like * and ? | 550 // string can contain wildcards like * and ? |
| 543 // The backslash character (\) is an escape character for * and ? | 551 // The backslash character (\) is an escape character for * and ? |
| 544 // We limit the patterns to having a max of 16 * or ? characters. | 552 // We limit the patterns to having a max of 16 * or ? characters. |
| 545 // ? matches 0 or 1 character, while * matches 0 or more characters. | 553 // ? matches 0 or 1 character, while * matches 0 or more characters. |
| 546 BASE_EXPORT bool MatchPattern(const base::StringPiece& string, | 554 BASE_EXPORT bool MatchPattern(const base::StringPiece& string, |
| 547 const base::StringPiece& pattern); | 555 const base::StringPiece& pattern); |
| 548 BASE_EXPORT bool MatchPattern(const base::string16& string, | 556 BASE_EXPORT bool MatchPattern(const base::string16& string, |
| 549 const base::string16& pattern); | 557 const base::string16& pattern); |
| 550 | 558 |
| 551 #endif // BASE_STRINGS_STRING_UTIL_H_ | 559 #endif // BASE_STRINGS_STRING_UTIL_H_ |
| OLD | NEW |