Skip to content
Permalink
122db818e8
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
43 lines (36 sloc) 791 Bytes
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <map>
#include <string>
#include <vector>
#include <sstream>
class Config {
std::string filename;
public:
std::map<std::string, std::string, std::string> attributes;
int logLevel;
};
Config createNewConfig(std::string filename) {
Config c;
std::ifstream myfile;
std::string line;
std::vector<std::string> lineArray;
myfile.open(filename);
if(myfile.is_open()) {
while(!myfile.eof()) {
getline(myfile, line);
std::istringstream iss(line);
for(std::string line; iss >> line; ) {
lineArray.push_back(line);
}
c.attributes[lineArray[1]] = lineArray[0], lineArray[2];
}
}
return c;
};
int main() {
Config c = createNewConfig("config.txt");
std::cout << c.attributes["i"];
return 0;
}