#pragma once #include #include #include #include class arguments { public: // functions // Constructor and destructor arguments(int argc, char** const argv) { std::string key ; std::string data ; for(int i=0; i(key, data)) ; } } ; ~arguments() { } ; // Access elements bool is_defined(const std::string& key) const { if(_map.count(key) > 0) { return true ; } else { return false ; } } ; std::string operator[](const std::string& key) const { if(_map.count(key) > 0) { return _map.find(key)->second ; } else { std::cerr << "Underfined request to key : \"" << key << "\"" << std::endl ; return std::string() ; } } ; float get_float(const std::string& key, float default_value = 0.0f) const { std::string value = _map.at(key) ; if(value.empty()) return default_value ; else return atof(value.c_str()) ; } ; int get_int(const std::string& key, int default_value = 0) const { std::string value = _map.at(key) ; if(value.empty()) return default_value ; else return atoi(value.c_str()) ; } ; private: // data std::map _map ; } ;