ConfigParser.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3#pragma once
4
5#include <string>
6#include <vector>
7#include <map>
8
9class CDM_DECL ConfigSet
10{
11public:
12 void SetKeyValues(const std::map<std::string, std::string>& keyValues);
13 void AddKeyValue(const std::string& key, const std::string& value);
14 const std::map<std::string, std::string>& GetKeyValues() const { return m_keyValues; }
15
16 bool HasKey(const std::string& key) const;
17 std::string GetValue(const std::string& key) const;
18
19private:
20 std::map<std::string, std::string> m_keyValues;
21};
22
23class CDM_DECL ConfigParser
24{
25public:
26
27 ConfigParser(const std::string& configFilePath);
28 ConfigParser(const std::string& configFilePath, bool splitGroups);
29
30 const std::vector<ConfigSet>& GetConfigSets() const { return m_configSets; }
31
32 static ConfigSet* FileToConfigSet(const std::string& file);
33
34private:
35 void ParseConfigFile(const std::string& configFile, bool splitGroups = true);
36 std::tuple<std::string, std::string> ParseKeyValue(const std::string& line);
37
38 std::map<std::string, std::string> m_globalKeyValues;
39 std::vector<ConfigSet> m_configSets;
40
41 bool m_parsingGlobalKeyValues = true;
42};
Definition: ConfigParser.h:24
std::vector< ConfigSet > m_configSets
Definition: ConfigParser.h:39
const std::vector< ConfigSet > & GetConfigSets() const
Definition: ConfigParser.h:30
std::map< std::string, std::string > m_globalKeyValues
Definition: ConfigParser.h:38
Definition: ConfigParser.h:10
const std::map< std::string, std::string > & GetKeyValues() const
Definition: ConfigParser.h:14
std::map< std::string, std::string > m_keyValues
Definition: ConfigParser.h:20

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.