-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpairfile.h
44 lines (30 loc) · 1.24 KB
/
pairfile.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
39
40
41
42
43
44
/***********************************************************
* this code by Peter Semiletov is Public Domain *
**********************************************************/
#ifndef PAIRFILE_H
#define PAIRFILE_H
#include <string>
#include <vector>
#include <map>
//using namespace std;
typedef std::map <std::string, std::string> TSPair;
class CPairFile
{
public:
std::string file_name;
TSPair values;
bool get_bool (const std::string &key, bool def_value = false);
int get_int (const std::string &key, int def_value = 0);
size_t get_num (const std::string &key, unsigned long long def_value = 0);
float get_float (const std::string &key, float def_value = 0.0f);
std::string get_string (const std::string &key, const std::string &def_value = "");
//size_t get_file_size (const std::string &key, const std::string &def_value = "64k"); //return value in bytes
void set_string (const std::string &key, const std::string &value);
void set_int (const std::string &key, int value);
void set_float (const std::string &key, float value);
void save();
CPairFile (const std::string &fname, bool from_data = false);
CPairFile (int argc, char *argv[]);
CPairFile (std::vector <std::string> envars); //ENV VARS
};
#endif