Newer
Older
#pragma once
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <sys/stat.h>
#include "ErrorCodes.h"
typedef std::unordered_map<std::string, std::string> KeyValueMap;
typedef std::unordered_set<std::string> AcceptedKeys;
#define ACCEPTED_KEYS { "--input", "--bounds", "--output", "--celltype" }
class ParseCommandLine
{
private:
std::string _launchPath;
KeyValueMap _cmdLineMap;
std::vector<ErrorCodes> _errors;
std::vector<std::string> _errorMsgs;
bool directoryExists(const std::string& filepath);
private:
static AcceptedKeys s_validKeys;
inline bool validKey(const std::string& key)
{
return s_validKeys.count(key);
}
public:
ParseCommandLine(int argc, char** argv);
inline const std::string& getValue(const std::string& key) const
{
return _cmdLineMap.at(key);
}
inline const bool hasKey(const std::string& key) const
{
if (_cmdLineMap.find(key) == _cmdLineMap.end())
return false;
return true;
}
const bool hasErrors() const { return _errors.size() > 0; }
void dumpErrors();
};