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

Side by Side Diff: base/string_util.h

Issue 8502027: Fix AutocompleteMatch DCHECK() triggered by |RenderViewContextMenu::AppendSearchProvider()|. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/string_util.cc » ('j') | base/string_util.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 9 #pragma once
10 10
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 BASE_EXPORT const std::string& EmptyString(); 166 BASE_EXPORT const std::string& EmptyString();
167 BASE_EXPORT const std::wstring& EmptyWString(); 167 BASE_EXPORT const std::wstring& EmptyWString();
168 BASE_EXPORT const string16& EmptyString16(); 168 BASE_EXPORT const string16& EmptyString16();
169 169
170 BASE_EXPORT extern const wchar_t kWhitespaceWide[]; 170 BASE_EXPORT extern const wchar_t kWhitespaceWide[];
171 BASE_EXPORT extern const char16 kWhitespaceUTF16[]; 171 BASE_EXPORT extern const char16 kWhitespaceUTF16[];
172 BASE_EXPORT extern const char kWhitespaceASCII[]; 172 BASE_EXPORT extern const char kWhitespaceASCII[];
173 173
174 BASE_EXPORT extern const char kUtf8ByteOrderMark[]; 174 BASE_EXPORT extern const char kUtf8ByteOrderMark[];
175 175
176 // Removes characters in |remove_chars| from anywhere in input. Returns true if 176 // Removes characters in |remove_chars| from anywhere in |input|. Returns true
177 // any characters were removed. |remove_chars| must be null-terminated. 177 // if any characters were removed. |remove_chars| must be null-terminated.
178 // NOTE: Safe to use the same variable for both input and output. 178 // NOTE: Safe to use the same variable for both |input| and |output|.
179 BASE_EXPORT bool RemoveChars(const string16& input, 179 BASE_EXPORT bool RemoveChars(const string16& input,
180 const char16 remove_chars[], 180 const char16 remove_chars[],
181 string16* output); 181 string16* output);
182 BASE_EXPORT bool RemoveChars(const std::string& input, 182 BASE_EXPORT bool RemoveChars(const std::string& input,
183 const char remove_chars[], 183 const char remove_chars[],
184 std::string* output); 184 std::string* output);
185 185
186 // Removes characters in |trim_chars| from the beginning and end of input. 186 // Replaces characters in |replace_chars| from anywhere in |input| with
187 // |replace_with|. Returns true if any characters were removed.
Mark Mentovai 2011/11/09 20:31:32 Removed? Replaced!
Mark Mentovai 2011/11/09 20:31:32 This doesn’t really explain whether ReplaceChars r
Alexei Svitkine (slow) 2011/11/09 21:03:58 Done.
Alexei Svitkine (slow) 2011/11/09 21:03:58 Done.
188 // |replace_chars| must be null-terminated.
189 // NOTE: Safe to use the same variable for both |input| and |output|.
190 BASE_EXPORT bool ReplaceChars(const string16& input,
191 const char16 replace_chars[],
192 const string16& replace_with,
193 string16* output);
194 BASE_EXPORT bool ReplaceChars(const std::string& input,
195 const char replace_chars[],
196 const std::string& replace_with,
197 std::string* output);
198
199 // Removes characters in |trim_chars| from the beginning and end of |input|.
187 // |trim_chars| must be null-terminated. 200 // |trim_chars| must be null-terminated.
188 // NOTE: Safe to use the same variable for both input and output. 201 // NOTE: Safe to use the same variable for both |input| and |output|.
189 BASE_EXPORT bool TrimString(const std::wstring& input, 202 BASE_EXPORT bool TrimString(const std::wstring& input,
190 const wchar_t trim_chars[], 203 const wchar_t trim_chars[],
191 std::wstring* output); 204 std::wstring* output);
192 BASE_EXPORT bool TrimString(const string16& input, 205 BASE_EXPORT bool TrimString(const string16& input,
193 const char16 trim_chars[], 206 const char16 trim_chars[],
194 string16* output); 207 string16* output);
195 BASE_EXPORT bool TrimString(const std::string& input, 208 BASE_EXPORT bool TrimString(const std::string& input,
196 const char trim_chars[], 209 const char trim_chars[],
197 std::string* output); 210 std::string* output);
198 211
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 std::string::size_type start_offset, 438 std::string::size_type start_offset,
426 const std::string& find_this, 439 const std::string& find_this,
427 const std::string& replace_with); 440 const std::string& replace_with);
428 441
429 // Starting at |start_offset| (usually 0), look through |str| and replace all 442 // Starting at |start_offset| (usually 0), look through |str| and replace all
430 // instances of |find_this| with |replace_with|. 443 // instances of |find_this| with |replace_with|.
431 // 444 //
432 // This does entire substrings; use std::replace in <algorithm> for single 445 // This does entire substrings; use std::replace in <algorithm> for single
433 // characters, for example: 446 // characters, for example:
434 // std::replace(str.begin(), str.end(), 'a', 'b'); 447 // std::replace(str.begin(), str.end(), 'a', 'b');
435 BASE_EXPORT void ReplaceSubstringsAfterOffset( 448 BASE_EXPORT void ReplaceSubstringsAfterOffset(
Mark Mentovai 2011/11/09 20:31:32 We’ve got this, but it replaces substrings, not en
436 string16* str, 449 string16* str,
437 string16::size_type start_offset, 450 string16::size_type start_offset,
438 const string16& find_this, 451 const string16& find_this,
439 const string16& replace_with); 452 const string16& replace_with);
440 BASE_EXPORT void ReplaceSubstringsAfterOffset( 453 BASE_EXPORT void ReplaceSubstringsAfterOffset(
441 std::string* str, 454 std::string* str,
442 std::string::size_type start_offset, 455 std::string::size_type start_offset,
443 const std::string& find_this, 456 const std::string& find_this,
444 const std::string& replace_with); 457 const std::string& replace_with);
445 458
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 #elif defined(WCHAR_T_IS_UTF32) 567 #elif defined(WCHAR_T_IS_UTF32)
555 typedef uint32 Unsigned; 568 typedef uint32 Unsigned;
556 #endif 569 #endif
557 }; 570 };
558 template<> 571 template<>
559 struct ToUnsigned<short> { 572 struct ToUnsigned<short> {
560 typedef unsigned short Unsigned; 573 typedef unsigned short Unsigned;
561 }; 574 };
562 575
563 #endif // BASE_STRING_UTIL_H_ 576 #endif // BASE_STRING_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/string_util.cc » ('j') | base/string_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698