Program Listing for File parser.h
↰ Return to documentation for file (src/parser.h)
#ifndef PARSER_H_
#define PARSER_H_
#include <iostream>
#include <vector>
#include <fstream>
class SettingsParserException : public std::exception {
private:
std::string message;
public:
SettingsParserException(const char* msg) : message(msg) {}
const char* what() const throw() {
return message.c_str();
}
};
class Settings {
private:
struct option {
char type;
std::string name;
double value_d;
std::string value_s;
option(std::string n, double v) : name(n), value_d(0), value_s("") {}
option(std::string n, std::string v);
option() : name(""), value_d(0), value_s("") {}
};
std::vector<option> settings;
std::ifstream input_file;
bool ParseLine(std::string line);
public:
Settings(const char* filename);
~Settings();
int LoadSettings();
double GetOptionDouble(std::string name);
std::string GetOptionString(std::string name);
bool GetOptionBool(std::string name);
};
#endif //PARSER_H_