clean up
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
|
||||
#include "ConfigParser.hpp"
|
||||
|
||||
|
||||
|
||||
// should i be sending & references?
|
||||
// const?
|
||||
std::string ConfigParser::_pre_set_val_check(const std::string key, \
|
||||
const std::string value)
|
||||
{
|
||||
@@ -16,12 +16,8 @@ std::string ConfigParser::_pre_set_val_check(const std::string key, \
|
||||
if (key.find_first_of(";") != std::string::npos)
|
||||
throw std::invalid_argument("bad config file arguments 2");
|
||||
|
||||
// there shouldn't be any tabs, right? not between values...
|
||||
if (value.find_first_of("\t") != std::string::npos)
|
||||
{
|
||||
// std::cout << value << "\n";
|
||||
throw std::invalid_argument("why would you put tabs between values");
|
||||
}
|
||||
|
||||
size_t i = value.find_first_of(";");
|
||||
// so you can't have no ;
|
||||
@@ -36,25 +32,22 @@ std::string ConfigParser::_pre_set_val_check(const std::string key, \
|
||||
return (value.substr(0, i));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// const?
|
||||
// assumes curr is on a space or \t or \n
|
||||
// get first word? next word? word?
|
||||
std::string ConfigParser::_get_first_word(size_t *curr)
|
||||
{
|
||||
size_t start;
|
||||
|
||||
// are these checks excessive?
|
||||
if ((start = _content.find_first_not_of(" \t\n", *curr)) == std::string::npos)
|
||||
throw std::invalid_argument("bad config file arguments");
|
||||
if ((*curr = _content.find_first_of(" \t\n", start)) == std::string::npos)
|
||||
throw std::invalid_argument("bad config file arguments");
|
||||
|
||||
std::string key = _content.substr(start, *curr - start);
|
||||
|
||||
return (key);
|
||||
}
|
||||
|
||||
// const?
|
||||
// also assumes curr is on a space \t or \n
|
||||
std::string ConfigParser::_get_rest_of_line(size_t *curr)
|
||||
{
|
||||
@@ -62,7 +55,6 @@ std::string ConfigParser::_get_rest_of_line(size_t *curr)
|
||||
|
||||
if ((start = _content.find_first_not_of(" \t\n", *curr)) == std::string::npos)
|
||||
throw std::invalid_argument("bad config file arguments");
|
||||
|
||||
if ((*curr = _content.find_first_of("\n", start)) == std::string::npos)
|
||||
throw std::invalid_argument("bad config file arguments");
|
||||
|
||||
@@ -71,8 +63,6 @@ std::string ConfigParser::_get_rest_of_line(size_t *curr)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ConfigParser::_print_content() const
|
||||
{
|
||||
std::cout << _content;
|
||||
|
||||
Reference in New Issue
Block a user