-
Notifications
You must be signed in to change notification settings - Fork 0
/
IniParser.h
38 lines (31 loc) · 1.15 KB
/
IniParser.h
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
38
//
// Created by Маргарита on 10.09.2017.
//
#pragma once
#include <map>
#include "SectionNotFound.h"
#include "ParamNotFound.h"
class IniParser
{
public:
std::string fileName;
IniParser( const std::string& f);
IniParser();
void printMap();
bool isHaveASec(const std::string& sec_name ) const;
bool isHaveParam (const std::string &sec_name, const std::string& param_name) const;
template<typename T>
T GetValue ( std::string §ionName, std::string ¶mName) const
throw (SectionNotFound, ParamNotFound) ;
private:
enum typesOfValues {STRING = 0, INT = 1, DOUBLE = 2 };
mutable std::map <std::string, std::map <std::string, std::pair < std::string, typesOfValues >>> mySections;
std::string varName, varValue, sectionName;
void searchSec (const std::string &s, int openIndex , int closeIndex);
void searchVarName (std::string s, int equalIndex);
void searchVarValue (std::string s, int equalIndex);
void removeSpaces(std::string &s);
void removeComments (std::string &s);
typesOfValues getTypeOfValue(std::string &s);
void readFile();
};