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

Side by Side Diff: base/command_line.cc

Issue 196793010: Move IsStringASCII/UTF8 to 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 | « no previous file | base/i18n/streaming_utf8_validator_perftest.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/command_line.h" 5 #include "base/command_line.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 base::TrimWhitespace(program.value(), base::TRIM_ALL, &argv_[0]); 297 base::TrimWhitespace(program.value(), base::TRIM_ALL, &argv_[0]);
298 } 298 }
299 299
300 bool CommandLine::HasSwitch(const std::string& switch_string) const { 300 bool CommandLine::HasSwitch(const std::string& switch_string) const {
301 return switches_.find(LowerASCIIOnWindows(switch_string)) != switches_.end(); 301 return switches_.find(LowerASCIIOnWindows(switch_string)) != switches_.end();
302 } 302 }
303 303
304 std::string CommandLine::GetSwitchValueASCII( 304 std::string CommandLine::GetSwitchValueASCII(
305 const std::string& switch_string) const { 305 const std::string& switch_string) const {
306 StringType value = GetSwitchValueNative(switch_string); 306 StringType value = GetSwitchValueNative(switch_string);
307 if (!IsStringASCII(value)) { 307 if (!base::IsStringASCII(value)) {
308 DLOG(WARNING) << "Value of switch (" << switch_string << ") must be ASCII."; 308 DLOG(WARNING) << "Value of switch (" << switch_string << ") must be ASCII.";
309 return std::string(); 309 return std::string();
310 } 310 }
311 #if defined(OS_WIN) 311 #if defined(OS_WIN)
312 return base::UTF16ToASCII(value); 312 return base::UTF16ToASCII(value);
313 #else 313 #else
314 return value; 314 return value;
315 #endif 315 #endif
316 } 316 }
317 317
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // Erase only the first kSwitchTerminator (maybe "--" is a legitimate page?) 379 // Erase only the first kSwitchTerminator (maybe "--" is a legitimate page?)
380 StringVector::iterator switch_terminator = 380 StringVector::iterator switch_terminator =
381 std::find(args.begin(), args.end(), kSwitchTerminator); 381 std::find(args.begin(), args.end(), kSwitchTerminator);
382 if (switch_terminator != args.end()) 382 if (switch_terminator != args.end())
383 args.erase(switch_terminator); 383 args.erase(switch_terminator);
384 return args; 384 return args;
385 } 385 }
386 386
387 void CommandLine::AppendArg(const std::string& value) { 387 void CommandLine::AppendArg(const std::string& value) {
388 #if defined(OS_WIN) 388 #if defined(OS_WIN)
389 DCHECK(IsStringUTF8(value)); 389 DCHECK(base::IsStringUTF8(value));
390 AppendArgNative(base::UTF8ToWide(value)); 390 AppendArgNative(base::UTF8ToWide(value));
391 #elif defined(OS_POSIX) 391 #elif defined(OS_POSIX)
392 AppendArgNative(value); 392 AppendArgNative(value);
393 #endif 393 #endif
394 } 394 }
395 395
396 void CommandLine::AppendArgPath(const FilePath& path) { 396 void CommandLine::AppendArgPath(const FilePath& path) {
397 AppendArgNative(path.value()); 397 AppendArgNative(path.value());
398 } 398 }
399 399
(...skipping 30 matching lines...) Expand all
430 int num_args = 0; 430 int num_args = 0;
431 wchar_t** args = NULL; 431 wchar_t** args = NULL;
432 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); 432 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args);
433 433
434 DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " 434 DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: "
435 << command_line; 435 << command_line;
436 InitFromArgv(num_args, args); 436 InitFromArgv(num_args, args);
437 LocalFree(args); 437 LocalFree(args);
438 } 438 }
439 #endif 439 #endif
OLDNEW
« no previous file with comments | « no previous file | base/i18n/streaming_utf8_validator_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698