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 
9 class CDM_DECL ConfigSet
10 {
11 public:
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 
19 private:
20  std::map<std::string, std::string> m_keyValues;
21 };
22 
23 class CDM_DECL ConfigParser
24 {
25 public:
26  ConfigParser(const std::string& configFilePath);
27 
28  const std::vector<ConfigSet>& GetConfigSets() const { return m_configSets; }
29 
30 private:
31  void ParseConfigFile(const std::string& configFile);
32  std::tuple<std::string, std::string> ParseKeyValue(const std::string& line);
33 
34  std::map<std::string, std::string> m_globalKeyValues;
35  std::vector<ConfigSet> m_configSets;
36 
37  bool m_parsingGlobalKeyValues = true;
38 };
Definition: ConfigParser.h:9
std::map< std::string, std::string > m_globalKeyValues
Definition: ConfigParser.h:34
const std::vector< ConfigSet > & GetConfigSets() const
Definition: ConfigParser.h:28
std::vector< ConfigSet > m_configSets
Definition: ConfigParser.h:35
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
Definition: ConfigParser.h:23