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

Side by Side Diff: base/string_util.h

Issue 18603: Add a replace_all param to ReplaceSubstringsAfterOffset and update call sites. (Closed)
Patch Set: Add ReplaceFirstSubstringAfterPos() Created 11 years, 11 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/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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_STRING_UTIL_H_ 7 #ifndef BASE_STRING_UTIL_H_
8 #define BASE_STRING_UTIL_H_ 8 #define BASE_STRING_UTIL_H_
9 9
10 #include <string> 10 #include <string>
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 313
314 // As above, but with "/s" units. 314 // As above, but with "/s" units.
315 // Ex: FormatSpeed(512, DATA_UNITS_KILOBYTE, true) => "0.5 KB/s" 315 // Ex: FormatSpeed(512, DATA_UNITS_KILOBYTE, true) => "0.5 KB/s"
316 // Ex: FormatSpeed(10*1024, DATA_UNITS_MEGABYTE, false) => "0.1" 316 // Ex: FormatSpeed(10*1024, DATA_UNITS_MEGABYTE, false) => "0.1"
317 std::wstring FormatSpeed(int64 bytes, DataUnits units, bool show_units); 317 std::wstring FormatSpeed(int64 bytes, DataUnits units, bool show_units);
318 318
319 // Return a number formated with separators in the user's locale way. 319 // Return a number formated with separators in the user's locale way.
320 // Ex: FormatNumber(1234567) => 1,234,567 320 // Ex: FormatNumber(1234567) => 1,234,567
321 std::wstring FormatNumber(int64 number); 321 std::wstring FormatNumber(int64 number);
322 322
323 // Starting at |start_offset| (usually 0), replace the first instance of
324 // |find_this| with |replace_with|.
325 void ReplaceFirstSubstringAfterOffset(std::wstring* str,
326 std::wstring::size_type start_offset,
327 const std::wstring& find_this,
328 const std::wstring& replace_with);
329 void ReplaceFirstSubstringAfterOffset(std::string* str,
330 std::string::size_type start_offset,
331 const std::string& find_this,
332 const std::string& replace_with);
333
323 // Starting at |start_offset| (usually 0), look through |str| and replace all 334 // Starting at |start_offset| (usually 0), look through |str| and replace all
324 // instances of |find_this| with |replace_with|. 335 // instances of |find_this| with |replace_with|.
325 // 336 //
326 // This does entire substrings; use std::replace in <algorithm> for single 337 // This does entire substrings; use std::replace in <algorithm> for single
327 // characters, for example: 338 // characters, for example:
328 // std::replace(str.begin(), str.end(), 'a', 'b'); 339 // std::replace(str.begin(), str.end(), 'a', 'b');
329 void ReplaceSubstringsAfterOffset(std::wstring* str, 340 void ReplaceSubstringsAfterOffset(std::wstring* str,
330 std::wstring::size_type start_offset, 341 std::wstring::size_type start_offset,
331 const std::wstring& find_this, 342 const std::wstring& find_this,
332 const std::wstring& replace_with); 343 const std::wstring& replace_with);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 // Returns true if the string passed in matches the pattern. The pattern 534 // Returns true if the string passed in matches the pattern. The pattern
524 // string can contain wildcards like * and ? 535 // string can contain wildcards like * and ?
525 // TODO(iyengar) This function may not work correctly for CJK strings as 536 // TODO(iyengar) This function may not work correctly for CJK strings as
526 // it does individual character matches. 537 // it does individual character matches.
527 // The backslash character (\) is an escape character for * and ? 538 // The backslash character (\) is an escape character for * and ?
528 bool MatchPattern(const std::wstring& string, const std::wstring& pattern); 539 bool MatchPattern(const std::wstring& string, const std::wstring& pattern);
529 bool MatchPattern(const std::string& string, const std::string& pattern); 540 bool MatchPattern(const std::string& string, const std::string& pattern);
530 541
531 #endif // BASE_STRING_UTIL_H_ 542 #endif // BASE_STRING_UTIL_H_
532 543
OLDNEW
« no previous file with comments | « no previous file | base/string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698