Skip to content

Latest commit

 

History

History
79 lines (72 loc) · 3 KB

ssuvariables_p.h

File metadata and controls

79 lines (72 loc) · 3 KB
 
Aug 21, 2015
Aug 21, 2015
2
* @file ssuvariables_p.h
3
4
5
6
7
* @copyright 2013 Jolla Ltd.
* @author Bernd Wachter <bwachter@lart.info>
* @date 2013
*/
Aug 21, 2015
Aug 21, 2015
8
9
#ifndef _SSUVARIABLES_P_H
#define _SSUVARIABLES_P_H
10
11
12
13
#include <QObject>
#include <QHash>
May 23, 2013
May 23, 2013
14
15
#include "ssusettings.h"
16
17
18
19
20
21
class SsuVariables: public QObject {
Q_OBJECT
public:
SsuVariables();
/**
Jul 5, 2013
Jul 5, 2013
22
23
24
25
26
* Return a default variable section, if exists, or an empty string.
*
* To identify the default section the section name gets split at '-', and
* the first token (or second token for "var-" sections) replaced with
* "default". You should therefore avoid "-" in section names.
Jul 5, 2013
Jul 5, 2013
28
static QString defaultSection(SsuSettings *settings, QString section);
Mar 22, 2013
Mar 22, 2013
29
30
31
/**
* Resolve a whole string, containing several variables. Variables inside variables are allowed
*/
Jul 5, 2013
Jul 5, 2013
32
static QString resolveString(QString pattern, QHash<QString, QString> *variables, int recursionDepth=0);
Mar 22, 2013
Mar 22, 2013
33
34
35
/**
* Resolve variables; variable can be passed as %(var) or var
*/
Jul 5, 2013
Jul 5, 2013
36
37
38
39
40
41
42
43
44
45
46
47
48
static QString resolveVariable(QString variable, QHash<QString, QString> *variables);
/**
* Set the settings object to use
*/
void setSettings(SsuSettings *settings);
/*
* Return the settings object used
*/
SsuSettings *settings();
/**
* Return a variable from the given variable section. 'var'- is automatically
* prepended to the section name if not specified already. Recursive search
* through several variable sections (specified in the section) is supported,
Jul 6, 2013
Jul 6, 2013
49
* returned will be the last occurence of the variable.
Jul 5, 2013
Jul 5, 2013
50
51
52
53
*/
QVariant variable(QString section, const QString &key);
static QVariant variable(SsuSettings *settings, QString section, const QString &key);
/**
Jul 5, 2013
Jul 5, 2013
54
55
56
57
58
59
60
61
62
63
64
* Return the requested variable section, recursively looking up all variable
* sections referenced inside with the 'variable' keyword. 'var-' is automatically
* prepended to the section names of included variable sections, but not for
* the parent section.
*
* Variables starting with _ are treated as local variables and are ignored.
* The special key 'local' may contain a section-specific stringlist with
* additional keys which should be treated local.
*
* This function tries to identify a default configuration section, and merges
* the default section with the requested section.
Jul 5, 2013
Jul 5, 2013
65
66
*/
void variableSection(QString section, QHash<QString, QString> *storageHash);
Jul 6, 2013
Jul 6, 2013
67
68
static void variableSection(SsuSettings *settings, QString section,
QHash<QString, QString> *storageHash);
Jul 5, 2013
Jul 5, 2013
69
70
private:
Jul 6, 2013
Jul 6, 2013
71
72
73
74
75
static void readSection(SsuSettings *settings, QString section,
QHash<QString, QString> *storageHash, int recursionDepth,
bool logOverride=true);
static QVariant readVariable(SsuSettings *settings, QString section, const QString &key,
int recursionDepth, bool logOverride=true);
Jul 5, 2013
Jul 5, 2013
76
SsuSettings *m_settings;