/*
* EtherPix simulator
*
* Copyright 2017 Stefan Schuermans <stefan schuermans info>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <algorithm>
#include <cctype>
#include <functional>
#include <fstream>
#include <stdexcept>
#include <sstream>
#include <string>
#include "config.h"
/**
* @brief constructor
* @param[in] configFile name of config file
*/
Config::Config(std::string const &configFile)
{
readFile(configFile);
}
/**
* @brief remove whitespace at beging and end of string
* @param[in,out] str string to process
*/
void Config::trim(std::string &str)
{
// remove leading whitespace
str.erase(str.begin(),
std::find_if(str.begin(), str.end(),
std::not1(std::ptr_fun<int, int>(std::isspace))));
// remove trailing whitespace
str.erase(std::find_if(str.rbegin(), str.rend(),