8#ifndef NETWORKCONFIGPARSER_HPP
9#define NETWORKCONFIGPARSER_HPP
37 std::map<std::string, std::string>
data;
45 if (line.find(
'#') != line.npos)
46 line.erase(line.find(
'#'));
54 return (line.find_first_not_of(
' ') == line.npos);
60 void parseLine(
const std::string &line,
size_t const lineNum)
62 std::string temp = line;
70 while ((pos = temp.find(
",")) != std::string::npos)
72 token = temp.substr(0, pos);
76 temp.erase(0, pos + std::string(
",").length());
106 while (std::getline(file, line))
109 std::string temp = line;
132 while (std::getline(file, line))
135 std::string temp = line;
154 int minDiff = INT_MAX;
155 bool foundConnectionMatch =
false;
162 foundConnectionMatch =
true;
182 if (!foundConnectionMatch)
209 bool getKey(
const std::string &key)
const
211 return data.find(key) !=
data.end();
216 template <
typename scalarT>
217 scalarT
getValue(
const std::string &key, scalarT
const &defaultValue = scalarT())
const
std::size_t DisCosTiC_Datatype
static T stringTOScalarT(std::string const &val)
a wrapper class which contains functions for parsing the configuration file end class configParser
bool getKey(const std::string &key) const
std::map< std::string, std::string > data
which will hold pairs of key-value
scalarT getValue(const std::string &key, scalarT const &defaultValue=scalarT()) const
a function that retrieves the value of a specific key
bool whitespace(const std::string &line) const
a function that returns false if a non-space character was found, true otherwise. The function is "co...
void setData(const int numberOfConcurrentConnection, const int buffersize, DisCosTiC::Networktype &latency, DisCosTiC::Networktype &inverse_bandwidth, DisCosTiC::Networktype &o, DisCosTiC::Networktype &O, DisCosTiC::Networktype &g, DisCosTiC::Networktype &G, DisCosTiC_Datatype &eagerLimit, const int mode)
NetworkConfigParser()
a class to set the name of the configuration file and extracts and parses the data
void parseLine(const std::string &line, size_t const lineNum)
a function that parse the line by calling above mentioed functions
void removeComment(std::string &line) const
a function that removes everything from the semicolon (including it) to the end of the line.
NetworkConfigParser(const std::string &fileName)
double networkFileData[1000][8]
std::string fileName
As member variables, we will only have a std::string, which will hold the name of the configuration f...
void readData(const std::string &fileName)
#define fileopen(myfile, filename)
open an open file
#define fileclose(myfile, filename)
close an open file
std::array< DisCosTiC_Timetype, 4 > Networktype
it parses the user-defined configuration file (.cfg)