-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfileoptionreader.cpp
38 lines (30 loc) · 954 Bytes
/
fileoptionreader.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "fileoptionreader.h"
#include <fstream>
#include <boost/algorithm/string.hpp>
FileOptionReader::FileOptionReader(const std::string& fileName) : m_fileName(fileName)
{
}
void FileOptionReader::doReadOptions(std::map<std::string, std::string>& values)
{
std::ifstream fileStream(m_fileName.c_str(), std::ifstream::in);
if (!fileStream.is_open())
throw std::runtime_error("Can't open " + m_fileName);
FileStreamReader reader(fileStream);
reader.readOptions(values);/*
std::string line;
size_t pos;
std::string name, value;
while (fileStream.good())
{
std::getline (fileStream, line);
pos = line.find('=');
name = line.substr(0, pos);
pos++;
value = line.substr(pos, line.length() - pos);
boost::trim(name);
boost::trim(value);
if (!name.empty() && name[0] != '#')
values[name] = value;
}
fileStream.close();*/
}