-
Notifications
You must be signed in to change notification settings - Fork 0
/
udevrule.cpp
77 lines (65 loc) · 1.36 KB
/
udevrule.cpp
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
#include "udevrule.h"
UdevRule::UdevRule()
{
}
void UdevRule::addComponent(Component c)
{
addComponent(c.key,c.op,c.value);
}
void UdevRule::addComponent(QString key, QString op, QString value)
{
Component component;
component.key = key;
component.op = op;
component.value = value;
components.append(component);
}
bool UdevRule::isEmpty() const
{
return !components.size();
}
bool UdevRule::hasSymlink() const
{
foreach (Component c, components) {
if (c.key.toUpper()=="SYMLINK"){
return true;
}
}
return false;
}
QString UdevRule::toString() const
{
QString r = "";
foreach (Component c, components) {
r+=c.key+c.op+"\""+c.value+"\"";
if (components.indexOf(c)<components.size()-1){
r+=",";
}
}
return r;
}
QString UdevRule::getFile() const
{
return file;
}
void UdevRule::setFile(const QString &value)
{
file = value;
}
UdevRule::Component UdevRule::getComponent(QString key,bool isAttr) const
{
if (isAttr){
foreach (Component c, components) {
if ("ATTRS{"+key+"}" == c.key || "ATTR{"+key+"}" == c.key){
return c;
}
}
}else{
foreach (Component c, components) {
if (c.key == key){
return c;
}
}
}
return Component();
}