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

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

Issue 183853011: Move TrimWhitespace to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « base/strings/string_util.h ('k') | chrome/browser/autocomplete/autocomplete_input.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 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 #include "base/strings/string_util.h" 5 #include "base/strings/string_util.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <math.h> 9 #include <math.h>
10 #include <stdarg.h> 10 #include <stdarg.h>
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 break; 235 break;
236 } 236 }
237 } 237 }
238 238
239 if (char_index >= 0 ) 239 if (char_index >= 0 )
240 *output = input.substr(0, char_index); 240 *output = input.substr(0, char_index);
241 else 241 else
242 output->clear(); 242 output->clear();
243 } 243 }
244 244
245 } // namespace base 245 TrimPositions TrimWhitespace(const string16& input,
246
247 TrimPositions TrimWhitespace(const base::string16& input,
248 TrimPositions positions, 246 TrimPositions positions,
249 base::string16* output) { 247 string16* output) {
250 return base::TrimStringT(input, base::kWhitespaceUTF16, positions, output); 248 return TrimStringT(input, kWhitespaceUTF16, positions, output);
251 } 249 }
252 250
253 TrimPositions TrimWhitespaceASCII(const std::string& input, 251 TrimPositions TrimWhitespaceASCII(const std::string& input,
254 TrimPositions positions, 252 TrimPositions positions,
255 std::string* output) { 253 std::string* output) {
256 return base::TrimStringT(input, base::kWhitespaceASCII, positions, output); 254 return TrimStringT(input, kWhitespaceASCII, positions, output);
257 } 255 }
258 256
259 // This function is only for backward-compatibility. 257 // This function is only for backward-compatibility.
260 // To be removed when all callers are updated. 258 // To be removed when all callers are updated.
261 TrimPositions TrimWhitespace(const std::string& input, 259 TrimPositions TrimWhitespace(const std::string& input,
262 TrimPositions positions, 260 TrimPositions positions,
263 std::string* output) { 261 std::string* output) {
264 return TrimWhitespaceASCII(input, positions, output); 262 return TrimWhitespaceASCII(input, positions, output);
265 } 263 }
266 264
265 } // namespace base
266
267 template<typename STR> 267 template<typename STR>
268 STR CollapseWhitespaceT(const STR& text, 268 STR CollapseWhitespaceT(const STR& text,
269 bool trim_sequences_with_line_breaks) { 269 bool trim_sequences_with_line_breaks) {
270 STR result; 270 STR result;
271 result.resize(text.size()); 271 result.resize(text.size());
272 272
273 // Set flags to pretend we're already in a trimmed whitespace sequence, so we 273 // Set flags to pretend we're already in a trimmed whitespace sequence, so we
274 // will trim any leading whitespace. 274 // will trim any leading whitespace.
275 bool in_whitespace = true; 275 bool in_whitespace = true;
276 bool already_trimmed = true; 276 bool already_trimmed = true;
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 } 928 }
929 929
930 } // namespace 930 } // namespace
931 931
932 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) { 932 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) {
933 return lcpyT<char>(dst, src, dst_size); 933 return lcpyT<char>(dst, src, dst_size);
934 } 934 }
935 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { 935 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) {
936 return lcpyT<wchar_t>(dst, src, dst_size); 936 return lcpyT<wchar_t>(dst, src, dst_size);
937 } 937 }
OLDNEW
« no previous file with comments | « base/strings/string_util.h ('k') | chrome/browser/autocomplete/autocomplete_input.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698