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

Unified Diff: build_tools/debug_server/debug_server/common/debug_command_line.cpp

Issue 6312039: RSP proxy that can record session (for playback testing).... (Closed) Base URL: http://nativeclient-sdk.googlecode.com/svn/trunk/src/
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
Index: build_tools/debug_server/debug_server/common/debug_command_line.cpp
===================================================================
--- build_tools/debug_server/debug_server/common/debug_command_line.cpp (revision 0)
+++ build_tools/debug_server/debug_server/common/debug_command_line.cpp (revision 0)
@@ -0,0 +1,52 @@
+#include "debug_command_line.h"
+
+namespace {
+std::string AddDashedPrefix(const std::string& name) {
+ std::string result = name;
+ while (0 != strncmp(result.c_str(), "--", 2)) {
+ result = std::string("-") + result;
+ }
+ return result;
+}
+} // namespace
+
+namespace debug {
+CommandLine::CommandLine(int argc, char* argv[])
+ : argc_(argc),
+ argv_(argv) {
+}
+
+CommandLine::~CommandLine() {}
+
+std::string CommandLine::GetStringSwitch(
+ const std::string& name, const std::string& default_value) const {
+ std::string value = default_value;
+ std::string name_with_two_dashes = AddDashedPrefix(name);
+ for (int i = 1; (i + 1) < argc_; i++) {
+ if (AddDashedPrefix(argv_[i]) == name_with_two_dashes) {
+ value = argv_[i + 1];
+ break;
+ }
+ }
+ return value;
+}
+
+int CommandLine::GetIntSwitch(const std::string& name,
+ int default_value) const {
+ int value = default_value;
+ std::string str = GetStringSwitch(name, "");
+ if (0 != str.size())
+ value = atoi(str.c_str());
+ return value;
+}
+
+bool CommandLine::HasSwitch(const std::string& name) const {
+ std::string name_with_two_dashes = AddDashedPrefix(name);
+ for (int i = 1; i < argc_; i++) {
+ if (AddDashedPrefix(argv_[i]) == name_with_two_dashes)
+ return true;
+ }
+ return false;
+}
+} // namespace debug
+

Powered by Google App Engine
This is Rietveld 408576698