This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
/
kconfig_parser.hpp
67 lines (57 loc) · 1.92 KB
/
kconfig_parser.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
#ifndef ELEKTRA_KCONFIGPARSER_HPP
#define ELEKTRA_KCONFIGPARSER_HPP
#include "file_utility.hpp"
#include <kdberrors.h>
#include <kdbplugin.hpp>
using CppKeySet = kdb::KeySet;
using CppKey = kdb::Key;
namespace kconfig
{
class KConfigParser
{
private:
/* This FileUtility is used to read from the file */
FileUtility & fileUtility;
/* This KeySet is used to store the parsed values */
CppKeySet & keySet;
/**
* @brief This method parses a group from the file into an Elektra key
* Format: (\[keyname\])+[\[$meta\]]
* @param parent
* @return
*/
kdb::Key loadGroupNameFromFile (CppKey const & parent);
/**
* @brief This method parses a key from the file into an Elektra key.
* Format: keyname[\[locale\]](\[$meta\])*[=value]
* @param parent
* @return
*/
kdb::Key loadKeyFromFile (CppKey const & parent);
/**
* @brief This method is used to add a key to the KeySet only if it contains KConfig metadata
* @param key This is the key that we want to add
*/
void appendIfContainsMeta (CppKey const & key);
/**
* @brief This method is used to add a key to the KeySet if it isn't the same as the group
* @param key This is the key that we want to add
* @param group This is the key that we don't want to add
*/
void appendIfNotGroup (CppKey const & key, CppKey const & group);
public:
/**
* @brief This constructor is used to abstract the File and KeySet that we're working on as well as the parsing methods
* @param fileUtilityParam This FileUtility is where we read the file from
* @param keySetParam This KeySet is where we store the parsed keys
*/
KConfigParser (FileUtility & fileUtilityParam, CppKeySet & keySetParam);
/**
* @brief This method is used to parses a KConfig file into an Elektra KeySet similarly to the KConfigIniBackend from the KConfig
* project
* @param parent the prefix to all the created keys
*/
void parse (CppKey const & parent);
};
}
#endif // ELEKTRA_KCONFIGPARSER_HPP