forked from licoffe/POE-Stash-indexer-NG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCFG_reader.h
34 lines (30 loc) · 949 Bytes
/
CFG_reader.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
/*
* CFG_reader.h
* POE-Indexer-NG
*
* Created by Licoffe on December 14th 2016.
* Distributed under MIT license, See file LICENSE for detail
* -----------------------------------------------------------------------------
* Description
*
* Contains minimal code to parse configuration files
*/
#ifndef _CFG_READER_H_
#define _CFG_READER_H_
#include <string>
#include <map>
#include <fstream>
#include <sstream>
#include <regex>
#include <iostream>
class CFG_reader {
public:
CFG_reader( const std::string path );
std::string get( const std::string field );
std::map<std::string, std::string> fields; // holds parsed values
private:
const std::regex COMMENT_RE = std::regex( "^#.*" );
const std::regex DEFINITION_RE =
std::regex( "([a-zA-Z_]+)\\s*=\\s*([a-zA-Z0-9_:/. ]+)" );
};
#endif /* _CFG_READER_H_ */