forked from manio/skymax-demo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
241 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
out/ | ||
test/ |
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,34 @@ | ||
// @author iain | ||
|
||
#include <algorithm> | ||
#include <string> | ||
#include <vector> | ||
#include "inputparser.h" | ||
|
||
// This class simply finds cmd line args and parses them for use in a program. | ||
// It is not posix compliant and wont work with args like: ./program -xf filename | ||
// You must place each arg after its own seperate dash like: ./program -x -f filename | ||
|
||
InputParser::InputParser (int &argc, char **argv) | ||
{ | ||
for (int i=1; i < argc; ++i) | ||
this->tokens.push_back(std::string(argv[i])); | ||
} | ||
const std::string& InputParser::getCmdOption(const std::string &option) const | ||
{ | ||
std::vector<std::string>::const_iterator itr; | ||
itr = std::find(this->tokens.begin(), this->tokens.end(), option); | ||
if (itr != this->tokens.end() && ++itr != this->tokens.end()) | ||
{ | ||
return *itr; | ||
} | ||
static const std::string empty_string(""); | ||
return empty_string; | ||
} | ||
bool InputParser::cmdOptionExists(const std::string &option) const | ||
{ | ||
return std::find(this->tokens.begin(), this->tokens.end(), option) | ||
!= this->tokens.end(); | ||
} | ||
|
||
std::vector <std::string> tokens; |
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,18 @@ | ||
// inputparser.h | ||
// @author iain | ||
#ifndef INPUTPARSER_H | ||
#define INPUTPARSER_H | ||
|
||
#include <vector> | ||
|
||
class InputParser | ||
{ | ||
std::vector <std::string> tokens; | ||
|
||
public: | ||
InputParser (int &argc, char **argv); | ||
const std::string& getCmdOption(const std::string &option) const; | ||
bool cmdOptionExists(const std::string &option) const; | ||
}; | ||
|
||
#endif // ___INPUTPARSER_H |
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
Oops, something went wrong.