-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigReader.hpp
87 lines (76 loc) · 2.4 KB
/
ConfigReader.hpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef CONFIGREADER_H
#define CONFIGREADER_H
#include <string>
#include <cstdint>
#include <map>
namespace dc {
/**
* @brief An enum with every type of setting.
* Use Setting::<name> to reauest a setting from a ConfigReader instance
* instead of a raw string.
*/
enum class ImageSetting : uint8_t {
rawfile = 0,
encfile,
decfile,
rle,
quantfile,
width,
height,
logfile,
AMOUNT
};
enum class VideoSetting : uint8_t {
rawfile = 0,
encfile,
decfile,
rle,
quantfile,
width,
height,
logfile,
gop,
merange,
motioncompensation,
AMOUNT
};
static constexpr size_t EXPECTED_VideoEncoderSettings = 8;
static const VideoSetting VideoEncoderSettings[] = {
VideoSetting::rawfile, VideoSetting::encfile,
VideoSetting::rle , VideoSetting::quantfile,
VideoSetting::width , VideoSetting::height,
VideoSetting::gop , VideoSetting::merange
};
static constexpr size_t EXPECTED_VideoDecoderSettings = 3;
static const VideoSetting VideoDecoderSettings[] = {
VideoSetting::encfile, VideoSetting::decfile,
VideoSetting::motioncompensation
};
const std::string SettingToKey(ImageSetting s);
const std::string SettingToKey(VideoSetting s);
/**
* @brief
* Helper class to read config files containing 'key=value' lines.
* If a function returns 'false', the getErrorDescription() member
* provides an error string
*/
class ConfigReader {
private:
std::map<std::string, std::string> m_keyValues;
std::string m_errStr;
public:
ConfigReader(void);
~ConfigReader(void);
bool read(const std::string &fileName);
bool getKeyValue(const ImageSetting &key, std::string &value);
bool getKeyValue(const VideoSetting &key, std::string &value);
const std::string getValue(const ImageSetting &key) const;
const std::string getValue(const VideoSetting &key) const;
const std::string toString(void) const;
void clear(void);
bool verifyForImage(void);
bool verifyForVideo(bool);
std::string getErrorDescription(void) const;
};
}
#endif // CONFIGREADER_H