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

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

Issue 1220793010: [ui/base;css] adding string template expression replacement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment change; merge with master 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 | « no previous file | base/strings/string_util.cc » ('j') | base/strings/string_util.cc » ('J')
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>
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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 const std::vector<std::string>& parts, char s); 516 const std::vector<std::string>& parts, char s);
516 517
517 // Join |parts| using |separator|. 518 // Join |parts| using |separator|.
518 BASE_EXPORT std::string JoinString( 519 BASE_EXPORT std::string JoinString(
519 const std::vector<std::string>& parts, 520 const std::vector<std::string>& parts,
520 const std::string& separator); 521 const std::string& separator);
521 BASE_EXPORT base::string16 JoinString( 522 BASE_EXPORT base::string16 JoinString(
522 const std::vector<base::string16>& parts, 523 const std::vector<base::string16>& parts,
523 const base::string16& separator); 524 const base::string16& separator);
524 525
526 // Replace ${foo} in the format string with the value for the foo key in
527 // |subst|. Additionally, any number of consecutive '$' characters is replaced
528 // by that number less one. Eg $$ becomes $, $$$ becomes $$, etc.
529 BASE_EXPORT std::string ReplaceStringPlaceholders(
530 const std::string& format_string,
531 const std::map<std::string, std::string>& subst);
Evan Stade 2015/07/07 17:15:16 don't abbreviate variable names
Dan Beam 2015/07/07 17:26:37 yeah, i don't like it either. we could just fix t
532
525 // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively. 533 // Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively.
526 // Additionally, any number of consecutive '$' characters is replaced by that 534 // Additionally, any number of consecutive '$' characters is replaced by that
527 // number less one. Eg $$->$, $$$->$$, etc. The offsets parameter here can be 535 // number less one. Eg $$->$, $$$->$$, etc. The offsets parameter here can be
528 // NULL. This only allows you to use up to nine replacements. 536 // NULL. This only allows you to use up to nine replacements.
529 BASE_EXPORT base::string16 ReplaceStringPlaceholders( 537 BASE_EXPORT base::string16 ReplaceStringPlaceholders(
530 const base::string16& format_string, 538 const base::string16& format_string,
531 const std::vector<base::string16>& subst, 539 const std::vector<base::string16>& subst,
532 std::vector<size_t>* offsets); 540 std::vector<size_t>* offsets);
533 541
534 BASE_EXPORT std::string ReplaceStringPlaceholders( 542 BASE_EXPORT std::string ReplaceStringPlaceholders(
535 const base::StringPiece& format_string, 543 const base::StringPiece& format_string,
536 const std::vector<std::string>& subst, 544 const std::vector<std::string>& subst,
537 std::vector<size_t>* offsets); 545 std::vector<size_t>* offsets);
538 546
539 // Single-string shortcut for ReplaceStringHolders. |offset| may be NULL. 547 // Single-string shortcut for ReplaceStringHolders. |offset| may be NULL.
540 BASE_EXPORT base::string16 ReplaceStringPlaceholders( 548 BASE_EXPORT base::string16 ReplaceStringPlaceholders(
541 const base::string16& format_string, 549 const base::string16& format_string,
542 const base::string16& a, 550 const base::string16& a,
543 size_t* offset); 551 size_t* offset);
544 552
545 #endif // BASE_STRINGS_STRING_UTIL_H_ 553 #endif // BASE_STRINGS_STRING_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/strings/string_util.cc » ('j') | base/strings/string_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698