-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored the arguments to be a ParsedArguments class.
- Loading branch information
Showing
13 changed files
with
92 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#ifndef PARSED_ARGUMENTS_HH | ||
#define PARSED_ARGUMENTS_HH | ||
|
||
#include <map> | ||
#include <string> | ||
#include "util.hh" | ||
#include "ezio.hh" | ||
|
||
using namespace std; | ||
|
||
class ParsedArguments | ||
{ | ||
private: | ||
map<string, string> argMap_; | ||
public: | ||
ParsedArguments(map<string, string> argMap ): argMap_(argMap) | ||
{ | ||
} | ||
|
||
double get_float_arg(const string & argName) | ||
{ | ||
if (argMap_.count(argName) > 0) { | ||
return myatof(argMap_.at(argName)); | ||
} else { | ||
throw runtime_error("Missing argument " + argName); | ||
} | ||
} | ||
|
||
double get_float_arg(const string & argName, double defaultArg) | ||
{ | ||
if (argMap_.count(argName) > 0) { | ||
return myatof(argMap_.at(argName)); | ||
} else { | ||
return defaultArg; | ||
} | ||
} | ||
|
||
int get_int_arg(const string & argName) | ||
{ | ||
|
||
if (argMap_.count(argName) > 0) { | ||
return myatoi(argMap_.at(argName)); | ||
} else { | ||
throw runtime_error("Missing argument " + argName); | ||
} | ||
} | ||
|
||
int get_int_arg(const string & argName, int defaultArg) | ||
{ | ||
if (argMap_.count(argName) > 0) { | ||
return myatoi(argMap_.at(argName)); | ||
} else { | ||
return defaultArg; | ||
} | ||
|
||
} | ||
|
||
bool empty() | ||
{ | ||
return argMap_.empty(); | ||
} | ||
|
||
}; | ||
|
||
#endif /* PARSED_ARGUMENTS_HH */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters