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

Side by Side Diff: experimental/windows_debugger/debugger/base/debug_command_line.cc

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2011 The Native Client SDK Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file.
4
5 #include "debugger/base/debug_command_line.h"
6
7 namespace {
8 std::string AddDashedPrefix(const std::string& name) {
9 std::string result = name;
10 while (0 != strncmp(result.c_str(), "--", 2)) {
11 result = std::string("-") + result;
12 }
13 return result;
14 }
15 } // namespace
16
17 namespace debug {
18 CommandLine::CommandLine(int argc, char* argv[])
19 : argc_(argc),
20 argv_(argv) {
21 }
22
23 CommandLine::~CommandLine() {}
24
25 bool HasSpace(const char* str) {
26 while(*str) {
27 if (isspace(*str++))
28 return true;
29 }
30 return false;
31 }
32
33 std::string CommandLine::ToString() const {
34 std::string str;
35 for (int i = 0; i < argc_; i++) {
36 if (i > 0)
37 str += " ";
38 if(HasSpace(argv_[i])) {
39 char tmp[4096] = {0};
40 _snprintf_s(tmp, sizeof(tmp), "\"%s\"");
41 str += tmp;
42 } else {
43 str += argv_[i];
44 }
45 }
46 return str;
47 }
48
49 std::string CommandLine::GetStringSwitch(
50 const std::string& name, const std::string& default_value) const {
51 std::string value = default_value;
52 std::string name_with_two_dashes = AddDashedPrefix(name);
53 for (int i = 1; (i + 1) < argc_; i++) {
54 if (AddDashedPrefix(argv_[i]) == name_with_two_dashes) {
55 value = argv_[i + 1];
56 break;
57 }
58 }
59 return value;
60 }
61
62 int CommandLine::GetIntSwitch(const std::string& name,
63 int default_value) const {
64 int value = default_value;
65 std::string str = GetStringSwitch(name, "");
66 if (0 != str.size())
67 value = atoi(str.c_str());
68 return value;
69 }
70
71 bool CommandLine::HasSwitch(const std::string& name) const {
72 std::string name_with_two_dashes = AddDashedPrefix(name);
73 for (int i = 1; i < argc_; i++) {
74 if (AddDashedPrefix(argv_[i]) == name_with_two_dashes)
75 return true;
76 }
77 return false;
78 }
79 } // namespace debug
80
81
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698